0
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2025-07-23 20:31:37 +00:00
Files
openwrt/scripts/ipkg-remove
Felix Fietkau 642d568b0f build: fix ipkg-remove: add support for removing apk files
Use apk adbdump to extract metadata from .apk files to derive the real
package name.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2025-07-15 20:48:45 +02:00

43 lines
1004 B
Bash
Executable File

#!/usr/bin/env bash
sourcename="$1"; shift
for pkg in "$@"; do
case "$pkg" in
*/"${sourcename}_"*.ipk|\
*/"${sourcename}-"[0-9]*.apk)
rm -vf "$pkg"
;;
*.ipk)
tar -Ozxf "$pkg" ./control.tar.gz 2>/dev/null | tar -Ozxf - ./control 2>/dev/null | {
packagename=
abiversion=
while read field value; do
case "$field" in
Package:) packagename="$value";;
ABIVersion:) abiversion="$value";;
esac
done
[ -n "$abiversion" ] && packagename="${packagename%%$abiversion}"
[ "$packagename" = "$sourcename" ] && rm -vf "$pkg"
}
;;
*.apk)
apk adbdump "$pkg" | grep -E '^ (name:|.*openwrt:abiversion)' | {
packagename=
abiversion=
while read field value; do
case "$field" in
name:) packagename="$value";;
-) abiversion="${value##*abiversion=}";;
esac
done
[ -n "$abiversion" ] && packagename="${packagename%%$abiversion}"
[ "$packagename" = "$sourcename" ] && rm -vf "$pkg"
}
;;
esac
done
exit 0