[openwrt/openwrt] base-files: sysupgrade: add saving list of installed packages for APK

LEDE Commits lede-commits at lists.infradead.org
Sat Dec 28 01:59:54 PST 2024


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

commit cee18af7049c32713a5ada5196d8ad238ee837fb
Author: Robert Marko <robimarko at gmail.com>
AuthorDate: Sat Nov 30 13:05:39 2024 +0100

    base-files: sysupgrade: add saving list of installed packages for APK
    
    Add support for saving list of installed packages for APK in the same way
    we do it for OPKG.
    
    Unlike OPKG, we dont generate .control files for packages so lets use .list
    files instead.
    
    Fixes: #16947
    Link: https://github.com/openwrt/openwrt/pull/17123
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 package/base-files/files/sbin/sysupgrade | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
index 611d8830bf..e51ab0b4f1 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -279,11 +279,19 @@ create_backup_archive() {
 			if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
 				# Format: pkg-name<TAB>{rom,overlay,unknown}
 				# rom is used for pkgs in /rom, even if updated later
-				tar_print_member "$INSTALLED_PACKAGES" "$(find /usr/lib/opkg/info -name "*.control" \( \
-					\( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \
-					\( -exec test -f /overlay/upper/{} \; -exec echo {} overlay \; \) -o \
-					\( -exec echo {} unknown \; \) \
-					\) | sed -e 's,.*/,,;s/\.control /\t/')" || ret=1
+				if [ -d "/usr/lib/opkg/info" ]; then
+					tar_print_member "$INSTALLED_PACKAGES" "$(find /usr/lib/opkg/info -name "*.control" \( \
+						\( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \
+						\( -exec test -f /overlay/upper/{} \; -exec echo {} overlay \; \) -o \
+						\( -exec echo {} unknown \; \) \
+						\) | sed -e 's,.*/,,;s/\.control /\t/')" || ret=1
+				elif [ -d "/lib/apk/packages" ]; then
+					tar_print_member "$INSTALLED_PACKAGES" "$(find /lib/apk/packages -name "*.list" \( \
+						\( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \
+						\( -exec test -f /overlay/upper/{} \; -exec echo {} overlay \; \) -o \
+						\( -exec echo {} unknown \; \) \
+						\) | sed -e 's,.*/,,;s/\.list /\t/')" || ret=1
+				fi
 			fi
 		fi
 




More information about the lede-commits mailing list