base-files: sysupgrade: add function for conffiles retrieval
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>
Fri, 10 Jul 2020 10:47:49 +0000 (12:47 +0200)
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>
Tue, 29 Dec 2020 23:00:13 +0000 (00:00 +0100)
The find command to retrieve files from /etc/sysupgrade.conf and
/lib/upgrade/keep.d/* is used twice in almost the same way.

Move it into a function to consolidate, enhance readability and make
future adjustments easier.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Acked-by: Paul Spooren <mail@aparcar.org>
Reviewed-by: Philip Prindeville <philipp@redfish-solutions.com>
package/base-files/Makefile
package/base-files/files/sbin/sysupgrade

index 47d4e73b42a6c8aebd7175c8ab0b963a220e28a6..35a07f2aad3e6fc41cf3010ce8c7b14ef12d2cde 100644 (file)
@@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/version.mk
 include $(INCLUDE_DIR)/feeds.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=242
+PKG_RELEASE:=243
 PKG_FLAGS:=nonshared
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
index 3300d8e1ea559c5e2e696876c5f500a89c4f97e7..7977b06ef18e9f3c10b6327bb233d9b3fc6602ac 100755 (executable)
@@ -131,12 +131,19 @@ list_changed_conffiles() {
        done
 }
 
+list_static_conffiles() {
+       local filter=$1
+
+       find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
+               /etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \
+               \( -type f -o -type l \) $filter 2>/dev/null
+}
+
 add_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 \) $find_filter 2>/dev/null;
-         list_changed_conffiles ) | sort -u > "$file"
+
+       ( list_static_conffiles "$find_filter"; list_changed_conffiles ) |
+               sort -u > "$file"
        return 0
 }
 
@@ -154,9 +161,7 @@ add_overlayfiles() {
 
                # backup files from /etc/sysupgrade.conf and /lib/upgrade/keep.d, but
                # ignore those aready controlled by opkg conffiles
-               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 | sort -u |
+               list_static_conffiles | sort -u |
                        grep -h -v -x -F -f $conffiles > "$keepfiles"
 
                # backup conffiles, but only those changed if '-u'