base-files: sysupgrade: do not rely on opkg to list changed conffiles
authorMatthias Schiffer <mschiffer@universe-factory.net>
Tue, 6 Mar 2018 07:25:32 +0000 (08:25 +0100)
committerMatthias Schiffer <mschiffer@universe-factory.net>
Wed, 7 Mar 2018 07:49:39 +0000 (08:49 +0100)
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@universe-factory.net>
package/base-files/Makefile
package/base-files/files/sbin/sysupgrade

index ab21213b51f866223e37aaffa58c6b9c1ee82ae5..3c7f2308e9c1776264b414c790251b524706b38d 100644 (file)
@@ -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/
index c747c4eaad84f70c2a13c3dcb79f8e989aea118e..bf5428af259e414a3b9f402d5716b00c819ceb1d 100755 (executable)
@@ -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
 }