aboutsummaryrefslogtreecommitdiffstats
path: root/dfly-update
diff options
context:
space:
mode:
Diffstat (limited to 'dfly-update')
-rwxr-xr-xdfly-update55
1 files changed, 55 insertions, 0 deletions
diff --git a/dfly-update b/dfly-update
index 6177aa2..088c706 100755
--- a/dfly-update
+++ b/dfly-update
@@ -500,6 +500,43 @@ upgrade_system() {
echo "+---------+"
}
+# Clean up obsolete and deprecated files
+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
+ echo "Removing obsolete and deprecated files ..."
+ make -f ${mk_upgrade} -V TO_REMOVE | tr ' ' '\n' > ${tmpfile}
+ make -f ${mk_upgrade} -V TO_REMOVE_LATE | tr ' ' '\n' >> ${tmpfile}
+
+ # Credit: https://stackoverflow.com/a/10929511
+ while IFS='' read -r item || [ -n "${item}" ]; do
+ if [ -e ${item} -o -L ${item} ]; then
+ echo " * ${item}"
+ chflags -Rf noschg ${item}
+ rm -rf ${item}
+ fi
+ done < ${tmpfile}
+ rm -f ${tmpfile}
+ echo " => DONE"
+}
+
+# Post-upgrade checking and report:
+# * check /etc for newly installed files that need manual merge
+postupgrade() {
+ [ $# -eq 0 ] || \
+ error ${EC_ARGS} "postupgrade: invalid arguments: $@"
+ echo "+=========================================================+"
+ echo "The following config files need manual merge:"
+ echo "+---------------------------------------------------------+"
+ find /etc -name "*.${NEW_SUF}" | sort
+
+ echo "+=========================================================+"
+ echo "Upgrade the packages by:"
+ echo " # pkg upgrade -f"
+ echo ""
}
@@ -534,6 +571,8 @@ Usage:
Back up the current kernel and world
upgrade
Install the new kernel, world, and config files
+ cleanup
+ Clean up obsolete files, umount and remove image file
_EOF_
echo
cmd_version
@@ -629,6 +668,18 @@ cmd_upgrade() {
upgrade_system
}
+# Clean up obsolete files, umount and remove image
+cmd_cleanup() {
+ [ $# -eq 0 ] || \
+ error ${EC_ARGS} "cmd_cleanup: invalid arguments: $@"
+ cleanup
+ local filepath=$(get_vn_filename ${MNT_DIR})
+ umount_image ${MNT_DIR}
+ rm -f ${filepath}
+ echo "Removed image file: ${filepath}"
+ postupgrade
+}
+
#
# Main
@@ -663,6 +714,10 @@ case "${COMMAND}" in
shift
cmd_upgrade
;;
+ cleanup)
+ shift
+ cmd_cleanup
+ ;;
help|--help|-h|*)
cmd_usage
;;