aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/freebsd-update
diff options
context:
space:
mode:
authorJaakko Heinonen <jh@FreeBSD.org>2010-09-12 18:53:44 +0000
committerJaakko Heinonen <jh@FreeBSD.org>2010-09-12 18:53:44 +0000
commitab7d0151f9f429f912b9a48e0e53dc9158106399 (patch)
treecc0b56f8a2a432e86a3768ecd0eabe21b4270900 /usr.sbin/freebsd-update
parenta458eaa039f041c8bf534a73ee1f340c56237085 (diff)
downloadsrc-ab7d0151f9f429f912b9a48e0e53dc9158106399.tar.gz
src-ab7d0151f9f429f912b9a48e0e53dc9158106399.zip
In backup_kernel(), support backing up subdirectories and handle files
with spaces correctly. Approved by: cperciva MFC after: 1 month
Notes
Notes: svn path=/head/; revision=212505
Diffstat (limited to 'usr.sbin/freebsd-update')
-rw-r--r--usr.sbin/freebsd-update/freebsd-update.sh11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh
index b5420776423a..441d257a98f4 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -2638,11 +2638,13 @@ backup_kernel () {
# "not ours", backup_kernel_finddir would have exited, so
# deleting the directory content is as safe as we can make it.
if [ -d $BACKUPKERNELDIR ]; then
- rm -f $BACKUPKERNELDIR/*
+ rm -fr $BACKUPKERNELDIR
fi
- # Create directory for backup if it doesn't exist.
+ # Create directories for backup.
mkdir -p $BACKUPKERNELDIR
+ mtree -cdn -p "${KERNELDIR}" | \
+ mtree -Ue -p "${BACKUPKERNELDIR}" > /dev/null
# Mark the directory as having been created by freebsd-update.
touch $BACKUPKERNELDIR/.freebsd-update
@@ -2663,9 +2665,8 @@ backup_kernel () {
fi
# Backup all the kernel files using hardlinks.
- find $KERNELDIR -type f $FINDFILTER | \
- sed -Ee "s,($KERNELDIR)/?(.*),\1/\2 ${BACKUPKERNELDIR}/\2," | \
- xargs -n 2 cp -pl
+ (cd $KERNELDIR && find . -type f $FINDFILTER -exec \
+ cp -pl '{}' ${BACKUPKERNELDIR}/'{}' \;)
# Re-enable patchname expansion.
set +f