[OpenWrt-Devel] [PATCH v2 1/4] base-files: minor cleanups on sysupgrade

Luiz Angelo Daros de Luca luizluca at gmail.com
Wed Apr 4 19:28:23 EDT 2018


Renamed add_uci_conffiles to add_conffiles as it includes
any conffiles listed, not only UCI ones.

Make do_save_conffiles arg mandatory

Allow other options after -l (like -c)

Signed-off-by: Luiz Angelo Daros de Luca <luizluca at gmail.com>
---
 package/base-files/files/sbin/sysupgrade | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
index bf5428af25..46e46c3342 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -30,7 +30,7 @@ while [ -n "$1" ]; do
 		-p) export SAVE_PARTITIONS=0;;
 		-b|--create-backup) export CONF_BACKUP="$2" NEED_IMAGE=1; shift;;
 		-r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; shift;;
-		-l|--list-backup) export CONF_BACKUP_LIST=1; break;;
+		-l|--list-backup) export CONF_BACKUP_LIST=1;;
 		-f) export CONF_IMAGE="$2"; shift;;
 		-F|--force) export FORCE=1;;
 		-T|--test) export TEST=1;;
@@ -49,10 +49,10 @@ export CONF_TAR=/tmp/sysupgrade.tgz
 
 IMAGE="$1"
 
-[ -z "$IMAGE" -a -z "$NEED_IMAGE" -o $HELP -gt 0 ] && {
+[ -z "$IMAGE" -a -z "$NEED_IMAGE" -a $CONF_BACKUP_LIST -eq 0 -o $HELP -gt 0 ] && {
 	cat <<EOF
 Usage: $0 [<upgrade-option>...] <image file or URL>
-       $0 [-q] [-i] <backup-command> <file>
+       $0 [-q] [-i] [-c] <backup-command> <file>
 
 upgrade-option:
 	-f <config>  restore configuration from .tar.gz (file or url)
@@ -115,7 +115,7 @@ list_changed_conffiles() {
 	done
 }
 
-add_uci_conffiles() {
+add_conffiles() {
 	local file="$1"
 	( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
 		/etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \
@@ -131,6 +131,7 @@ add_overlayfiles() {
 		-e '\,/META_[a-zA-Z0-9]*$,d' \
 		-e '\,/functions.sh$,d' \
 		-e '\,/[^/]*-opkg$,d' \
+		-e '\,/etc/urandom.seed$,d' \
 	> "$file"
 	return 0
 }
@@ -146,13 +147,13 @@ if [ $SAVE_OVERLAY = 1 ]; then
 	}
 	sysupgrade_init_conffiles="add_overlayfiles"
 else
-	sysupgrade_init_conffiles="add_uci_conffiles"
+	sysupgrade_init_conffiles="add_conffiles"
 fi
 
 include /lib/upgrade
 
 do_save_conffiles() {
-	local conf_tar="${1:-$CONF_TAR}"
+	local conf_tar="$1"
 
 	[ -z "$(rootfs_type)" ] && {
 		echo "Cannot save config while running from ramdisk."
@@ -247,7 +248,7 @@ if [ -n "$CONF_IMAGE" ]; then
 	get_image "$CONF_IMAGE" "cat" > "$CONF_TAR"
 	export SAVE_CONFIG=1
 elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then
-	[ $TEST -eq 1 ] || do_save_conffiles
+	[ $TEST -eq 1 ] || do_save_conffiles "$CONF_TAR"
 	export SAVE_CONFIG=1
 else
 	[ $TEST -eq 1 ] || rm -f "$CONF_TAR"
-- 
2.16.3
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list