[openwrt/openwrt] base-files: sysupgrade: do not rely on opkg to list changed conffiles

LEDE Commits lede-commits at lists.infradead.org
Wed Mar 7 01:00:08 PST 2018


neoraider pushed a commit to openwrt/openwrt.git, branch master:
https://git.lede-project.org/6ed389da85a9259c688aac91c859c804e29c485b

commit 6ed389da85a9259c688aac91c859c804e29c485b
Author: Matthias Schiffer <mschiffer at universe-factory.net>
AuthorDate: Tue Mar 6 08:25:32 2018 +0100

    base-files: sysupgrade: do not rely on opkg to list changed conffiles
    
    Many packages use the opkg conffiles field to list configuration files that
    are to be retained on upgrades. Make this work on systems without opkg.
    
    Signed-off-by: Matthias Schiffer <mschiffer at universe-factory.net>
---
 package/base-files/Makefile              |  2 +-
 package/base-files/files/sbin/sysupgrade | 21 ++++++++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index ab21213..3c7f230 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk
 include $(INCLUDE_DIR)/feeds.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=184
+PKG_RELEASE:=185
 PKG_FLAGS:=nonshared
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
index c747c4e..bf5428a 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -96,12 +96,31 @@ EOF
 # prevent messages from clobbering the tarball when using stdout
 [ "$CONF_BACKUP" = "-" ] && export VERBOSE=0
 
+
+list_conffiles() {
+	awk '
+		BEGIN { conffiles = 0 }
+		/^Conffiles:/ { conffiles = 1; next }
+		!/^ / { conffiles = 0; next }
+		conffiles == 1 { print }
+	' /usr/lib/opkg/status
+}
+
+list_changed_conffiles() {
+	# Cannot handle spaces in filenames - but opkg cannot either...
+	list_conffiles | while read file csum; do
+		[ -r "$file" ] || continue
+
+		echo "${csum}  ${file}" | sha256sum -sc - || echo "$file"
+	done
+}
+
 add_uci_conffiles() {
 	local file="$1"
 	( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
 		/etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \
 		-type f -o -type l 2>/dev/null;
-	  opkg list-changed-conffiles ) | sort -u > "$file"
+	  list_changed_conffiles ) | sort -u > "$file"
 	return 0
 }
 



More information about the lede-commits mailing list