]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
base-files: sysupgrade: -u option was broken with apk 17847/head
authorLuiz Angelo Daros de Luca <luizluca@gmail.com>
Mon, 3 Feb 2025 23:01:11 +0000 (20:01 -0300)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 12 Apr 2026 23:27:55 +0000 (01:27 +0200)
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 <luizluca@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/17847
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
package/base-files/files/sbin/sysupgrade

index a5004de47692ebbd13061fa15cada36f68f991aa..12575e0b1fad499ae5859db24d6226062858e739 100755 (executable)
@@ -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