[RFC PATCH 1/2] base-files: sysupgrade: add function for conffiles retrieval
Paul Spooren
mail at aparcar.org
Sun Dec 27 16:39:52 EST 2020
On Fr, Jul 10, 2020 at 12:47, Adrian Schmutzler
<freifunk at adrianschmutzler.de> wrote:
> The find command to retrieve files from /etc/sysupgrade.conf and
> /lib/upgrade/keep.d/* is used twice in almost similar way.
>
> Move it into a function to consolidate, enhance readability and make
> future adjustments easier.
>
> Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
Acked-by: Paul Spooren <mail at aparcar.org>
> ---
> package/base-files/files/sbin/sysupgrade | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/package/base-files/files/sbin/sysupgrade
> b/package/base-files/files/sbin/sysupgrade
> index ca2eb298dc..4ecea5a303 100755
> --- a/package/base-files/files/sbin/sysupgrade
> +++ b/package/base-files/files/sbin/sysupgrade
> @@ -131,12 +131,18 @@ 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 +160,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'
> --
> 2.20.1
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list