Skip to content

Instantly share code, notes, and snippets.

@thefloweringash
Created January 31, 2014 10:09
Show Gist options
  • Save thefloweringash/8729473 to your computer and use it in GitHub Desktop.
Save thefloweringash/8729473 to your computer and use it in GitHub Desktop.
There I "fixed" freebsd-update.
#!/bin/sh
# freebsd-update makes assumptions that don't match the world I live
# in. My local mirror has a 20ms rtt, can probably saturate my 130mbps
# line speed and takes about 2 minutes to fetch all of FreeBSD 10's
# dists; freebsd-update's mirrors are at least 140ms away, and take
# about 4 hours to fetch the changes from 9.1-RELEASE-p10 to
# 10.0-RELEASE.
#
# freebsd-update is a clever script that downloads a lot of bsdiff
# patches and whole files when patches are not suitable. The result of
# this process is a collection of files in
# /var/db/freebsd-update/files. If the files already exist, it will
# not fetch them again.
#
# This script provides the entire contents of a given distribution in
# the hashed/gzip'd format that freebsd-update expects, and can
# replace a 4 hour fetch with a 2 minute fetch + 3 minute expand.
#
# Run this before starting the upgrade to the new version.
mkdir -p named
BASEDIR=${1:-${PWD}}
PARTS="base kernel doc games lib32 src"
echo "==> Extracting all parts"
for p in $PARTS; do
FULL_PATH="${BASEDIR}/${p}.txz"
if [ ! -r "${FULL_PATH}" ]; then
echo "Missing file ${FULL_PATH}"
exit 1
fi
echo $p
tar -C named -xf "${FULL_PATH}"
done
echo "==> supplying files to freebsd-update"
mkdir -p "/var/db/freebsd-update/files/"
find named -type f | while read f; do
HASH=`sha256 -q "$f"`
TARGET="/var/db/freebsd-update/files/${HASH}.gz"
if [ ! -f "${TARGET}" ]; then
gzip < "$f" > "${TARGET}"
fi
done
@ericx
Copy link

ericx commented Feb 12, 2015

Looks very cool. I will give this a try.
Ever suss the "No such file" issue?

@FlorianHeigl
Copy link

@ericx that just depends on your workdir.
i don't remember specifics off-hand but you need to be in the right place (i.e. the root of the iso, or /dists.., not sure).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment