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>
This commit is contained in:
Felix Fietkau 2025-07-15 20:47:31 +02:00
parent 471fd0a502
commit 642d568b0f
3 changed files with 19 additions and 4 deletions

View File

@ -20,7 +20,7 @@ opkg_package_files = $(wildcard \
apk_package_files = $(wildcard \
$(foreach dir,$(PACKAGE_SUBDIRS), \
$(foreach pkg,$(1), $(dir)/$(pkg)_*.apk)))
$(foreach pkg,$(1), $(dir)/$(pkg)-*.apk)))
# 1: package name
define FeedPackageDir

View File

@ -15,7 +15,7 @@ endef
# Generates a make statement to return a wildcard for candidate ipkg files
# 1: package name
define gen_package_wildcard
$(1)$$(if $$(filter -%,$$(ABIV_$(1))),,[^a-z-])*
$(1)$$(if $$(filter -%,$$(ABIV_$(1))),,[^a-z$(if $(CONFIG_USE_APK),,-)])*
endef
# 1: package name

View File

@ -4,10 +4,11 @@ sourcename="$1"; shift
for pkg in "$@"; do
case "$pkg" in
*/"${sourcename}_"*.ipk)
*/"${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=
@ -21,6 +22,20 @@ for pkg in "$@"; do
[ "$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