[openwrt/openwrt] base-files: handle packages alternatives when apk removes packages

LEDE Commits lede-commits at lists.infradead.org
Mon Jun 23 00:39:15 PDT 2025


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/47b6b9de1a6c37b877be250fdd759a64337c9ecc

commit 47b6b9de1a6c37b877be250fdd759a64337c9ecc
Author: Mario Andrés Pérez <mapb_ at outlook.com>
AuthorDate: Thu Jun 12 15:49:59 2025 +0200

    base-files: handle packages alternatives when apk removes packages
    
    On commit 3010ab8 ("base-files: add update_alternatives function") was
    implemented the function to handle ALTERNATIVES when using APK (OPKG
    handle it internally) but in commit bcc6415 ("base-files: add
    compatibility for APK and OPKG") was only called when adding a package,
    so call it also when removing packages.
    
    While we are here, check for a more specific *.alternatives files instead
    of *.list, and remove redundant "filelist" variable definition.
    
    Fixes: bcc6415 ("base-files: add compatibility for APK and OPKG")
    Fixes: https://github.com/openwrt/openwrt/issues/19090
    Fixes: https://github.com/openwrt/openwrt/issues/16991
    Reported-and-tested-by: Eric Fahlgren <ericfahlgren at gmail.com>
    Signed-off-by: Mario Andrés Pérez <mapb_ at outlook.com>
    Link: https://github.com/openwrt/openwrt/pull/19093
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 package/base-files/files/lib/functions.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index e944d36505..18bf79251d 100644
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -216,6 +216,10 @@ default_prerm() {
 	local filelist="${root}/usr/lib/opkg/info/${pkgname}.list"
 	[ -f "$root/lib/apk/packages/${pkgname}.list" ] && filelist="$root/lib/apk/packages/${pkgname}.list"
 
+	if [ -e "$root/lib/apk/packages/${pkgname}.alternatives" ]; then
+		update_alternatives remove "${pkgname}"
+	fi
+
 	if [ -f "$root/usr/lib/opkg/info/${pkgname}.prerm-pkg" ]; then
 		( . "$root/usr/lib/opkg/info/${pkgname}.prerm-pkg" )
 		ret=$?
@@ -352,8 +356,7 @@ default_postinst() {
 		add_group_and_user "${pkgname}"
 	fi
 
-	if [ -e "${root}/lib/apk/packages/${pkgname}.list" ]; then
-		filelist="${root}/lib/apk/packages/${pkgname}.list"
+	if [ -e "${root}/lib/apk/packages/${pkgname}.alternatives" ]; then
 		update_alternatives install "${pkgname}"
 	fi
 




More information about the lede-commits mailing list