aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Gmelin <grembo@FreeBSD.org>2020-08-19 15:11:27 +0000
committerMichael Gmelin <grembo@FreeBSD.org>2020-08-19 15:11:27 +0000
commit101d33b8fbefa3e68fdfce22bff90838da88ffe8 (patch)
treebabd00097f7660edbb2b74a5a5bc2e7c0f42385f
parent6c55d6e030fbcfbac5aa59891bb497dbb18e45d2 (diff)
downloadsrc-101d33b8fbefa3e68fdfce22bff90838da88ffe8.tar.gz
src-101d33b8fbefa3e68fdfce22bff90838da88ffe8.zip
Unbreak `freebsd-update updatesready'.
The command would only work if PWD happened to be WORKDIR. Also, exit 1 in case WORKDIR exists, but isn't accessible by the current user. PR: 242709 Reported by: Max Fiedler MFC after: 1 week
Notes
Notes: svn path=/head/; revision=364396
-rw-r--r--usr.sbin/freebsd-update/freebsd-update.sh12
1 files changed, 11 insertions, 1 deletions
diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh
index 3ba3f1dec2f2..1e4d5f20d888 100644
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -3341,8 +3341,18 @@ cmd_upgrade () {
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.
cmd_updatesready () {
+ # Check if working directory exists (if not, no updates pending)
+ if ! [ -e "${WORKDIR}" ]; then
+ echo "No updates are available to install."
+ exit 2
+ fi
+
+ # Change into working directory (fail if no permission/directory etc.)
+ cd ${WORKDIR} || exit 1
+
# Construct a unique name from ${BASEDIR}
BDHASH=`echo ${BASEDIR} | sha256 -q`