Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Sep 2010 18:53:44 +0000 (UTC)
From:      Jaakko Heinonen <jh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r212505 - head/usr.sbin/freebsd-update
Message-ID:  <201009121853.o8CIriSY099956@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jh
Date: Sun Sep 12 18:53:44 2010
New Revision: 212505
URL: http://svn.freebsd.org/changeset/base/212505

Log:
  In backup_kernel(), support backing up subdirectories and handle files
  with spaces correctly.
  
  Approved by:	cperciva
  MFC after:	1 month

Modified:
  head/usr.sbin/freebsd-update/freebsd-update.sh

Modified: head/usr.sbin/freebsd-update/freebsd-update.sh
==============================================================================
--- head/usr.sbin/freebsd-update/freebsd-update.sh	Sun Sep 12 18:50:57 2010	(r212504)
+++ head/usr.sbin/freebsd-update/freebsd-update.sh	Sun Sep 12 18:53:44 2010	(r212505)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009121853.o8CIriSY099956>