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 <luizluca@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/17847
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
(cherry picked from commit 37c5aade23a415a15f829c80ce6cdc36a2e13396)
This commit is contained in:
Luiz Angelo Daros de Luca 2025-02-03 20:01:11 -03:00 committed by Hauke Mehrtens
parent 8ab67441c5
commit 714240997d

View File

@ -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