freebsd-update: Clarify unsupported release upgrade error message

Notify users that upgrading from -CURRENT or -STABLE is unsupported by
freebsd-update.

Also ensure --currently-running provides a correctly formatted release
(as done by -r).

PR:		234771
Submitted by:	Gerald Aryeetey <aryeeteygerald_rogers.com>
Reported by:	yuri
Reviewed by:	bcran
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18803
This commit is contained in:
Ed Maste 2019-01-17 21:38:57 +00:00
parent 50d503b781
commit 0d5c5243af

View File

@ -304,6 +304,14 @@ config_TargetRelease () {
fi
}
# Pretend current release is FreeBSD $1
config_SourceRelease () {
UNAME_r=$1
if echo ${UNAME_r} | grep -qE '^[0-9.]+$'; then
UNAME_r="${UNAME_r}-RELEASE"
fi
}
# Define what happens to output of utilities
config_VerboseLevel () {
if [ -z ${VERBOSELEVEL} ]; then
@ -442,7 +450,8 @@ parse_cmdline () {
NOTTYOK=1
;;
--currently-running)
shift; export UNAME_r="$1"
shift
config_SourceRelease $1 || usage
;;
# Configuration file equivalents
@ -658,6 +667,18 @@ fetchupgrade_check_params () {
FETCHDIR=${RELNUM}/${ARCH}
PATCHDIR=${RELNUM}/${ARCH}/bp
# Disallow upgrade from a version that is not `-RELEASE`
if ! echo "${RELNUM}" | grep -qE -- "-RELEASE$"; then
echo -n "`basename $0`: "
cat <<- EOF
Cannot upgrade from a version that is not a '-RELEASE' using `basename $0`.
Instead, FreeBSD can be directly upgraded by source or upgraded to a
RELEASE/RELENG version prior to running `basename $0`.
EOF
echo "System version: ${RELNUM}"
exit 1
fi
# Figure out what directory contains the running kernel
BOOTFILE=`sysctl -n kern.bootfile`
KERNELDIR=${BOOTFILE%/kernel}