diff options
author | Adrian Schmutzler <freifunk@adrianschmutzler.de> | 2020-07-10 12:47:49 +0200 |
---|---|---|
committer | Adrian Schmutzler <freifunk@adrianschmutzler.de> | 2020-12-30 00:00:13 +0100 |
commit | 93b612221208c731da9b6c7100af636894405f75 (patch) | |
tree | 349fe8b46156c14d00ed7033bf3fd7d64bf2a3ba /package/base-files/files | |
parent | f17c30098356778f212f73b8ea0c2e238907b580 (diff) | |
download | upstream-93b612221208c731da9b6c7100af636894405f75.tar.gz upstream-93b612221208c731da9b6c7100af636894405f75.tar.bz2 upstream-93b612221208c731da9b6c7100af636894405f75.zip |
base-files: sysupgrade: add function for conffiles retrieval
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>
Diffstat (limited to 'package/base-files/files')
-rwxr-xr-x | package/base-files/files/sbin/sysupgrade | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade index 3300d8e1ea..7977b06ef1 100755 --- a/package/base-files/files/sbin/sysupgrade +++ b/package/base-files/files/sbin/sysupgrade @@ -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' |