Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/freebsd-update/freebsd-update.sh
Show First 20 Lines • Show All 664 Lines • ▼ Show 20 Lines | RELNUM=`uname -r | | ||||
sed -E 's,-p[0-9]+,,' | | sed -E 's,-p[0-9]+,,' | | ||||
sed -E 's,-SECURITY,-RELEASE,'` | sed -E 's,-SECURITY,-RELEASE,'` | ||||
ARCH=`uname -m` | ARCH=`uname -m` | ||||
FETCHDIR=${RELNUM}/${ARCH} | FETCHDIR=${RELNUM}/${ARCH} | ||||
PATCHDIR=${RELNUM}/${ARCH}/bp | PATCHDIR=${RELNUM}/${ARCH}/bp | ||||
# Disallow upgrade from a version that is not a release | # Disallow upgrade from a version that is not a release | ||||
case ${RELNUM} in | case ${RELNUM} in | ||||
*-RELEASE | *-ALPHA* | *-BETA* | *-RC*) | *-RELEASE | *-ALPHA* | *-BETA* | *-RC*) | ||||
;; | ;; | ||||
emaste: FreeBSD shell style places the cases at the same indentation level as the case statement itself… | |||||
*) | *) | ||||
echo -n "`basename $0`: " | echo -n "`basename $0`: " | ||||
cat <<- EOF | cat <<- EOF | ||||
Cannot upgrade from a version that is not a release | Cannot upgrade from a version that is not a release | ||||
(including alpha, beta and release candidates) | (including alpha, beta and release candidates) | ||||
using `basename $0`. Instead, FreeBSD can be directly | using `basename $0`. Instead, FreeBSD can be directly | ||||
upgraded by source or upgraded to a RELEASE/RELENG version | upgraded by source or upgraded to a RELEASE/RELENG version | ||||
prior to running `basename $0`. | prior to running `basename $0`. | ||||
Currently running: ${RELNUM} | Currently running: ${RELNUM} | ||||
EOF | EOF | ||||
exit 1 | exit 1 | ||||
;; | ;; | ||||
esac | esac | ||||
case ${ARCH} in | |||||
i386 | amd64) | |||||
;; | |||||
*) | |||||
echo -n "`basename $0:`" | |||||
cat <<- EOF | |||||
Upgrading from '${ARCH}' is unsupported by `basename $0`. | |||||
Instead, FreeBSD can be directly upgraded by source. | |||||
EOF | |||||
exit 1 | |||||
;; | |||||
esac | |||||
# Figure out what directory contains the running kernel | # Figure out what directory contains the running kernel | ||||
BOOTFILE=`sysctl -n kern.bootfile` | BOOTFILE=`sysctl -n kern.bootfile` | ||||
KERNELDIR=${BOOTFILE%/kernel} | KERNELDIR=${BOOTFILE%/kernel} | ||||
if ! [ -d ${KERNELDIR} ]; then | if ! [ -d ${KERNELDIR} ]; then | ||||
echo "Cannot identify running kernel" | echo "Cannot identify running kernel" | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
▲ Show 20 Lines • Show All 320 Lines • ▼ Show 20 Lines | |||||
# Pick a mirror. Returns 1 if we have run out of mirrors to try. | # Pick a mirror. Returns 1 if we have run out of mirrors to try. | ||||
fetch_pick_server () { | fetch_pick_server () { | ||||
# Generate a list of not-yet-tried mirrors | # Generate a list of not-yet-tried mirrors | ||||
sort serverlist_tried | | sort serverlist_tried | | ||||
comm -23 serverlist_full - > serverlist | comm -23 serverlist_full - > serverlist | ||||
# Have we run out of mirrors? | # Have we run out of mirrors? | ||||
if [ `wc -l < serverlist` -eq 0 ]; then | if [ `wc -l < serverlist` -eq 0 ]; then | ||||
echo "No mirrors remaining, giving up." | cat <<- EOF | ||||
No mirrors remaining, giving up. | |||||
This may be because upgrading from this platform (${ARCH}) | |||||
or release (${RELNUM}) is unsupported by `basename $0`. Only | |||||
platforms with Tier 1 support can be upgraded by `basename $0`. | |||||
See https://www.freebsd.org/platforms/index.html for more info. | |||||
If unsupported, FreeBSD must be upgraded by source. | |||||
EOF | |||||
return 1 | return 1 | ||||
fi | fi | ||||
# Find the highest priority level (lowest numeric value). | # Find the highest priority level (lowest numeric value). | ||||
SRV_PRIORITY=`cut -f 1 -d ' ' serverlist | sort -n | head -1` | SRV_PRIORITY=`cut -f 1 -d ' ' serverlist | sort -n | head -1` | ||||
# Add up the weights of the response lines at that priority level. | # Add up the weights of the response lines at that priority level. | ||||
SRV_WSUM=0; | SRV_WSUM=0; | ||||
▲ Show 20 Lines • Show All 2,308 Lines • Show Last 20 Lines |
FreeBSD shell style places the cases at the same indentation level as the case statement itself: