Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107921434
D36241.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D36241.diff
View Options
diff --git a/usr.sbin/freebsd-update/freebsd-update.8 b/usr.sbin/freebsd-update/freebsd-update.8
--- a/usr.sbin/freebsd-update/freebsd-update.8
+++ b/usr.sbin/freebsd-update/freebsd-update.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 10, 2022
+.Dd September 27, 2022
.Dt FREEBSD-UPDATE 8
.Os
.Sh NAME
@@ -51,7 +51,7 @@
tool is used to fetch, install, and rollback binary
updates to the
.Fx
-base system.
+base system. It can also just check for available updates and exit.
.Sh BINARY UPDATES AVAILABILITY
Binary updates are not available for every single
.Fx
@@ -161,9 +161,18 @@
.Cm command
can be any one of the following:
.Bl -tag -width "rollback"
-.It Cm fetch
-Based on the currently installed world and the configuration
-options set, fetch all available binary updates.
+.It Cm check
+Check for available updates without fetching all available
+binary files. Instead, it only fetches and sanitizes the update
+tag and compares it against the current running version of
+.Fx
+at that time. The
+.Cm check
+command can not be called together with the
+.Cm install
+or
+.Cm upgrade
+commands.
.It Cm cron
Sleep a random amount of time between 1 and 3600 seconds,
then download updates as if the
@@ -179,6 +188,9 @@
the random delay serves to minimize the probability that
a large number of machines will simultaneously attempt to
fetch updates.
+.It Cm fetch
+Based on the currently installed world and the configuration
+options set, fetch all available binary updates.
.It Cm upgrade
Fetch files necessary for upgrading to a new release.
Before using this command, make sure that you read the
@@ -256,9 +268,13 @@
stores temporary files and downloaded updates.
.El
.Sh SEE ALSO
-.Xr freebsd-version 1 ,
-.Xr uname 1 ,
.Xr freebsd-update.conf 5 ,
+.Xr freebsd-version 1 ,
.Xr nextboot 8
+.Xr uname 1 ,
.Sh AUTHORS
-.An Colin Percival Aq Mt cperciva@FreeBSD.org
+.An Colin Percival Aq Mt cperciva@FreeBSD.org .
+The
+.Cm check
+command was implemented and documented by
+.An Vinicius Zavam Aq Mt egypcio@FreeBSD.org .
diff --git a/usr.sbin/freebsd-update/freebsd-update.sh b/usr.sbin/freebsd-update/freebsd-update.sh
--- a/usr.sbin/freebsd-update/freebsd-update.sh
+++ b/usr.sbin/freebsd-update/freebsd-update.sh
@@ -59,9 +59,10 @@
--currently-running release
-- Update as if currently running this release
Commands:
- fetch -- Fetch updates from server
+ check -- Check for available updates only
cron -- Sleep rand(3600) seconds, fetch updates, and send an
email if updates were found
+ fetch -- Fetch updates from server
upgrade -- Fetch upgrades to FreeBSD version specified via -r option
updatesready -- Check if there are fetched updates ready to install
install -- Install downloaded updates or upgrades
@@ -474,6 +475,9 @@
# Fetched first in a chain of commands
ISFETCHED=0
+
+ # Check for available updates
+ CHECK_ONLY=0
}
# Parse the command line
@@ -541,7 +545,7 @@
# Commands
cron | fetch | upgrade | updatesready | install | rollback |\
- IDS | showconfig)
+ IDS | showconfig | check)
COMMANDS="${COMMANDS} $1"
;;
@@ -2186,8 +2190,8 @@
echo ${NOWTIME} > lasteolwarn
}
-# Do the actual work involved in "fetch" / "cron".
-fetch_run () {
+# Preparation before the actual work involved in "fetch" / "cron".
+fetch_run_pre () {
workdir_init || return 1
# Prepare the mirror list.
@@ -2205,6 +2209,14 @@
done
fetch_tagsanity || return 1
+ # Check for available updates
+ [ $CHECK_ONLY -eq 1 ] && check_only
+}
+
+# Do the actual work involved in "fetch" / "cron".
+fetch_run () {
+ fetch_run_pre
+
# Fetch the latest INDEX-NEW and INDEX-OLD files.
fetch_metadata INDEX-NEW INDEX-OLD || return 1
@@ -3023,14 +3035,6 @@
install_from_index INDEX-NEW || return 1
install_delete INDEX-OLD INDEX-NEW || return 1
- # Restart sshd if running (PR263489). Note that this does not
- # affect child sshd processes handling existing sessions.
- if service sshd status >/dev/null 2>/dev/null; then
- echo
- echo "Restarting sshd after upgrade"
- service sshd restart
- fi
-
# Rehash certs if we actually have certctl installed.
if which certctl>/dev/null; then
env DESTDIR=${BASEDIR} certctl rehash
@@ -3371,6 +3375,39 @@
IDS_compare INDEX-ALL INDEX-PRESENT
}
+# Check for available updates
+check_only () {
+ RELPATCHNUM=`cut -f 4 -d '|' < tag.new`
+ RELPX=`uname -r | sed -E 's,.*-,,'`
+ case ${RELPX} in
+ ALPHA* | BETA* | RC*)
+ echo "`basename $0` can not check updates for ALPHA/BETA/RC releases."
+ echo "Those can only be upgraded to a newer release, not patched."
+ exit 1
+ ;;
+ RELEASE)
+ if [ $RELPATCHNUM -ge 1 ]; then
+ echo "There is an update available: $RELNUM-p$RELPATCHNUM"
+ exit 0
+ fi
+ ;;
+ p*)
+ PX=`echo $RELPX | sed 's|p||'`
+ if [ $PX -lt $RELPATCHNUM ]; then
+ echo "There is an update available: $RELNUM-p$RELPATCHNUM"
+ exit 0
+ fi
+ ;;
+ *)
+ echo "`basename $0` can not find reliable updates for `uname -r`"
+ echo "Cowardly refusing to proceed any further."
+ exit 1
+ ;;
+ esac
+ echo "No updates are available."
+ exit 0
+}
+
#### Main functions -- call parameter-handling and core functions
# Using the command line, configuration file, and defaults,
@@ -3393,7 +3430,13 @@
exit 1
fi
fetch_check_params
- fetch_run || exit 1
+ case "$COMMANDS" in
+ check)
+ ;;
+ *)
+ fetch_run || exit 1
+ ;;
+ esac
ISFETCHED=1
}
@@ -3479,6 +3522,20 @@
done
}
+# Check for available updates.
+cmd_check () {
+ case "$COMMANDS" in
+ install|upgrade)
+ ;;
+ *)
+ CHECK_ONLY=1
+ ;;
+ esac
+ finalize_components_config ${COMPONENTS}
+ fetch_check_params
+ fetch_run_pre
+}
+
#### Entry point
# Make sure we find utilities from the base system
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 20, 11:30 AM (21 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15977215
Default Alt Text
D36241.diff (5 KB)
Attached To
Mode
D36241: freebsd-update(8): add new command to 'check' for available updates only
Attached
Detach File
Event Timeline
Log In to Comment