From: Luiz Angelo Daros de Luca Date: Mon, 3 Feb 2025 23:01:11 +0000 (-0300) Subject: base-files: sysupgrade: -u option was broken with apk X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=37c5aade23a415a15f829c80ce6cdc36a2e13396;p=thirdparty%2Fopenwrt.git base-files: sysupgrade: -u option was broken with apk The check of files from packages was only checking opkg files. Check for apk as well and fail if both are missing. Signed-off-by: Luiz Angelo Daros de Luca Link: https://github.com/openwrt/openwrt/pull/17847 Signed-off-by: Hauke Mehrtens --- diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade index a5004de4769..12575e0b1fa 100755 --- a/package/base-files/files/sbin/sysupgrade +++ b/package/base-files/files/sbin/sysupgrade @@ -201,12 +201,17 @@ build_list_of_backup_overlay_files() { # do not backup files from packages, except those listed # in conffiles and keep.d - { + if [ -f /usr/lib/opkg/status ]; then find /usr/lib/opkg/info -type f -name "*.list" -exec cat {} \; find /usr/lib/opkg/info -type f -name "*.control" -exec sed \ -ne '/^Alternatives/{s/^Alternatives: //;s/, /\n/g;p}' {} \; | cut -f2 -d: - } | grep -v -x -F -f $conffiles | + elif [ -d /lib/apk/packages ]; then + find /lib/apk/packages -type f -name "*.list" -exec cat {} \; + find /lib/apk/packages -type f -name "*.alternatives" -exec cat {} \; | + tr ' ' '\n' | + cut -f2 -d: + fi | grep -v -x -F -f $conffiles | grep -v -x -F -f $keepfiles | sort -u > "$packagesfiles" rm -f "$keepfiles" "$conffiles" fi @@ -302,6 +307,9 @@ create_backup_archive() { \( -exec test -f /overlay/upper/{} \; -exec echo {} overlay \; \) -o \ \( -exec echo {} unknown \; \) \ \) | sed -e 's,.*/,,;s/\.list /\t/')" || ret=1 + else + echo "Failed to detect installed packages metadata files." >&2 + ret=1 fi fi fi