aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2019-01-08 16:39:34 +0800
committerAaron LI <aly@aaronly.me>2019-01-09 11:50:34 +0800
commit6c54c80c53c817332773ac0f6f99e991b8f3419b (patch)
tree8c2d9127e8b0a5ed5a4945925d070f18225d0ca2
parentd806eb2cde93ab662f724290adaee62ac5a3c3ad (diff)
downloaddfly-update-6c54c80c53c817332773ac0f6f99e991b8f3419b.tar.bz2
Also use cpdup -X to ignore files when copying new /etc
Add the new function make_cpignore() to generate the ignore file for cpdup(1), considering the substitution from '/etc' to '/etc.hdd'. Explicitly remove possible existing 'etc.new' directory left by the previous run.
-rwxr-xr-xdfly-update39
1 files changed, 21 insertions, 18 deletions
diff --git a/dfly-update b/dfly-update
index 5eed602..c6cfc2d 100755
--- a/dfly-update
+++ b/dfly-update
@@ -200,6 +200,18 @@ backup_world() {
exit ${EC_TAR}
}
+# Make the ignore file for cpdup(1)
+make_cpignore() {
+ local cpignore=$(mktemp -t ${NAME}) || exit ${EC_TMPFILE}
+ local f f2
+ for f in ${FILES_IGNORE}; do
+ f2=$(echo "${f}" | sed 's|^/etc/|/etc.hdd/|')
+ # NOTE: 'cpdup -X' doesn't normalize multiple '/' to be one.
+ echo "${MNT_DIR%/}/${f2#/}" >> ${cpignore}
+ done
+ echo ${cpignore}
+}
+
# Install the new system (kernel and world, excluding /etc)
install_system() {
local file item path cpignore
@@ -217,13 +229,8 @@ install_system() {
exit ${EC_MTREE}
done
- echo " => Collecting files to be ignored ..."
- cpignore=$(mktemp -t ${NAME}) || exit ${EC_TMPFILE}
- for file in ${FILES_IGNORE}; do
- # NOTE: 'cpdup -X' doesn't normalize multiple '/' to be one.
- echo "${MNT_DIR%/}/${file#/}" >> ${cpignore}
- echo " * ${file} <ignored>"
- done
+ echo " => Collecting ignored files for cpdup ..."
+ cpignore=$(make_cpignore) || exit ${EC_TMPFILE}
echo " => Installing kernel and world ..."
for item in ${INSTALL_LIST}; do
@@ -287,22 +294,18 @@ add_users() {
# Upgrade the system with new configuration files
upgrade_system() {
- local etcdir file file_etc file_new
+ local etcdir file file_etc file_new cpignore
[ -d "${CACHE_DIR}" ] || mkdir "${CACHE_DIR}"
etcdir="${CACHE_DIR}/etc.new"
+ rm -rf "${etcdir}"
+ echo " => Collecting ignored files for cpdup ..."
+ cpignore=$(make_cpignore) || exit ${EC_TMPFILE}
echo " => Coping new /etc to: ${etcdir}"
- ${CPDUP} -o ${MNT_DIR}/etc.hdd ${etcdir} || exit ${EC_CPDUP}
-
- echo " => Removing ignored files ..."
- for file_etc in ${FILES_IGNORE}; do
- file_new="${etcdir}/${file_etc#/etc/}"
- if [ -f "${file_new}" ]; then
- rm -f "${file_new}"
- echo " * ${file_new} <ignored>"
- fi
- done
+ ${CPDUP} -o -X ${cpignore} ${MNT_DIR%/}/etc.hdd ${etcdir} ||
+ exit ${EC_CPDUP}
+ rm -f ${cpignore}
echo " => Identifying new/updated config files ..."
(cd "${etcdir}" && find -s . -type f) | while read -r file; do