aboutsummaryrefslogtreecommitdiffstats
path: root/dfly-update
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2019-01-06 00:24:26 +0800
committerAaron LI <aly@aaronly.me>2019-01-06 00:24:26 +0800
commit16885e3bdea77e7898bb7599ddeb86e5576e17c4 (patch)
tree071fd11b5a43d71661705cb8747dcb845e4b86ba /dfly-update
parent5f622792533fc26935a781651d009f90b0f22679 (diff)
downloaddfly-update-16885e3bdea77e7898bb7599ddeb86e5576e17c4.tar.bz2
Use cpdup -X to ignore the files to avoid overwriting
Use cpdup -X to not copy the files should be ignored to avoid overwriting. Therefore, the copy-backup-then-rename hack is not needed.
Diffstat (limited to 'dfly-update')
-rwxr-xr-xdfly-update31
1 files changed, 11 insertions, 20 deletions
diff --git a/dfly-update b/dfly-update
index 2f26633..1b7aae4 100755
--- a/dfly-update
+++ b/dfly-update
@@ -88,8 +88,6 @@ FILES_IGNORE='
/etc/rc.conf
/etc/spwd.db
'
-# Filename suffix for the temporarily backup files to avoid overwriting.
-BAK_SUF="__bak__"
# Filename suffix for newly installed files that need (manual) merge.
NEW_SUF="__new__"
@@ -223,16 +221,8 @@ install_system() {
[ $# -eq 0 ] ||
error ${EC_ARGS} "install_system: invalid arguments: $@"
- local file file2 item path
+ local file item path cpignore
echo "Installing the new kernel and world ..."
- echo " => Backing up the files to protect from overriding ..."
- for file in ${FILES_IGNORE}; do
- if [ -f "${file}" ]; then
- file2="${file}.${BAK_SUF}"
- cp -pf "${file}" "${file2}" # NOTE: do NOT use "mv"
- echo " * ${file} <backed>"
- fi
- done
echo " => Creating distribution directories ..."
for item in \
@@ -247,21 +237,22 @@ 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
+ echo "${file}" >> ${cpignore}
+ echo " * ${file} <ignored>"
+ done
+
echo " => Installing kernel and world ..."
for item in ${INSTALL_LIST}; do
echo -n " * Installing: ${item} ... "
- ${CPDUP} -o -u ${MNT_DIR}/${item} /${item} || exit ${EC_CPDUP}
+ ${CPDUP} -o -u -X ${cpignore} ${MNT_DIR}/${item} /${item} ||
+ exit ${EC_CPDUP}
echo "ok"
done
- echo " => Recovering the backed files ..."
- for file in ${FILES_IGNORE}; do
- file2="${file}.${BAK_SUF}"
- if [ -f "${file2}" ]; then
- mv -f "${file2}" "${file}"
- echo " * ${file} <recovered>"
- fi
- done
+ rm -f ${cpignore}
echo " => DONE!"
}