aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2018-04-16 19:12:09 +0800
committerAaron LI <aly@aaronly.me>2018-04-16 19:12:09 +0800
commit009e1116b250e85c07289dc6009ee6093057a60d (patch)
tree865caaa3205dc79ceb18690f86711c31b6dd198a
parent182f5cf539961db4208dda4e5987321a05fcdcc0 (diff)
downloaddfly-update-009e1116b250e85c07289dc6009ee6093057a60d.tar.bz2
Try use the new Makefile_upgrade.inc to cleanup obsolete files
Also bump version to 0.1.3
-rwxr-xr-xdfly-update14
1 files changed, 9 insertions, 5 deletions
diff --git a/dfly-update b/dfly-update
index ecd8c1f..b10ec65 100755
--- a/dfly-update
+++ b/dfly-update
@@ -9,10 +9,12 @@
# Exit immediately if any untested command fails in non-interactive mode
set -e
+# Exit with an error when an undefined variable is referenced
+set -u
DEBUG=${DEBUG:-""}
-VERSION="0.1.2"
+VERSION="0.1.3"
NAME="dfly-update"
TOOLDIR="${0%/*}"
PREFIX="${PREFIX:-${TOOLDIR}}"
@@ -79,7 +81,7 @@ NEW_SUF="__new__"
#
-# XXX: Variables share across two or more functions
+# XXX: Variables shared across two or more functions
#
_FILENAME= # The latest remote system image filename
_MD5=
@@ -521,10 +523,12 @@ upgrade_system() {
cleanup() {
[ $# -eq 0 ] || \
error ${EC_ARGS} "cleanup: invalid arguments: $@"
- local mk_upgrade=/etc/upgrade/Makefile_upgrade.inc
- local tmpfile=$(mktemp -t ${NAME}) || exit ${EC_TMPFILE}
- local item
+ local mk_upgrade tmpfile item
+ mk_upgrade=/etc/upgrade/Makefile_upgrade.inc
+ [ -e "${mk_upgrade}.${NEW_SUF}" ] && mk_upgrade=${mk_upgrade}.${NEW_SUF}
+ tmpfile=$(mktemp -t ${NAME}) || exit ${EC_TMPFILE}
echo "Removing obsolete and deprecated files ..."
+ echo "(according to ${mk_upgrade})"
make -f ${mk_upgrade} -V TO_REMOVE | tr ' ' '\n' > ${tmpfile}
make -f ${mk_upgrade} -V TO_REMOVE_LATE | tr ' ' '\n' >> ${tmpfile}