Changeset View
Standalone View
usr.sbin/freebsd-update/freebsd-update.sh
Show First 20 Lines • Show All 1,093 Lines • ▼ Show 20 Lines | "SERVERNAME must be given via command line or configuration file." | |||||||||
# Define some paths | # Define some paths | |||||||||
SHA256=/sbin/sha256 | SHA256=/sbin/sha256 | |||||||||
PHTTPGET=/usr/libexec/phttpget | PHTTPGET=/usr/libexec/phttpget | |||||||||
# Set up variables relating to VERBOSELEVEL | # Set up variables relating to VERBOSELEVEL | |||||||||
fetch_setup_verboselevel | fetch_setup_verboselevel | |||||||||
} | } | |||||||||
# Packaged base and freebsd-update are incompatible. Exit with an error if | ||||||||||
# packaged base is in use. | ||||||||||
check_pkgbase() | ||||||||||
{ | ||||||||||
emaste: Does `-c` do the right thing here, to use the the pkg database under $BASEDIR? freebsd-update… | ||||||||||
Done Inline ActionsTried an ad-hoc test, populating enough of a directory tree that pkg info works, and -c is indeed sufficient. In addition to /var/db/pkg contents we need /etc/pwd.db, /etc/pkg/FreeBSD.conf, /usr/bin/uname. emaste: Tried an ad-hoc test, populating enough of a directory tree that pkg info works, and `-c` is… | ||||||||||
Not Done Inline Actions
This won't quite work on CheriBSD since there the package prefix is CheriBSD, but I doubt that'll be much of an issue in practice. It would be nice to have a better way to check for pkgbase systems though. What happens if you run this on a system where pkg hasn't been bootstrapped? markj: This won't quite work on CheriBSD since there the package prefix is CheriBSD, but I doubt… | ||||||||||
Done Inline Actions/usr/sbin/pkg doesn't support -q and we get: pkg: illegal option -- q pkg: Invalid argument provided We could check for $BASEDIR/var/db/pkg/local.sqlite and then for /usr/local/sbin/pkg and either of those don't exist assume we're not in a pkgbase config. That will still fail if pkg is not bootstrapped on the host but a jail is being managed by pkgbase. emaste: /usr/sbin/pkg doesn't support -q and we get:
```
pkg: illegal option -- q
pkg: Invalid… | ||||||||||
# Packaged base requires that pkg is bootstrapped. | ||||||||||
if ! pkg -c ${BASEDIR} -N >/dev/null 2>/dev/null; then | ||||||||||
Not Done Inline Actions/var/db/pkg is the default PKG_DBDIR, which could have been overridden? jlduran: `/var/db/pkg` is the default `PKG_DBDIR`, which could have been overridden? | ||||||||||
Not Done Inline Actionsuse pkg -N to check if pkg is boostrapped. bapt: use pkg -N to check if pkg is boostrapped. | ||||||||||
return | ||||||||||
fi | ||||||||||
# Presence of FreeBSD-* package(s) indicates packaged base. | ||||||||||
if ! pkg -c ${BASEDIR} info -q -x '^FreeBSD' 2>/dev/null; then | ||||||||||
return | ||||||||||
fi | ||||||||||
cat <<EOF | ||||||||||
FreeBSD-update is incompatible with the use of packaged base. Please see | ||||||||||
https://wiki.freebsd.org/PkgBase for more information. | ||||||||||
EOF | ||||||||||
exit 1 | ||||||||||
} | ||||||||||
#### Core functionality -- the actual work gets done here | #### Core functionality -- the actual work gets done here | |||||||||
# Use an SRV query to pick a server. If the SRV query doesn't provide | # Use an SRV query to pick a server. If the SRV query doesn't provide | |||||||||
# a useful answer, use the server name specified by the user. | # a useful answer, use the server name specified by the user. | |||||||||
# Put another way... look up _http._tcp.${SERVERNAME} and pick a server | # Put another way... look up _http._tcp.${SERVERNAME} and pick a server | |||||||||
# from that; or if no servers are returned, use ${SERVERNAME}. | # from that; or if no servers are returned, use ${SERVERNAME}. | |||||||||
# This allows a user to specify "update.FreeBSD.org" (in which case | # This allows a user to specify "update.FreeBSD.org" (in which case | |||||||||
# freebsd-update will select one of the mirrors) or "update1.freebsd.org" | # freebsd-update will select one of the mirrors) or "update1.freebsd.org" | |||||||||
▲ Show 20 Lines • Show All 2,402 Lines • ▼ Show 20 Lines | cmd_cron () { | |||||||||
fi | fi | |||||||||
ISFETCHED=1 | ISFETCHED=1 | |||||||||
rm ${TMPFILE} | rm ${TMPFILE} | |||||||||
} | } | |||||||||
# Fetch files for upgrading to a new release. | # Fetch files for upgrading to a new release. | |||||||||
cmd_upgrade () { | cmd_upgrade () { | |||||||||
check_pkgbase | ||||||||||
finalize_components_config ${COMPONENTS} | finalize_components_config ${COMPONENTS} | |||||||||
upgrade_check_params | upgrade_check_params | |||||||||
upgrade_check_kmod_ports | upgrade_check_kmod_ports | |||||||||
upgrade_run || exit 1 | upgrade_run || exit 1 | |||||||||
} | } | |||||||||
# Check if there are fetched updates ready to install. | # Check if there are fetched updates ready to install. | |||||||||
# Chdir into the working directory. | # Chdir into the working directory. | |||||||||
Show All 18 Lines | cmd_updatesready () { | |||||||||
fi | fi | |||||||||
echo "There are updates available to install." | echo "There are updates available to install." | |||||||||
echo "Run '`basename $0` [options] install' to proceed." | echo "Run '`basename $0` [options] install' to proceed." | |||||||||
} | } | |||||||||
# Install downloaded updates. | # Install downloaded updates. | |||||||||
cmd_install () { | cmd_install () { | |||||||||
check_pkgbase | ||||||||||
finalize_components_config ${COMPONENTS} | finalize_components_config ${COMPONENTS} | |||||||||
install_check_params | install_check_params | |||||||||
install_create_be | install_create_be | |||||||||
install_run || exit 1 | install_run || exit 1 | |||||||||
} | } | |||||||||
# Rollback most recently installed updates. | # Rollback most recently installed updates. | |||||||||
cmd_rollback () { | cmd_rollback () { | |||||||||
check_pkgbase | ||||||||||
finalize_components_config ${COMPONENTS} | finalize_components_config ${COMPONENTS} | |||||||||
rollback_check_params | rollback_check_params | |||||||||
rollback_run || exit 1 | rollback_run || exit 1 | |||||||||
} | } | |||||||||
# Compare system against a "known good" index. | # Compare system against a "known good" index. | |||||||||
cmd_IDS () { | cmd_IDS () { | |||||||||
finalize_components_config ${COMPONENTS} | finalize_components_config ${COMPONENTS} | |||||||||
Show All 32 Lines |
Does -c do the right thing here, to use the the pkg database under $BASEDIR? freebsd-update sets BASEDIR for both -j and -b options.