summaryrefslogtreecommitdiffstats
path: root/usr.sbin/freebsd-update
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2007-08-07 19:33:46 +0000
committercperciva <cperciva@FreeBSD.org>2007-08-07 19:33:46 +0000
commit48c0f8b99203e1ade6fb9ffb5a5ed37bdb4f5369 (patch)
treeb17fb5bb828183cc080bd66e6b16b513430f0cf0 /usr.sbin/freebsd-update
parent7e2354fa52ebbde49cd428f1db26b174fb47bdf0 (diff)
downloadFreeBSD-src-48c0f8b99203e1ade6fb9ffb5a5ed37bdb4f5369.zip
FreeBSD-src-48c0f8b99203e1ade6fb9ffb5a5ed37bdb4f5369.tar.gz
When storing old versions of files for use in generating new files via
patching and for rolling back updates, don't copy a file if it has already been stored. This provides a significant speedup to the "Preparing to download files" stage of "freebsd-update fetch" if many updates have already been applied or if a file being updated is linked many times (such as /rescue/*). Reported by: Paul Dekkers MFC after: 1 week Approved by: re (bmah)
Diffstat (limited to 'usr.sbin/freebsd-update')
-rw-r--r--usr.sbin/freebsd-update/freebsd-update.sh25
1 files changed, 20 insertions, 5 deletions
diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh
index 552057e..a08517c 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -1365,12 +1365,27 @@ fetch_files_prepare () {
# Copy all files into /files/. We only need the unmodified files
# for use in patching; but we'll want all of them if the user asks
# to rollback the updates later.
- cut -f 1 -d '|' < $2.hashes |
- while read F; do
+ while read LINE; do
+ F=`echo "${LINE}" | cut -f 1 -d '|'`
+ HASH=`echo "${LINE}" | cut -f 2 -d '|'`
+
+ # Skip files we already have.
+ if [ -f files/${HASH}.gz ]; then
+ continue
+ fi
+
+ # Make sure the file hasn't changed.
cp "${BASEDIR}/${F}" tmpfile
- gzip -c < tmpfile > files/`sha256 -q tmpfile`.gz
+ if [ `sha256 -q tmpfile` != ${HASH} ]; then
+ echo
+ echo "File changed while FreeBSD Update running: ${F}"
+ return 1
+ fi
+
+ # Place the file into storage.
+ gzip -c < tmpfile > files/${HASH}.gz
rm tmpfile
- done
+ done < $2.hashes
# Produce a list of patches to download
sort -k 1,1 -t '|' $3.hashes |
@@ -1665,7 +1680,7 @@ fetch_run () {
# Prepare to fetch files: Generate a list of the files we need,
# copy the unmodified files we have into /files/, and generate
# a list of patches to download.
- fetch_files_prepare INDEX-OLD INDEX-PRESENT INDEX-NEW
+ fetch_files_prepare INDEX-OLD INDEX-PRESENT INDEX-NEW || return 1
# Fetch files.
fetch_files || return 1
OpenPOWER on IntegriCloud