Lines Matching +full:1 +full:- +full:to +full:- +full:1
3 #-
4 # SPDX-License-Identifier: BSD-2-Clause
6 # Copyright 2004-2007 Colin Percival
12 # 1. Redistributions of source code must retain the above copyright
19 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 #### Usage function -- called from command-line handling code.
33 # --debug -- don't filter output from utilities
34 # --no-stats -- don't show progress statistics while fetching files
40 -b basedir -- Operate on a system mounted at basedir
42 -d workdir -- Store working files in workdir
43 (default: /var/db/freebsd-update/)
44 -f conffile -- Read configuration options from conffile
45 (default: /etc/freebsd-update.conf)
46 -F -- Force a fetch operation to proceed in the
48 -j jail -- Operate on the given jail specified by jid or name
49 -k KEY -- Trust an RSA key with SHA256 hash of KEY
50 -r release -- Target for upgrade (e.g., 13.2-RELEASE)
51 -s server -- Server from which to fetch updates
53 -t address -- Mail output of cron command, if any, to address
55 --not-running-from-cron
56 -- Run without a tty, for use by automated tools
57 --currently-running release
58 -- Update as if currently running this release
60 fetch -- Fetch updates from server
61 cron -- Sleep rand(3600) seconds, fetch updates, and send an
63 upgrade -- Fetch upgrades to FreeBSD version specified via -r option
64 updatesready -- Check if there are fetched updates ready to install
65 install -- Install downloaded updates or upgrades
66 rollback -- Uninstall most recently installed updates
67 IDS -- Compare the system against an index of "known good" files
68 showconfig -- Show configuration
75 #-
77 # 1. Command line options
82 # configuration file) they will accumulate. Finally, because the path to the
87 # 1. Initialize CONFFILE and all the options to "".
88 # 2. Process the command line. Throw an error if a non-accumulating option
90 # 3. If CONFFILE is "", set CONFFILE to /etc/freebsd-update.conf .
91 # 4. For all the configuration options X, set X_saved to X.
92 # 5. Initialize all the options to "".
94 # 7. For each configuration option X, set X to X_saved iff X_saved is not "".
95 # 8. Repeat steps 4-7, except setting options to their default values at (6).
102 # Set all the configuration options to "".
109 # For each configuration option X, set X_saved to X.
116 # For each configuration option X, set X to X_saved if X_saved is not "".
120 if ! [ -z "${_}" ]; then
128 if [ -z ${KEYPRINT} ]; then
129 KEYPRINT=$1
131 return 1
137 if [ -z ${WORKDIR} ]; then
138 WORKDIR=$1
140 return 1
144 # Set the name of the server (pool) from which to fetch updates
146 if [ -z ${SERVERNAME} ]; then
147 SERVERNAME=$1
149 return 1
153 # Set the address to which 'cron' output will be mailed.
155 if [ -z ${MAILTO} ]; then
156 MAILTO=$1
158 return 1
162 # Set whether FreeBSD Update is allowed to add files (or directories, or
165 if [ -z ${ALLOWADD} ]; then
166 case $1 in
174 return 1
178 return 1
182 # Set whether FreeBSD Update is allowed to remove files/directories/symlinks.
184 if [ -z ${ALLOWDELETE} ]; then
185 case $1 in
193 return 1
197 return 1
205 if [ -z ${KEEPMODIFIEDMETADATA} ]; then
206 case $1 in
214 return 1
218 return 1
222 # Add to the list of components which should be kept updated.
234 if [ -e "${BASEDIR}/usr/src/COPYRIGHT" ]; then
245 # Add to the list of paths under which updates will be ignored.
252 # Add to the list of paths which IDS should ignore.
259 # Add to the list of paths within which updates will be performed only if the
267 # Add to the list of paths within which updates to text files will be merged
275 # Work on a FreeBSD installation mounted under $1
277 if [ -z ${BASEDIR} ]; then
278 BASEDIR=$1
280 return 1
285 # components listed in COMPONENTS, rather than trying to guess based on
288 if [ -z ${STRICTCOMPONENTS} ]; then
289 case $1 in
297 return 1
301 return 1
305 # Upgrade to FreeBSD $1
307 if [ -z ${TARGETRELEASE} ]; then
308 TARGETRELEASE=$1
310 return 1
312 if echo ${TARGETRELEASE} | grep -qE '^[0-9.]+$'; then
313 TARGETRELEASE="${TARGETRELEASE}-RELEASE"
317 # Pretend current release is FreeBSD $1
319 UNAME_r=$1
320 if echo ${UNAME_r} | grep -qE '^[0-9.]+$'; then
321 UNAME_r="${UNAME_r}-RELEASE"
328 JAIL=$1
329 UNAME_r=$(freebsd-version -j ${JAIL})
330 BASEDIR=$(jls -j ${JAIL} -h path | awk 'NR == 2 {print}')
331 if [ -z ${BASEDIR} ] || [ -z ${UNAME_r} ]; then
333 "does not have freebsd-version."
334 exit 1
339 # Define what happens to output of utilities
341 if [ -z ${VERBOSELEVEL} ]; then
342 case $1 in
353 return 1
357 return 1
362 if [ -z ${BACKUPKERNEL} ]; then
363 case $1 in
371 return 1
375 return 1
380 if [ -z ${BACKUPKERNELDIR} ]; then
381 if [ -z "$1" ]; then
382 echo "BackupKernelDir set to empty dir"
383 return 1
387 # to use, but which could cause a lot of problems if
389 case $1 in
391 echo "BackupKernelDir set to invalid path $1"
392 return 1
395 BACKUPKERNELDIR=$1
398 echo "BackupKernelDir ($1) is not an absolute path"
399 return 1
403 return 1
408 if [ -z ${BACKUPKERNELSYMBOLFILES} ]; then
409 case $1 in
417 return 1
421 return 1
426 if [ -z ${BOOTENV} ]; then
427 case $1 in
435 return 1
439 return 1
444 if [ $# -eq 0 ]; then
448 OPT=$1
455 # Initialize parameters to null, just in case they're
467 # Force fetch to proceed
479 while [ $# -gt 0 ]; do
480 case "$1" in
482 -f)
483 if [ $# -eq 1 ]; then usage; fi
484 if [ ! -z "${CONFFILE}" ]; then usage; fi
485 shift; CONFFILE="$1"
487 -F)
488 FORCEFETCH=1
490 --not-running-from-cron)
491 NOTTYOK=1
493 --currently-running)
495 config_SourceRelease $1 || usage
499 -b)
500 if [ $# -eq 1 ]; then usage; fi; shift
501 config_BaseDir $1 || usage
503 -d)
504 if [ $# -eq 1 ]; then usage; fi; shift
505 config_WorkDir $1 || usage
507 -j)
508 if [ $# -eq 1 ]; then usage; fi; shift
509 config_TargetJail $1 || usage
511 -k)
512 if [ $# -eq 1 ]; then usage; fi; shift
513 config_KeyPrint $1 || usage
515 -r)
516 if [ $# -eq 1 ]; then usage; fi; shift
517 config_TargetRelease $1 || usage
519 -s)
520 if [ $# -eq 1 ]; then usage; fi; shift
521 config_ServerName $1 || usage
523 -t)
524 if [ $# -eq 1 ]; then usage; fi; shift
525 config_MailTo $1 || usage
527 -v)
528 if [ $# -eq 1 ]; then usage; fi; shift
529 config_VerboseLevel $1 || usage
532 # Aliases for "-v debug" and "-v nostats"
533 --debug)
536 --no-stats)
543 COMMANDS="${COMMANDS} $1"
555 if [ -z "${COMMANDS}" ]; then
564 if [ ! -z "${CONFFILE}" ] && [ ! -r "${CONFFILE}" ]; then
565 echo -n "File does not exist "
566 echo -n "or is not readable: "
568 exit 1
574 if [ -z "${CONFFILE}" ]; then
575 CONFFILE="/etc/freebsd-update.conf"
576 if [ ! -r "${CONFFILE}" ]; then
590 L=$(($L + 1))
591 LINEX=`echo "${LINE}" | cut -f 1 -d '#'`
595 exit 1
611 config_WorkDir /var/db/freebsd-update
624 # Merge these defaults into the earlier-configured settings
636 XARGST="-t"
649 QUIETFLAG="-q"
653 NDEBUG="-n"
660 # packages) might need necessary for the modules to work in the new release.
670 if ! pkg -N 2>/dev/null; then
676 # in every module_path passed to the kernel:
677 pattern=$(sysctl -n kern.module_path | tr ";" "|")
679 if [ -z "${pattern}" ]; then
686 modules=$(pkg query '%Fp' | grep -E "${pattern}")
688 if [ -z "${modules}" ]; then
692 echo -e "\n"
695 echo -e "It is advised to rebuild these ports:\n"
698 report="Module Package Port\n------ ------- ----\n"
701 mod_name=$(echo "${w}" | awk '{print $1;}')
703 port_name=$(pkg info -o "${pkg_name}" | awk '{print $2;}')
707 echo -e "${report}" | column -t
708 echo -e "\n"
714 # running *-p[0-9]+, strip off the last part; if the
715 # user is running -SECURITY, call it -RELEASE. Chdir
718 export HTTP_USER_AGENT="freebsd-update (${COMMAND}, `uname -r`)"
722 _KEYPRINT_z="Key must be given via -k option or configuration file."
727 if [ -z "${SERVERNAME}" ]; then
728 echo -n "`basename $0`: "
730 exit 1
732 if [ -z "${KEYPRINT}" ]; then
733 echo -n "`basename $0`: "
735 exit 1
737 if ! echo "${KEYPRINT}" | grep -qE "^[0-9a-f]{64}$"; then
738 echo -n "`basename $0`: "
739 echo -n "${_KEYPRINT_bad}"
741 exit 1
743 if ! [ -d "${WORKDIR}" -a -w "${WORKDIR}" ]; then
744 echo -n "`basename $0`: "
745 echo -n "${_WORKDIR_bad}"
747 exit 1
749 case `df -T ${WORKDIR}` in */dev/md[0-9]* | *tmpfs*)
750 echo -n "`basename $0`: "
751 echo -n "${_WORKDIR_bad2}"
753 exit 1
757 cd ${WORKDIR} || exit 1
760 # to provide an upgrade path for FreeBSD Update 1.x users, since
761 # the kernels provided by FreeBSD Update 1.x are always labelled
762 # as X.Y-SECURITY.
763 RELNUM=`uname -r |
764 sed -E 's,-p[0-9]+,,' |
765 sed -E 's,-SECURITY,-RELEASE,'`
766 ARCH=`uname -m`
772 *-RELEASE | *-ALPHA* | *-BETA* | *-RC*)
775 echo -n "`basename $0`: "
776 cat <<- EOF
780 upgraded by source or upgraded to a RELEASE/RELENG version
781 prior to running `basename $0`.
784 exit 1
789 BOOTFILE=`sysctl -n kern.bootfile`
791 if ! [ -d ${KERNELDIR} ]; then
793 exit 1
797 # the output of `uname -i`, and then make the following adjustments:
798 # 1. Replace "SMP-GENERIC" with "SMP". Why the SMP kernel config
799 # file says "ident SMP-GENERIC", I don't know...
800 # 2. If the kernel claims to be GENERIC _and_ ${ARCH} is "amd64"
802 # we're running an SMP kernel. This mis-identification is a bug
803 # which was fixed in 6.2-STABLE.
804 KERNCONF=`uname -i`
805 if [ ${KERNCONF} = "SMP-GENERIC" ]; then
809 if sysctl kern.version | grep -qE '/SMP$'; then
819 # Set up variables relating to VERBOSELEVEL
823 BDHASH=`echo ${BASEDIR} | sha256 -q`
830 if ! [ -z "${TARGETRELEASE}" ]; then
831 echo -n "`basename $0`: "
832 echo -n "'-r' option is meaningless with 'fetch' command. "
834 exit 1
837 # Check that we have updates ready to install
838 if [ -f ${BDHASH}-install/kerneldone -a $FORCEFETCH -eq 0 ]; then
841 echo "Run '`basename $0` [options] fetch -F' to proceed anyway."
842 exit 1
850 # Unless set otherwise, we're upgrading to the same kernel config.
854 _TARGETRELEASE_z="Release target must be specified via '-r' option."
855 if [ -z "${TARGETRELEASE}" ]; then
856 echo -n "`basename $0`: "
858 exit 1
863 echo -n "`basename $0`: "
864 echo "Cannot upgrade from ${RELNUM} to itself"
865 exit 1
870 echo -n "`basename $0`: "
871 echo -n "WARNING: \"AllowAdd no\" is a bad idea "
876 echo -n "`basename $0`: "
877 echo -n "WARNING: \"AllowDelete no\" is a bad idea "
882 # Set EDITOR to /usr/bin/vi if it isn't already set
890 if [ `id -u` != 0 ]; then
891 echo "You must be root to run this."
892 exit 1
896 if [ `sysctl -n kern.securelevel` -gt 0 ]; then
899 exit 1
904 if ! [ -d "${WORKDIR}" -a -w "${WORKDIR}" ]; then
905 echo -n "`basename $0`: "
906 echo -n "${_WORKDIR_bad}"
908 exit 1
910 cd ${WORKDIR} || exit 1
913 BDHASH=`echo ${BASEDIR} | sha256 -q`
915 # Check that we have updates ready to install
916 if ! [ -L ${BDHASH}-install ]; then
917 echo "No updates are available to install."
918 if [ $ISFETCHED -eq 0 ]; then
924 if ! [ -f ${BDHASH}-install/INDEX-OLD ] ||
925 ! [ -f ${BDHASH}-install/INDEX-NEW ]; then
926 echo "Update manifest is corrupt -- this should never happen."
927 echo "Re-run '`basename $0` [options] fetch'."
928 exit 1
932 BOOTFILE=`sysctl -n kern.bootfile`
934 if ! [ -d ${KERNELDIR} ]; then
936 exit 1
943 if [ `sysctl -n security.jail.jailed` = 1 ]; then
944 return 1
949 return 1
969 echo -n "Creating snapshot of existing boot environment... "
970 VERSION=`freebsd-version -ku | sort -V | tail -n 1`
971 TIMESTAMP=`date +"%Y-%m-%d_%H%M%S"`
972 bectl create -r ${VERSION}_${TIMESTAMP}
973 if [ $? -eq 0 ]; then
977 exit 1
987 if [ `id -u` != 0 ]; then
988 echo "You must be root to run this."
989 exit 1
994 if ! [ -d "${WORKDIR}" -a -w "${WORKDIR}" ]; then
995 echo -n "`basename $0`: "
996 echo -n "${_WORKDIR_bad}"
998 exit 1
1000 cd ${WORKDIR} || exit 1
1003 BDHASH=`echo ${BASEDIR} | sha256 -q`
1005 # Check that we have updates ready to rollback
1006 if ! [ -L ${BDHASH}-rollback ]; then
1008 exit 1
1010 if ! [ -f ${BDHASH}-rollback/INDEX-OLD ] ||
1011 ! [ -f ${BDHASH}-rollback/INDEX-NEW ]; then
1012 echo "Update manifest is corrupt -- this should never happen."
1013 exit 1
1020 # compare against: If the user is running *-p[0-9]+,
1022 # -SECURITY, call it -RELEASE. Chdir into the working
1025 export HTTP_USER_AGENT="freebsd-update (${COMMAND}, `uname -r`)"
1029 _KEYPRINT_z="Key must be given via '-k' option or configuration file."
1033 if [ -z "${SERVERNAME}" ]; then
1034 echo -n "`basename $0`: "
1036 exit 1
1038 if [ -z "${KEYPRINT}" ]; then
1039 echo -n "`basename $0`: "
1041 exit 1
1043 if ! echo "${KEYPRINT}" | grep -qE "^[0-9a-f]{64}$"; then
1044 echo -n "`basename $0`: "
1045 echo -n "${_KEYPRINT_bad}"
1047 exit 1
1049 if ! [ -d "${WORKDIR}" -a -w "${WORKDIR}" ]; then
1050 echo -n "`basename $0`: "
1051 echo -n "${_WORKDIR_bad}"
1053 exit 1
1055 cd ${WORKDIR} || exit 1
1058 # to provide an upgrade path for FreeBSD Update 1.x users, since
1059 # the kernels provided by FreeBSD Update 1.x are always labelled
1060 # as X.Y-SECURITY.
1061 RELNUM=`uname -r |
1062 sed -E 's,-p[0-9]+,,' |
1063 sed -E 's,-SECURITY,-RELEASE,'`
1064 ARCH=`uname -m`
1069 BOOTFILE=`sysctl -n kern.bootfile`
1071 if ! [ -d ${KERNELDIR} ]; then
1073 exit 1
1077 # the output of `uname -i`, and then make the following adjustments:
1078 # 1. Replace "SMP-GENERIC" with "SMP". Why the SMP kernel config
1079 # file says "ident SMP-GENERIC", I don't know...
1080 # 2. If the kernel claims to be GENERIC _and_ ${ARCH} is "amd64"
1082 # we're running an SMP kernel. This mis-identification is a bug
1083 # which was fixed in 6.2-STABLE.
1084 KERNCONF=`uname -i`
1085 if [ ${KERNCONF} = "SMP-GENERIC" ]; then
1089 if sysctl kern.version | grep -qE '/SMP$'; then
1098 # Set up variables relating to VERBOSELEVEL
1102 # Return 0 if the system is managed using pkgbase, 1 otherwise.
1106 if ! pkg -N -r ${BASEDIR} >/dev/null 2>/dev/null; then
1107 return 1
1109 # uname(1) is used by pkg to determine ABI, so it should exist.
1111 if ! pkg -r ${BASEDIR} which /usr/bin/uname >/dev/null; then
1112 return 1
1117 #### Core functionality -- the actual work gets done here
1119 # Use an SRV query to pick a server. If the SRV query doesn't provide
1123 # This allows a user to specify "update.FreeBSD.org" (in which case
1124 # freebsd-update will select one of the mirrors) or "update1.freebsd.org"
1125 # (in which case freebsd-update will use that particular server, since
1128 # We ignore the Port field, since we are always going to use port 80.
1130 # Fetch the mirror list, but do not pick a mirror yet. Returns 1 if
1135 # Check that host(1) exists (i.e., that the system wasn't built with the
1136 # WITHOUT_BIND set) and don't try to find a mirror if it doesn't exist.
1137 if ! which -s host; then
1139 return 1
1142 echo -n "Looking up ${SERVERNAME} mirrors... "
1148 host -t srv "${MLIST}" |
1149 sed -nE "s/${MLIST} (has SRV record|server selection) //Ip" |
1150 cut -f 1,2,4 -d ' ' |
1151 sed -e 's/\.$//' |
1154 # If no records, give up -- we'll just use the server name we were given.
1155 if [ `wc -l < serverlist_full` -eq 0 ]; then
1157 return 1
1161 echo `wc -l < serverlist_full` "mirrors found."
1164 # is set, this will be used to generate the seed; otherwise, the seed
1166 if [ -n "${HTTP_PROXY}${http_proxy}" ]; then
1167 RANDVALUE=`sha256 -qs "${HTTP_PROXY}${http_proxy}" |
1168 tr -d 'a-f' |
1169 cut -c 1-9`
1171 RANDVALUE=`jot -r 1 0 999999999`
1175 # Pick a mirror. Returns 1 if we have run out of mirrors to try.
1177 # Generate a list of not-yet-tried mirrors
1179 comm -23 serverlist_full - > serverlist
1182 if [ `wc -l < serverlist` -eq 0 ]; then
1183 cat <<- EOF
1188 platforms with Tier 1 support can be upgraded by `basename $0`.
1193 return 1
1197 SRV_PRIORITY=`cut -f 1 -d ' ' serverlist | sort -n | head -1`
1204 SRV_W=`echo $X | cut -f 2 -d ' '`
1210 # If all the weights are 0, pretend that they are all 1 instead.
1211 if [ ${SRV_WSUM} -eq 0 ]; then
1212 SRV_WSUM=`grep -E "^${SRV_PRIORITY} " serverlist | wc -l`
1213 SRV_W_ADD=1
1218 # Pick a value between 0 and the sum of the weights - 1
1222 # corresponding to the mirror we selected into serverlist_tried so that
1227 SRV_W=`echo $X | cut -f 2 -d ' '`
1229 if [ $SRV_RND -lt $SRV_W ]; then
1230 SERVERNAME=`echo $X | cut -f 3 -d ' '`
1234 SRV_RND=$(($SRV_RND - $SRV_W))
1244 grep -vE "^([0-9a-f]{64})\|\1$" |
1247 if [ -f "files/${Y}.gz" ] ||
1248 [ ! -f "files/${X}.gz" ]; then
1252 done | sort -u
1255 # Print user-friendly progress statistics
1259 LNC=$(($LNC + 1))
1261 echo -n $LNC
1263 echo -n .
1266 echo -n " "
1271 while read -p "Does this look reasonable (y/n)? " CONTINUE; do
1277 return 1
1285 mkdir -p files
1290 # fetch the key if it doesn't exist. Returns 1 if the key has
1293 if [ -r pub.ssl ] && [ `${SHA256} -q pub.ssl` = ${KEYPRINT} ]; then
1297 echo -n "Fetching public key from ${SERVERNAME}... "
1298 rm -f pub.ssl
1301 if ! [ -r pub.ssl ]; then
1303 return 1
1305 if ! [ `${SHA256} -q pub.ssl` = ${KEYPRINT} ]; then
1307 rm -f pub.ssl
1308 return 1
1315 echo -n "Fetching metadata signature "
1317 rm -f latest.ssl
1320 if ! [ -r latest.ssl ]; then
1322 return 1
1325 openssl pkeyutl -pubin -inkey pub.ssl -verifyrecover \
1329 if ! [ `wc -l < tag.new` = 1 ] ||
1330 ! grep -qE \
1331 "^freebsd-update\|${ARCH}\|${RELNUM}\|[0-9]+\|[0-9a-f]{64}\|[0-9]{10}" \
1334 return 1
1339 RELPATCHNUM=`cut -f 4 -d '|' < tag.new`
1340 TINDEXHASH=`cut -f 5 -d '|' < tag.new`
1341 EOLTIME=`cut -f 6 -d '|' < tag.new`
1344 # Sanity-check the patch number in a tag, to make sure that we're not
1345 # going to "update" backwards and to prevent replay attacks.
1347 # Check that we're not going to move from -pX to -pY with Y < X.
1348 RELPX=`uname -r | sed -E 's,.*-,,'`
1349 if echo ${RELPX} | grep -qE '^p[0-9]+$'; then
1350 RELPX=`echo ${RELPX} | cut -c 2-`
1354 if [ "${RELPATCHNUM}" -lt "${RELPX}" ]; then
1356 echo -n "Files on mirror (${RELNUM}-p${RELPATCHNUM})"
1358 echo "we are currently running (`uname -r`)!"
1359 echo "Cowardly refusing to proceed any further."
1360 return 1
1363 # If "tag" exists and corresponds to ${RELNUM}, make sure that
1364 # it contains a patch number <= RELPATCHNUM, in order to protect
1366 if [ -f tag ] &&
1367 grep -qE \
1368 "^freebsd-update\|${ARCH}\|${RELNUM}\|[0-9]+\|[0-9a-f]{64}\|[0-9]{10}" \
1370 LASTRELPATCHNUM=`cut -f 4 -d '|' < tag`
1372 if [ "${RELPATCHNUM}" -lt "${LASTRELPATCHNUM}" ]; then
1374 echo -n "Files on mirror (${RELNUM}-p${RELPATCHNUM})"
1376 echo -n "most recently seen updates"
1377 echo " (${RELNUM}-p${LASTRELPATCHNUM})."
1378 echo "Cowardly refusing to proceed any further."
1379 return 1
1387 rm -f ${TINDEXHASH}
1390 if ! [ -f ${TINDEXHASH} ]; then
1392 return 1
1394 if [ `${SHA256} -q ${TINDEXHASH}` != ${TINDEXHASH} ]; then
1396 return 1
1404 echo "The update metadata$1 is correctly signed, but"
1406 echo "Cowardly refusing to proceed any further."
1407 return 1
1410 # Construct tINDEX.new by merging the lines named in $1 from ${TINDEXHASH}
1414 if [ `grep -E "^${METAFILE}\|" ${TINDEXHASH} | wc -l` \
1415 -ne 1 ]; then
1417 return 1
1420 grep -E "${METAFILE}\|" ${TINDEXHASH}
1424 if [ -f tINDEX.present ]; then
1425 join -t '|' -v 2 tINDEX.wanted tINDEX.present |
1426 sort -m - tINDEX.wanted > tINDEX.new
1438 if grep -qvE '^[0-9A-Z.-]+\|[0-9a-f]{64}$' tINDEX.new; then
1440 return 1
1444 # Sanity check the metadata file $1.
1446 # Some aliases to save space later: ${P} is a character which can
1449 P="[-+./:=,%@_[~[:alnum:]]"
1450 M="[0-9]+\|[0-9]+\|[0-9]+\|[0-9]+"
1451 H="[0-9a-f]{64}"
1454 if gunzip -c < files/$1.gz |
1455 grep -qvE "^[a-z]+\|[0-9a-z-]+\|${P}+\|[fdL-]\|"; then
1457 return 1
1461 gunzip -c < files/$1.gz |
1462 cut -f 4- -d '|' > sanitycheck.tmp
1465 if grep -E '^f' sanitycheck.tmp |
1466 grep -qvE "^f\|${M}\|${H}\|${P}*\$"; then
1468 return 1
1472 if grep -E '^d' sanitycheck.tmp |
1473 grep -qvE "^d\|${M}\|\|\$"; then
1475 return 1
1479 if grep -E '^L' sanitycheck.tmp |
1480 grep -qvE "^L\|${M}\|${P}*\|\$"; then
1482 return 1
1485 # Sanity check entries with type '-'
1486 if grep -E '^-' sanitycheck.tmp |
1487 grep -qvE "^-\|\|\|\|\|\|"; then
1489 return 1
1499 fetch_metadata_index || return 1
1500 fetch_metadata_index_merge $@ || return 1
1501 fetch_metadata_index_sanity || return 1
1504 join -t '|' -o 1.2,2.2 tINDEX.present tINDEX.new |
1507 if [ -s patchlist ]; then
1508 # Attempt to fetch metadata patches
1509 echo -n "Fetching `wc -l < patchlist | tr -d ' '` "
1511 tr '|' '-' < patchlist |
1512 lam -s "${FETCHDIR}/tp/" - -s ".gz" |
1517 # Attempt to apply metadata patches
1518 echo -n "Applying metadata patches... "
1521 if [ ! -f "${X}-${Y}.gz" ]; then continue; fi
1522 gunzip -c < ${X}-${Y}.gz > diff
1523 gunzip -c < files/${X}.gz > diff-OLD
1526 grep -E '^-' diff |
1527 cut -c 2- |
1529 look "${PREFIX}" diff-OLD
1531 sort > diff-rm
1532 grep -E '^\+' diff |
1533 cut -c 2- > diff-add
1536 comm -23 diff-OLD diff-rm |
1537 sort - diff-add > diff-NEW
1539 if [ `${SHA256} -q diff-NEW` = ${Y} ]; then
1540 mv diff-NEW files/${Y}
1541 gzip -n files/${Y}
1543 mv diff-NEW ${Y}.bad
1545 rm -f ${X}-${Y}.gz diff
1546 rm -f diff-OLD diff-NEW diff-add diff-rm
1552 cut -f 2 -d '|' < tINDEX.new |
1554 if [ ! -f "files/${Y}.gz" ]; then
1558 sort -u > filelist
1560 if [ -s filelist ]; then
1561 echo -n "Fetching `wc -l < filelist | tr -d ' '` "
1563 lam -s "${FETCHDIR}/m/" - -s ".gz" < filelist |
1568 if ! [ -f ${Y}.gz ]; then
1570 return 1
1572 if [ `gunzip -c < ${Y}.gz |
1573 ${SHA256} -q` = ${Y} ]; then
1577 return 1
1583 # Sanity-check the metadata files.
1584 cut -f 2 -d '|' tINDEX.new > filelist
1586 fetch_metadata_sanity ${X} || return 1
1590 cut -f 2 -d '|' tINDEX.present |
1592 cut -f 2 -d '|' tINDEX.new |
1594 comm -13 - oldfiles |
1595 lam -s "files/" - -s ".gz" |
1596 xargs rm -f
1610 METAHASH=`look "$1|" tINDEX.present | cut -f 2 -d '|'`
1611 gunzip -c < files/${METAHASH}.gz > $1.all
1613 # Fish out the lines belonging to components we care about.
1615 look "`echo ${C} | tr '/' '|'`|" $1.all
1616 done > $1
1619 rm $1.all
1622 # Generate a filtered version of the metadata file $1 from the downloaded
1623 # file, by fishing out the lines corresponding to components we're trying
1624 # to keep updated, and then removing lines corresponding to paths we want
1625 # to ignore.
1627 # Fish out the lines belonging to components we care about.
1628 fetch_filter_metadata_components $1
1631 # order to avoid listing directories multiple times if they
1632 # belong to multiple components. Turning "/" into "" doesn't
1634 cut -f 3- -d '|' $1 |
1635 sed -e 's,/|d|,|d|,' |
1636 sed -e 's,/|-|,|-|,' |
1637 sort -u > $1.tmp
1639 # Figure out which lines to ignore and remove them.
1641 grep -E "^${X}" $1.tmp
1643 sort -u |
1644 comm -13 - $1.tmp > $1
1647 rm $1.tmp
1650 # Filter the metadata file $1 by adding lines with "/boot/$2"
1651 # replaced by ${KERNELDIR} (which is `sysctl -n kern.bootfile` minus the
1657 grep ^/boot/$2 $1 |
1658 sed -e "s,/boot/$2,${KERNELDIR},g" |
1659 sort - $1 > $1.tmp
1660 mv $1.tmp $1
1662 if ! [ -d /boot/$2 ]; then
1663 grep -v ^/boot/$2 $1 > $1.tmp
1664 mv $1.tmp $1
1668 # For all paths appearing in $1 or $3, inspect the system
1672 rm -f .err
1675 echo -n "Inspecting system... "
1677 # Generate list of files to inspect
1678 cat $1 $3 |
1679 cut -f 1 -d '|' |
1680 sort -u > filelist
1683 # /path/to/file|type|device-inum|user|group|perm|flags|value
1687 if ! [ -e ${BASEDIR}/${F} ]; then
1688 echo "${F}|-||||||"
1691 if ! [ -r ${BASEDIR}/${F} ]; then
1695 return 1
1699 if [ -L ${BASEDIR}/${F} ]; then
1700 echo -n "${F}|L|"
1701 stat -n -f '%d-%i|%u|%g|%Mp%Lp|%Of|' ${BASEDIR}/${F};
1703 elif [ -f ${BASEDIR}/${F} ]; then
1704 echo -n "${F}|f|"
1705 stat -n -f '%d-%i|%u|%g|%Mp%Lp|%Of|' ${BASEDIR}/${F};
1706 sha256 -q ${BASEDIR}/${F};
1707 elif [ -d ${BASEDIR}/${F} ]; then
1708 echo -n "${F}|d|"
1709 stat -f '%d-%i|%u|%g|%Mp%Lp|%Of|' ${BASEDIR}/${F};
1714 return 1
1717 sort -k 3,3 -t '|' > $2.tmp
1721 if [ -f .err ]; then
1722 return 1
1725 # Convert to the form
1726 # /path/to/file|type|user|group|perm|flags|value|hlink
1728 cut -f 1,3 -d '|' $2.tmp |
1729 sort -k 1,1 -t '|' |
1730 sort -s -u -k 2,2 -t '|' |
1731 join -1 2 -2 3 -t '|' - $2.tmp |
1732 awk -F \| -v OFS=\| \
1734 if (($2 == $3) || ($4 == "-"))
1746 # For any paths matching ${MERGECHANGES}, compare $2 against $1 and $3 and
1747 # find any files with values unique to $2; generate $4 containing these paths
1748 # and their corresponding hashes from $1.
1751 for F in $1 $2 $3; do
1753 grep -E "^${X}" ${F}
1755 cut -f 1,2,7 -d '|' |
1756 sort > ${F}-values
1759 # Any line in $2-values which doesn't appear in $1-values or $3-values
1761 sort $1-values $3-values |
1762 comm -13 - $2-values |
1764 cut -f 1 -d '|' > $2-paths
1766 # For each path, pull out one (and only one!) entry from $1-values.
1768 # changes to; but hopefully any changes which occur due to security
1772 look "${X}|" $1-values |
1773 head -1
1774 done < $2-paths > $4
1777 rm $1-values $2-values $3-values $2-paths
1781 # which correspond to lines in $2 with hashes not matching $1 or $3, unless
1783 # (aka. type -), remove lines from $[123] unless there is a corresponding
1784 # entry in $1.
1786 # Figure out which lines of $1 and $3 correspond to bits which
1789 # NOTE: We don't consider a file to be "modified" if it matches
1792 grep -E "^${X}" $1
1793 grep -E "^${X}" $3
1795 cut -f 1,2,7 -d '|' |
1796 sort > $1-values
1800 grep -E "^${X}" $2
1802 cut -f 1,2,7 -d '|' |
1803 sort > $2-values
1805 # Any entry in $2-values which is not in $1-values corresponds to
1806 # a path which we need to remove from $1, $2, and $3, unless it
1808 comm -13 $1-values $2-values |
1809 sort -t '|' -k 1,1 > mlines.tmp
1810 cut -f 1 -d '|' $4 |
1812 join -v 2 -t '|' - mlines.tmp |
1814 rm $1-values $2-values mlines.tmp
1816 # Any lines in $2 which are not in $1 AND are "not present" lines
1818 comm -13 $1 $2 |
1819 cut -f 1,2,7 -d '|' |
1820 fgrep '|-|' >> mlines
1822 # Remove lines from $1, $2, and $3
1823 for X in $1 $2 $3; do
1824 sort -t '|' -k 1,1 ${X} > ${X}.tmp
1825 cut -f 1 -d '|' < mlines |
1827 join -v 2 -t '|' - ${X}.tmp |
1833 fgrep -v '|-|' mlines |
1834 cut -f 1 -d '|' > modifiedfiles
1838 # For each entry in $1 of type -, remove any corresponding
1840 # of type - from $1.
1842 cut -f 1,2 -d '|' < $1 |
1843 fgrep '|-' |
1844 cut -f 1 -d '|' > filesnotpresent
1848 join -v 1 -t '|' - filesnotpresent |
1853 sort < $1 |
1854 join -v 1 -t '|' - filesnotpresent |
1855 sort > $1.tmp
1856 mv $1.tmp $1
1860 # If ${ALLOWDELETE} != "yes", then remove any entries from $1
1861 # which don't correspond to entries in $2.
1864 for X in $1 $2; do
1865 cut -f 1-2 -d '|' < ${X} |
1866 sort -u > ${X}.nodes
1869 # Figure out which lines need to be removed from $1.
1871 comm -23 $1.nodes $2.nodes > $1.badnodes
1873 : > $1.badnodes
1876 # Remove the relevant lines from $1
1878 look "${X}|" $1
1879 done < $1.badnodes |
1880 comm -13 - $1 > $1.tmp
1881 mv $1.tmp $1
1883 rm $1.badnodes $1.nodes $2.nodes
1887 # with metadata not matching any entry in $1, replace the corresponding
1890 # Fish out the metadata from $1 and $2
1891 for X in $1 $2; do
1892 cut -f 1-6 -d '|' < ${X} > ${X}.metadata
1895 # Find the metadata we need to keep
1897 comm -13 $1.metadata $2.metadata > keepmeta
1902 # Extract the lines which we need to remove from $3, and
1903 # construct the lines which we need to add to $3.
1907 NODE=`echo "${LINE}" | cut -f 1-2 -d '|'`
1910 cut -f 7- -d '|' |
1911 lam -s "${LINE}|" - >> $3.add
1916 comm -13 - $3 |
1917 sort -u - $3.add > $3.tmp
1920 rm keepmeta $1.metadata $2.metadata $3.add $3.remove
1923 # Remove lines from $1 and $2 which are identical;
1924 # no need to update a file if it isn't changing.
1926 comm -23 $1 $2 > $1.tmp
1927 comm -13 $1 $2 > $2.tmp
1929 mv $1.tmp $1
1935 # We only need to do anything if $1 is non-empty.
1936 if [ -s $1 ]; then
1938 echo -n "Fetching files from ${OLDRELNUM} for merging... "
1941 fgrep '|f|' < $1 |
1942 cut -f 3 -d '|' |
1943 sort -u > files.wanted
1947 if [ ! -f "files/${Y}.gz" ]; then
1953 lam -s "${OLDFETCHDIR}/f/" - -s ".gz" < filelist |
1959 if ! [ -f ${Y}.gz ]; then
1961 return 1
1963 if [ `gunzip -c < ${Y}.gz |
1964 ${SHA256} -q` = ${Y} ]; then
1968 return 1
1978 # Prepare to fetch files: Generate a list of the files we need,
1980 # a list of patches to download.
1983 echo -n "Preparing to download files... "
1985 # Reduce indices to ${PATH}|${HASH} pairs
1986 for X in $1 $2 $3; do
1987 cut -f 1,2,7 -d '|' < ${X} |
1989 cut -f 1,3 -d '|' |
1994 cut -f 2 -d '|' < $3.hashes |
1995 sort -u |
1997 if ! [ -f files/${HASH}.gz ]; then
2003 comm -12 $1.hashes $2.hashes |
2004 sort -k 1,1 -t '|' > unmodified.files
2008 # to rollback the updates later.
2010 F=`echo "${LINE}" | cut -f 1 -d '|'`
2011 HASH=`echo "${LINE}" | cut -f 2 -d '|'`
2014 if [ -f files/${HASH}.gz ]; then
2020 if [ `sha256 -q tmpfile` != ${HASH} ]; then
2023 return 1
2027 gzip -c < tmpfile > files/${HASH}.gz
2031 # Produce a list of patches to download
2032 sort -k 1,1 -t '|' $3.hashes |
2033 join -t '|' -o 2.2,1.2 - unmodified.files |
2037 rm unmodified.files $1.hashes $2.hashes $3.hashes
2040 rm $1
2048 # Attempt to fetch patches
2049 if [ -s patchlist ]; then
2050 echo -n "Fetching `wc -l < patchlist | tr -d ' '` "
2052 tr '|' '-' < patchlist |
2053 lam -s "${PATCHDIR}/" - |
2058 # Attempt to apply patches
2059 echo -n "Applying patches... "
2062 if [ ! -f "${X}-${Y}" ]; then continue; fi
2063 gunzip -c < files/${X}.gz > OLD
2065 bspatch OLD NEW ${X}-${Y}
2067 if [ `${SHA256} -q NEW` = ${Y} ]; then
2069 gzip -n files/${Y}
2071 rm -f diff OLD NEW ${X}-${Y}
2078 if [ ! -f "files/${Y}.gz" ]; then
2083 if [ -s filelist ]; then
2084 echo -n "Fetching `wc -l < filelist | tr -d ' '` "
2086 lam -s "${FETCHDIR}/f/" - -s ".gz" < filelist |
2091 if ! [ -f ${Y}.gz ]; then
2093 return 1
2095 if [ `gunzip -c < ${Y}.gz |
2096 ${SHA256} -q` = ${Y} ]; then
2100 return 1
2114 if [ -L "${BDHASH}-install" ]; then
2115 rm -r ${BDHASH}-install/
2116 rm ${BDHASH}-install
2119 # Report to the user if any updates were avoided due to local changes
2120 if [ -s modifiedfiles ]; then
2121 cat - modifiedfiles <<- EOF | ${PAGER}
2130 if ! [ -s INDEX-PRESENT ] &&
2131 ! [ -s INDEX-NEW ]; then
2132 rm INDEX-PRESENT INDEX-NEW
2134 echo -n "No updates needed to update system to "
2135 echo "${RELNUM}-p${RELPATCHNUM}."
2141 cut -f 1 -d '|' < INDEX-PRESENT |
2142 sort > INDEX-PRESENT.flist
2143 cut -f 1 -d '|' < INDEX-NEW |
2144 sort > INDEX-NEW.flist
2145 comm -23 INDEX-PRESENT.flist INDEX-NEW.flist > files.removed
2146 comm -13 INDEX-PRESENT.flist INDEX-NEW.flist > files.added
2147 comm -12 INDEX-PRESENT.flist INDEX-NEW.flist > files.updated
2148 rm INDEX-PRESENT.flist INDEX-NEW.flist
2151 if [ -s files.removed ]; then
2152 cat - files.removed <<- EOF | ${PAGER}
2153 The following files will be removed as part of updating to
2154 ${RELNUM}-p${RELPATCHNUM}:
2160 if [ -s files.added ]; then
2161 cat - files.added <<- EOF | ${PAGER}
2162 The following files will be added as part of updating to
2163 ${RELNUM}-p${RELPATCHNUM}:
2169 if [ -s files.updated ]; then
2170 cat - files.updated <<- EOF | ${PAGER}
2171 The following files will be updated as part of updating to
2172 ${RELNUM}-p${RELPATCHNUM}:
2178 MDIR=`mktemp -d install.XXXXXX` || return 1
2181 mv INDEX-PRESENT ${MDIR}/INDEX-OLD
2182 mv INDEX-NEW ${MDIR}/INDEX-NEW
2185 ln -s ${MDIR} ${BDHASH}-install
2194 if [ -f lasteolwarn ]; then
2197 LASTWARN=`expr ${NOWTIME} - 63072000`
2201 if [ ${EOLTIME} -lt ${NOWTIME} ]; then
2203 cat <<-EOF
2204 WARNING: `uname -sr` HAS PASSED ITS END-OF-LIFE DATE.
2205 Any security issues discovered after `date -r ${EOLTIME}`
2208 return 1
2213 SINCEWARN=`expr ${NOWTIME} - ${LASTWARN}`
2214 TIMELEFT=`expr ${EOLTIME} - ${NOWTIME}`
2217 if [ ${TIMELEFT} -gt 7884000 ]; then
2223 if [ ${TIMELEFT} -gt `expr ${SINCEWARN} \* 3` ]; then
2227 # Figure out what time units to use.
2228 if [ ${TIMELEFT} -lt 604800 ]; then
2231 elif [ ${TIMELEFT} -lt 2678400 ]; then
2241 if [ ${NUM} != 1 ]; then
2247 cat <<-EOF
2248 WARNING: `uname -sr` is approaching its End-of-Life date.
2249 It is strongly recommended that you upgrade to a newer
2259 workdir_init || return 1
2264 # Try to fetch the public key until we run out of servers.
2266 fetch_pick_server || return 1
2269 # Try to fetch the metadata index signature ("tag") until we run
2272 fetch_pick_server || return 1
2274 fetch_tagsanity || return 1
2276 # Fetch the latest INDEX-NEW and INDEX-OLD files.
2277 fetch_metadata INDEX-NEW INDEX-OLD || return 1
2279 # Generate filtered INDEX-NEW and INDEX-OLD files containing only
2280 # the lines which (a) belong to components we care about, and (b)
2281 # don't correspond to paths we're explicitly ignoring.
2282 fetch_filter_metadata INDEX-NEW || return 1
2283 fetch_filter_metadata INDEX-OLD || return 1
2286 fetch_filter_kernel_names INDEX-NEW ${KERNCONF}
2287 fetch_filter_kernel_names INDEX-OLD ${KERNCONF}
2289 # For all paths appearing in INDEX-OLD or INDEX-NEW, inspect the
2290 # system and generate an INDEX-PRESENT file.
2291 fetch_inspect_system INDEX-OLD INDEX-PRESENT INDEX-NEW || return 1
2293 # Based on ${UPDATEIFUNMODIFIED}, remove lines from INDEX-* which
2294 # correspond to lines in INDEX-PRESENT with hashes not appearing
2295 # in INDEX-OLD or INDEX-NEW. Also remove lines where the entry in
2296 # INDEX-PRESENT has type - and there isn't a corresponding entry in
2297 # INDEX-OLD with type -.
2299 INDEX-OLD INDEX-PRESENT INDEX-NEW /dev/null
2301 # For each entry in INDEX-PRESENT of type -, remove any corresponding
2302 # entry from INDEX-NEW if ${ALLOWADD} != "yes". Remove all entries
2303 # of type - from INDEX-PRESENT.
2304 fetch_filter_allowadd INDEX-PRESENT INDEX-NEW
2307 # INDEX-PRESENT which don't correspond to entries in INDEX-NEW.
2308 fetch_filter_allowdelete INDEX-PRESENT INDEX-NEW
2311 # INDEX-PRESENT with metadata not matching any entry in INDEX-OLD,
2312 # replace the corresponding line of INDEX-NEW with one having the
2313 # same metadata as the entry in INDEX-PRESENT.
2314 fetch_filter_modified_metadata INDEX-OLD INDEX-PRESENT INDEX-NEW
2316 # Remove lines from INDEX-PRESENT and INDEX-NEW which are identical;
2317 # no need to update a file if it isn't changing.
2318 fetch_filter_uptodate INDEX-PRESENT INDEX-NEW
2320 # Prepare to fetch files: Generate a list of the files we need,
2322 # a list of patches to download.
2323 fetch_files_prepare INDEX-OLD INDEX-PRESENT INDEX-NEW || return 1
2326 fetch_files || return 1
2330 fetch_create_manifest || return 1
2333 fetch_warn_eol || return 1
2337 # with only the components which appear to be installed.
2340 # Generate filtered INDEX-ALL with only the components listed
2342 fetch_filter_metadata_components $1 || return 1
2345 echo -n "Inspecting system... "
2348 # supposed to be present if it is more than half-present.
2349 cut -f 1-3 -d '|' < INDEX-ALL |
2352 if [ -e ${BASEDIR}/${F} ]; then
2358 uniq -c |
2359 sed -E 's,^ +,,' > compfreq
2361 cut -f 1,3 -d ' ' |
2362 sort -k 2,2 -t ' ' > compfreq.total
2364 cut -f 1,3 -d ' ' |
2365 sort -k 2,2 -t ' ' > compfreq.present
2366 join -t ' ' -1 2 -2 2 compfreq.present compfreq.total |
2368 if [ ${T} -ne 0 -a ${P} -gt `expr ${T} / 2` ]; then
2372 cut -f 2 -d ' ' < compfreq.total > comp.total
2373 rm INDEX-ALL compfreq compfreq.total compfreq.present
2378 # Sometimes the kernel isn't installed where INDEX-ALL
2380 # /boot/kernel instead of /boot/GENERIC or /boot/SMP. To
2383 # found to be present) we will add it to comp.present.
2385 # not, we print a warning -- the user is running a kernel
2387 KCOMP=`echo ${KERNCONF} | tr 'A-Z' 'a-z'`
2388 grep -E "^kernel\|${KCOMP}\$" comp.total >> comp.present
2390 if grep -qE "^kernel\|" comp.total &&
2391 ! grep -qE "^kernel\|${KCOMP}\$" comp.total; then
2392 cat <<-EOF
2401 # Re-sort the list of installed components and generate
2402 # the list of non-installed components.
2403 sort -u < comp.present > comp.present.tmp
2405 comm -13 comp.present comp.total > comp.absent
2407 # Ask the user to confirm that what we have is correct. To
2408 # reduce user confusion, translate "X|Y" back to "X/Y" (as
2411 echo -n "The following components of FreeBSD "
2412 echo "seem to be installed:"
2414 fmt -72
2416 echo -n "The following components of FreeBSD "
2417 echo "do not seem to be installed:"
2419 fmt -72
2421 continuep || return 1
2425 # Note that comp.present.tmp is used due to issues with
2439 # corresponding to the currently running kernel, and said kernel
2440 # does not exist in the new release, add "kernel/generic" to the
2445 METAHASH=`look "$1|" tINDEX.present | cut -f 2 -d '|'`
2446 gunzip -c < files/${METAHASH}.gz > $1.all
2449 # isn't in $1.all, we need to add kernel/generic.
2452 ! grep -qE "^kernel\|${KCOMP}\|" $1.all; then
2455 cat <<-EOF
2459 As part of upgrading to FreeBSD ${RELNUM}, this kernel will be
2462 continuep || return 1
2467 rm $1.all
2471 # Convert INDEX-OLD (last release) and INDEX-ALL (new release) into
2472 # INDEX-OLD and INDEX-NEW files (in the sense of normal upgrades).
2474 # For each ${F}|... which appears in INDEX-ALL but does not appear
2475 # in INDEX-OLD, add ${F}|-|||||| to INDEX-OLD.
2476 cut -f 1 -d '|' < $1 |
2477 sort -u > $1.paths
2478 cut -f 1 -d '|' < $2 |
2479 sort -u |
2480 comm -13 $1.paths - |
2481 lam - -s "|-||||||" |
2482 sort - $1 > $1.tmp
2483 mv $1.tmp $1
2485 # Remove lines from INDEX-OLD which also appear in INDEX-ALL
2486 comm -23 $1 $2 > $1.tmp
2487 mv $1.tmp $1
2489 # Remove lines from INDEX-ALL which have a file name not appearing
2490 # anywhere in INDEX-OLD (since these must be files which haven't
2491 # changed -- if they were new, there would be an entry of type "-").
2492 cut -f 1 -d '|' < $1 |
2493 sort -u > $1.paths
2494 sort -k 1,1 -t '|' < $2 |
2495 join -t '|' - $1.paths |
2497 rm $1.paths
2500 # Rename INDEX-ALL to INDEX-NEW.
2507 X=`sed -E 's/\\$FreeBSD.*\\$/\$FreeBSD\$/' < $1 | ${SHA256}`
2508 Y=`sed -E 's/\\$FreeBSD.*\\$/\$FreeBSD\$/' < $2 | ${SHA256}`
2513 return 1;
2517 # From the list of "old" files in $1, merge changes in $2 with those in $3,
2518 # and update $3 to reflect the hashes of merged files.
2520 # We only need to do anything if $1 is non-empty.
2521 if [ -s $1 ]; then
2522 cut -f 1 -d '|' $1 |
2523 sort > $1-paths
2526 rm -rf merge/
2529 mkdir -p merge/old/${D}
2530 mkdir -p merge/${OLDRELNUM}/${D}
2531 mkdir -p merge/${RELNUM}/${D}
2532 mkdir -p merge/new/${D}
2533 done < $1-paths
2538 V=`look "${F}|" $2 | cut -f 7 -d '|'`
2542 if look "${F}|" $1 | fgrep -q "|f|"; then
2543 V=`look "${F}|" $1 | cut -f 3 -d '|'`
2549 if look "${F}|" $3 | cut -f 1,2,7 -d '|' |
2550 fgrep -q "|f|"; then
2551 V=`look "${F}|" $3 | cut -f 7 -d '|'`
2555 done < $1-paths
2557 # Attempt to automatically merge changes
2558 echo -n "Attempting to automatically merge "
2559 echo -n "changes in files..."
2565 if ! [ -f merge/${RELNUM}/${F} ]; then
2570 # going to throw away the existing file and hope that
2572 if ! [ -f merge/${OLDRELNUM}/${F} ]; then
2580 # Don't merge these -- we're rebuild them
2585 if ! diff3 -E -m -L "current version" \
2586 -L "${OLDRELNUM}" -L "${RELNUM}" \
2595 done < $1-paths
2598 # Ask the user to handle any files which didn't merge.
2601 # the old release only due to RCS tag expansion
2608 cat <<-EOF
2611 Press Enter to edit this file in ${EDITOR} and resolve the conflicts
2622 if ! grep -qE '^(<<<<<<<|=======|>>>>>>>)([[:space:]].*)?$' $(pwd)/merge/new/${F} ; then
2625 cat <<-EOF
2628 These must be resolved for the system to be functional.
2630 Press Enter to return to editing this file, or type "ACCEPT" to carry on with
2637 # Ask the user to confirm that he likes how the result
2642 if [ -f merge/old/${F} ] && [ -f merge/new/${F} ] &&
2648 # the old file only due to RCS tags.
2649 if [ -f merge/old/${F} ] &&
2650 [ -f merge/${OLDRELNUM}/${F} ] &&
2655 # Warn about files which are ceasing to exist.
2656 if ! [ -f merge/new/${F} ]; then
2657 cat <<-EOF
2662 continuep < /dev/tty || return 1
2667 cat <<-EOF
2672 diff -U 5 -L "current version" -L "new version" \
2674 continuep < /dev/tty || return 1
2675 done < $1-paths
2679 if [ -f merge/new/${F} ]; then
2680 V=`${SHA256} -q merge/new/${F}`
2682 gzip -c < merge/new/${F} > files/${V}.gz
2685 done < $1-paths > newhashes
2687 # Pull lines out from $3 which need to be updated to
2691 done < $1-paths > $3-oldlines
2693 # Update lines to reflect merged files
2694 join -t '|' -o 1.1,1.2,1.3,1.4,1.5,1.6,2.2,1.8 \
2695 $3-oldlines newhashes > $3-newlines
2698 sort $3-oldlines |
2699 comm -13 - $3 |
2700 sort - $3-newlines > $3.tmp
2704 rm $1-paths newhashes $3-oldlines $3-newlines
2705 rm -rf merge/
2709 rm $1
2712 # Do the work involved in fetching upgrades to a new release
2714 workdir_init || return 1
2719 # Try to fetch the public key until we run out of servers.
2721 fetch_pick_server || return 1
2724 # Try to fetch the metadata index signature ("tag") until we run
2727 fetch_pick_server || return 1
2729 fetch_tagsanity || return 1
2731 # Fetch the INDEX-OLD and INDEX-ALL.
2732 fetch_metadata INDEX-OLD INDEX-ALL || return 1
2735 # with only the components which appear to be installed.
2736 upgrade_guess_components INDEX-ALL || return 1
2738 # Generate filtered INDEX-OLD and INDEX-ALL files containing only
2740 fetch_filter_metadata INDEX-OLD || return 1
2741 fetch_filter_metadata INDEX-ALL || return 1
2743 # Merge the INDEX-OLD and INDEX-ALL files into INDEX-OLD.
2744 sort INDEX-OLD INDEX-ALL > INDEX-OLD.tmp
2745 mv INDEX-OLD.tmp INDEX-OLD
2746 rm INDEX-ALL
2754 # Try to fetch the NEW metadata index signature ("tag") until we run
2757 fetch_pick_server || return 1
2760 # Fetch the new INDEX-ALL.
2761 fetch_metadata INDEX-ALL || return 1
2764 # corresponding to the currently running kernel, and said kernel
2765 # does not exist in the new release, add "kernel/generic" to the
2767 upgrade_guess_new_kernel INDEX-ALL || return 1
2769 # Filter INDEX-ALL to contain only the components we want and without
2771 fetch_filter_metadata INDEX-ALL || return 1
2773 # Convert INDEX-OLD (last release) and INDEX-ALL (new release) into
2774 # INDEX-OLD and INDEX-NEW files (in the sense of normal upgrades).
2775 upgrade_oldall_to_oldnew INDEX-OLD INDEX-ALL INDEX-NEW
2778 fetch_filter_kernel_names INDEX-NEW ${NKERNCONF}
2779 fetch_filter_kernel_names INDEX-OLD ${KERNCONF}
2781 # For all paths appearing in INDEX-OLD or INDEX-NEW, inspect the
2782 # system and generate an INDEX-PRESENT file.
2783 fetch_inspect_system INDEX-OLD INDEX-PRESENT INDEX-NEW || return 1
2785 # Based on ${MERGECHANGES}, generate a file tomerge-old with the
2786 # paths and hashes of old versions of files to merge.
2787 fetch_filter_mergechanges INDEX-OLD INDEX-PRESENT INDEX-NEW tomerge-old
2789 # Based on ${UPDATEIFUNMODIFIED}, remove lines from INDEX-* which
2790 # correspond to lines in INDEX-PRESENT with hashes not appearing
2791 # in INDEX-OLD or INDEX-NEW. Also remove lines where the entry in
2792 # INDEX-PRESENT has type - and there isn't a corresponding entry in
2793 # INDEX-OLD with type -.
2795 INDEX-OLD INDEX-PRESENT INDEX-NEW tomerge-old
2797 # For each entry in INDEX-PRESENT of type -, remove any corresponding
2798 # entry from INDEX-NEW if ${ALLOWADD} != "yes". Remove all entries
2799 # of type - from INDEX-PRESENT.
2800 fetch_filter_allowadd INDEX-PRESENT INDEX-NEW
2803 # INDEX-PRESENT which don't correspond to entries in INDEX-NEW.
2804 fetch_filter_allowdelete INDEX-PRESENT INDEX-NEW
2807 # INDEX-PRESENT with metadata not matching any entry in INDEX-OLD,
2808 # replace the corresponding line of INDEX-NEW with one having the
2809 # same metadata as the entry in INDEX-PRESENT.
2810 fetch_filter_modified_metadata INDEX-OLD INDEX-PRESENT INDEX-NEW
2812 # Remove lines from INDEX-PRESENT and INDEX-NEW which are identical;
2813 # no need to update a file if it isn't changing.
2814 fetch_filter_uptodate INDEX-PRESENT INDEX-NEW
2817 fetch_files_premerge tomerge-old
2819 # Prepare to fetch files: Generate a list of the files we need,
2821 # a list of patches to download.
2822 fetch_files_prepare INDEX-OLD INDEX-PRESENT INDEX-NEW || return 1
2824 # Fetch patches from to-${RELNUM}/${ARCH}/bp/
2825 PATCHDIR=to-${RELNUM}/${ARCH}/bp
2826 fetch_files || return 1
2829 upgrade_merge tomerge-old INDEX-PRESENT INDEX-NEW || return 1
2833 fetch_create_manifest || return 1
2835 # Leave a note behind to tell the "install" command that the kernel
2836 # needs to be installed before the world.
2837 touch ${BDHASH}-install/kernelfirst
2839 # Remind the user that they need to run "freebsd-update install"
2840 # to install the downloaded bits, in case they didn't RTFM.
2841 echo "To install the downloaded upgrades, run '`basename $0` [options] install'."
2849 cut -f 2,7 -d '|' |
2850 grep -E '^f' |
2851 cut -f 2 -d '|' |
2852 sort -u > filelist
2856 if ! [ -f files/${HASH}.gz ]; then
2857 echo -n "Update files missing -- "
2859 echo "Re-run '`basename $0` [options] fetch'."
2860 return 1
2872 cut -f 1 -d '|' > filelist
2876 if ! [ -e ${BASEDIR}/${F} ]; then
2881 done < filelist | xargs chflags noschg || return 1
2887 # Decide which directory name to use for kernel backups.
2893 if [ ! -e $BASEDIR/$BACKUPKERNELDIR ]; then
2899 if [ -d $BASEDIR/$BACKUPKERNELDIR -a \
2900 -e $BASEDIR/$BACKUPKERNELDIR/.freebsd-update ]; then
2904 # We could not use current directory name, so add counter to
2906 CNT=$((CNT + 1))
2907 if [ $CNT -gt 9 ]; then
2909 exit 1
2911 BACKUPKERNELDIR="`echo $BACKUPKERNELDIR | sed -Ee 's/[0-9]\$//'`"
2918 # we create a marker file called ".freebsd-update" in the directory so
2920 # freebsd-update and we then do not accidentally remove user files in
2929 # Decide which directory name to use for kernel backups.
2935 if [ -d $BASEDIR/$BACKUPKERNELDIR ]; then
2936 rm -fr $BASEDIR/$BACKUPKERNELDIR
2940 mkdir -p $BASEDIR/$BACKUPKERNELDIR
2941 mtree -cdn -p "${BASEDIR}/${KERNELDIR}" | \
2942 mtree -Ue -p "${BASEDIR}/${BACKUPKERNELDIR}" > /dev/null
2944 # Mark the directory as having been created by freebsd-update.
2945 touch $BASEDIR/$BACKUPKERNELDIR/.freebsd-update
2946 if [ $? -ne 0 ]; then
2948 exit 1
2951 # Disable pathname expansion to be sure *.symbols is not
2953 set -f
2955 # Use find to ignore symbol files, unless disabled by user.
2959 FINDFILTER="-a ! -name *.debug -a ! -name *.symbols"
2963 (cd ${BASEDIR}/${KERNELDIR} && find . -type f $FINDFILTER -exec \
2964 cp -pl '{}' ${BASEDIR}/${BACKUPKERNELDIR}/'{}' \;)
2966 # Re-enable pathname expansion.
2971 # symlink that we are going to install.
2973 if [ -d "$1" ]; then
2974 echo "Removing conflicting directory $1"
2975 rm -rf -- "$1"
2983 sort -k 1,1 -t '|' $1 |
2988 # Create a directory. A file may change to a directory
2991 if [ -e "${BASEDIR}/${FPATH}" ] && \
2992 ! [ -d "${BASEDIR}/${FPATH}" ]; then
2993 rm -f -- "${BASEDIR}/${FPATH}"
2995 install -d -o ${OWNER} -g ${GROUP} \
2996 -m ${PERM} ${BASEDIR}/${FPATH}
3000 if [ -z "${LINK}" ]; then
3003 install -o ${OWNER} -g ${GROUP} \
3004 -m ${PERM} ${HASH} ${BASEDIR}/${FPATH}
3008 ln -f ${BASEDIR}/${LINK} ${BASEDIR}/${FPATH}
3014 ln -sfh ${HASH} ${BASEDIR}/${FPATH}
3020 tr '|' ' ' < $1 |
3029 # Remove files which we want to delete
3032 cut -f 1 -d '|' < $2 |
3035 # Generate subindex of old files we want to nuke
3036 sort -k 1,1 -t '|' $1 |
3037 join -t '|' -v 1 - newfiles |
3038 sort -r -k 1,1 -t '|' |
3039 cut -f 1,2 -d '|' |
3049 if [ -f "${BASEDIR}/${FPATH}" ]; then
3054 if [ -L "${BASEDIR}/${FPATH}" ]; then
3068 if ! [ -f $1/kerneldone ]; then
3069 grep -E '^/boot/' $1/INDEX-OLD > INDEX-OLD
3070 grep -E '^/boot/' $1/INDEX-NEW > INDEX-NEW
3073 backup_kernel || return 1
3076 install_from_index INDEX-NEW || return 1
3078 # Remove files which need to be deleted
3079 install_delete INDEX-OLD INDEX-NEW || return 1
3082 if [ -s INDEX-OLD -o -s INDEX-NEW ]; then
3083 kldxref -R ${BASEDIR}/boot/ 2>/dev/null
3087 touch $1/kerneldone
3089 # Do we need to ask for a reboot now?
3090 if [ -f $1/kernelfirst ] &&
3091 [ -s INDEX-OLD -o -s INDEX-NEW ]; then
3092 cat <<-EOF
3095 '`basename $0` [options] install' again to finish installing updates.
3102 if ! [ -f $1/worlddone ]; then
3104 grep -vE '^/boot/' $1/INDEX-NEW |
3105 grep -E '^[^|]+\|d\|' > INDEX-NEW
3106 install_from_index INDEX-NEW || return 1
3109 grep -vE '^/boot/' $1/INDEX-NEW |
3110 grep -vE '^[^|]+\|d\|' |
3111 grep -E '^/libexec/ld-elf[^|]*\.so\.[0-9]+\|' > INDEX-NEW
3112 install_from_index INDEX-NEW || return 1
3115 grep -vE '^/boot/' $1/INDEX-NEW |
3116 grep -vE '^[^|]+\|d\|' |
3117 grep -vE '^/libexec/ld-elf[^|]*\.so\.[0-9]+\|' |
3118 grep -E '^[^|]*/lib/libsys\.so\.[0-9]+\|' > INDEX-NEW
3119 install_from_index INDEX-NEW || return 1
3120 grep -vE '^/boot/' $1/INDEX-NEW |
3121 grep -vE '^[^|]+\|d\|' |
3122 grep -vE '^/libexec/ld-elf[^|]*\.so\.[0-9]+\|' |
3123 grep -E '^[^|]*/lib/libc\.so\.[0-9]+\|' > INDEX-NEW
3124 install_from_index INDEX-NEW || return 1
3125 grep -vE '^/boot/' $1/INDEX-NEW |
3126 grep -vE '^[^|]+\|d\|' |
3127 grep -vE '^/libexec/ld-elf[^|]*\.so\.[0-9]+\|' |
3128 grep -E '^[^|]*/lib/libthr\.so\.[0-9]+\|' > INDEX-NEW
3129 install_from_index INDEX-NEW || return 1
3132 grep -vE '^/boot/' $1/INDEX-NEW |
3133 grep -vE '^[^|]+\|d\|' |
3134 grep -vE '^/libexec/ld-elf[^|]*\.so\.[0-9]+\|' |
3135 grep -vE '^[^|]*/lib/(libsys|libc|libthr)\.so\.[0-9]+\|' |
3136 grep -E '^[^|]*/lib/[^|]*\.so\.[0-9]+\|' > INDEX-NEW
3137 install_from_index INDEX-NEW || return 1
3140 grep -vE '^/boot/' $1/INDEX-OLD |
3141 grep -vE '^[^|]+\|d\|' |
3142 grep -vE '^/libexec/ld-elf[^|]*\.so\.[0-9]+\|' |
3143 grep -vE '^[^|]*/lib/[^|]*\.so\.[0-9]+\|' > INDEX-OLD
3144 grep -vE '^/boot/' $1/INDEX-NEW |
3145 grep -vE '^[^|]+\|d\|' |
3146 grep -vE '^/libexec/ld-elf[^|]*\.so\.[0-9]+\|' |
3147 grep -vE '^[^|]*/lib/[^|]*\.so\.[0-9]+\|' > INDEX-NEW
3148 install_from_index INDEX-NEW || return 1
3149 install_delete INDEX-OLD INDEX-NEW || return 1
3166 pwd_mkdb -d ${BASEDIR}/etc -p ${BASEDIR}/etc/master.passwd
3171 if [ ! -d ${BASEDIR}/$D ]; then
3174 if [ -f ${BASEDIR}/$D/mandoc.db ] && \
3175 [ -z "$(find ${BASEDIR}/$D -type f -newer ${BASEDIR}/$D/mandoc.db)" ]; then
3183 touch $1/worlddone
3185 # Do we need to ask the user to portupgrade now?
3186 grep -vE '^/boot/' $1/INDEX-NEW |
3187 grep -E '^[^|]*/lib/[^|]*\.so\.[0-9]+\|' |
3188 cut -f 1 -d '|' |
3190 if grep -vE '^/boot/' $1/INDEX-OLD |
3191 grep -E '^[^|]*/lib/[^|]*\.so\.[0-9]+\|' |
3192 cut -f 1 -d '|' |
3194 join -v 1 - newfiles |
3195 grep -q .; then
3196 cat <<-EOF
3201 '`basename $0` [options] install' again to finish installing updates.
3210 grep -vE '^/boot/' $1/INDEX-NEW |
3211 grep -vE '^[^|]+\|d\|' |
3212 grep -E '^[^|]*/lib/[^|]*\.so\.[0-9]+\|' > INDEX-NEW
3213 grep -vE '^/boot/' $1/INDEX-OLD |
3214 grep -vE '^[^|]+\|d\|' |
3215 grep -E '^[^|]*/lib/[^|]*\.so\.[0-9]+\|' > INDEX-OLD
3216 install_delete INDEX-OLD INDEX-NEW || return 1
3219 grep -vE '^/boot/' $1/INDEX-NEW |
3220 grep -E '^[^|]+\|d\|' > INDEX-NEW
3221 grep -vE '^/boot/' $1/INDEX-OLD |
3222 grep -E '^[^|]+\|d\|' > INDEX-OLD
3223 install_delete INDEX-OLD INDEX-NEW || return 1
3226 rm INDEX-OLD INDEX-NEW
3229 # Rearrange bits to allow the installed updates to be rolled back
3232 # "finished installing the world" flags if present -- they are
3234 if [ -f ${BDHASH}-install/kernelfirst ]; then
3235 rm ${BDHASH}-install/kernelfirst
3236 rm ${BDHASH}-install/kerneldone
3238 if [ -f ${BDHASH}-install/worlddone ]; then
3239 rm ${BDHASH}-install/worlddone
3242 if [ -L ${BDHASH}-rollback ]; then
3243 mv ${BDHASH}-rollback ${BDHASH}-install/rollback
3246 mv ${BDHASH}-install ${BDHASH}-rollback
3251 echo -n "Installing updates..."
3254 install_verify ${BDHASH}-install/INDEX-OLD \
3255 ${BDHASH}-install/INDEX-NEW || return 1
3258 install_unschg ${BDHASH}-install/INDEX-OLD \
3259 ${BDHASH}-install/INDEX-NEW || return 1
3262 install_files ${BDHASH}-install || return 1
3264 # Rearrange bits to allow the installed updates to be rolled back
3270 # Rearrange bits to allow the previous set of updates to be rolled back next.
3272 if [ -L ${BDHASH}-rollback/rollback ]; then
3273 mv ${BDHASH}-rollback/rollback rollback-tmp
3274 rm -r ${BDHASH}-rollback/
3275 rm ${BDHASH}-rollback
3276 mv rollback-tmp ${BDHASH}-rollback
3278 rm -r ${BDHASH}-rollback/
3279 rm ${BDHASH}-rollback
3287 awk -F \| '{if ($2 == "d") print }' $1/INDEX-OLD > INDEX-OLD
3288 install_from_index INDEX-OLD || return 1
3292 grep -vE '^/boot/' $1/INDEX-NEW |
3293 grep -E '/lib/.*\.so\.[0-9]+\|' |
3294 cut -f 1 -d '|' |
3295 sort > INDEX-NEW.libs.flist
3296 grep -vE '^/boot/' $1/INDEX-OLD |
3297 grep -E '/lib/.*\.so\.[0-9]+\|' |
3298 sort -k 1,1 -t '|' - |
3299 join -t '|' -v 1 - INDEX-NEW.libs.flist > INDEX-OLD
3300 install_from_index INDEX-OLD || return 1
3303 grep -vE '^/boot/' $1/INDEX-OLD |
3304 grep -vE '/lib/.*\.so\.[0-9]+\|' > INDEX-OLD
3305 grep -vE '^/boot/' $1/INDEX-NEW |
3306 grep -vE '/lib/.*\.so\.[0-9]+\|' > INDEX-NEW
3307 install_from_index INDEX-OLD || return 1
3308 install_delete INDEX-NEW INDEX-OLD || return 1
3311 grep -vE '^/boot/' $1/INDEX-OLD |
3312 grep -E '/lib/.*\.so\.[0-9]+\|' |
3313 sort -k 1,1 -t '|' - |
3314 join -t '|' - INDEX-NEW.libs.flist > INDEX-OLD
3315 install_from_index INDEX-OLD || return 1
3318 grep -vE '^/boot/' $1/INDEX-OLD |
3319 grep -E '/lib/.*\.so\.[0-9]+\|' > INDEX-OLD
3320 grep -vE '^/boot/' $1/INDEX-NEW |
3321 grep -E '/lib/.*\.so\.[0-9]+\|' > INDEX-NEW
3322 install_delete INDEX-NEW INDEX-OLD || return 1
3325 grep -E '^/boot/' $1/INDEX-OLD > INDEX-OLD
3326 grep -E '^/boot/' $1/INDEX-NEW > INDEX-NEW
3327 install_from_index INDEX-OLD || return 1
3328 install_delete INDEX-NEW INDEX-OLD || return 1
3329 if [ -s INDEX-OLD -o -s INDEX-NEW ]; then
3330 kldxref -R /boot/ 2>/dev/null
3334 rm INDEX-OLD INDEX-NEW INDEX-NEW.libs.flist
3339 echo -n "Uninstalling updates..."
3341 # If there are updates waiting to be installed, remove them; we
3342 # want the user to re-run 'fetch' after rolling back updates.
3343 if [ -L ${BDHASH}-install ]; then
3344 rm -r ${BDHASH}-install/
3345 rm ${BDHASH}-install
3349 install_verify ${BDHASH}-rollback/INDEX-NEW \
3350 ${BDHASH}-rollback/INDEX-OLD || return 1
3353 install_unschg ${BDHASH}-rollback/INDEX-NEW \
3354 ${BDHASH}-rollback/INDEX-OLD || return 1
3357 rollback_files ${BDHASH}-rollback || return 1
3359 # Remove the rollback directory and the symlink pointing to it; and
3360 # rearrange bits to allow the previous set of updates to be rolled
3367 # Compare INDEX-ALL and INDEX-PRESENT and print warnings about differences.
3370 # flags. We ignore file flags because sysinstall doesn't seem to
3373 cut -f 1-5,7-8 -d '|' $1 > $1.noflags
3374 sort -k 1,1 -t '|' $1.noflags > $1.sorted
3375 cut -f 1-5,7-8 -d '|' $2 |
3376 comm -13 $1.noflags - |
3377 fgrep -v '|-|||||' |
3378 sort -k 1,1 -t '|' |
3379 join -t '|' $1.sorted - > INDEX-NOTMATCHING
3383 grep -E "^${X}" INDEX-NOTMATCHING
3385 sort -u |
3386 comm -13 - INDEX-NOTMATCHING > INDEX-NOTMATCHING.tmp
3387 mv INDEX-NOTMATCHING.tmp INDEX-NOTMATCHING
3394 echo -n "${FPATH} is a "
3396 f) echo -n "regular file, "
3398 d) echo -n "directory, "
3400 L) echo -n "symlink, "
3403 echo -n "but should be a "
3405 f) echo -n "regular file."
3407 d) echo -n "directory."
3409 L) echo -n "symlink."
3421 echo -n "${FPATH} is owned by user id ${P_OWNER}, "
3427 echo -n "${FPATH} is owned by group id ${P_GROUP}, "
3437 echo -n "${FPATH} has ${P_PERM} permissions, "
3444 echo -n "${FPATH} is a symlink to ${P_HASH}, "
3445 echo "but should be a symlink to ${HASH}."
3448 echo -n "${FPATH} has SHA256 hash ${P_HASH}, "
3456 done < INDEX-NOTMATCHING
3459 rm $1 $1.noflags $1.sorted $2 INDEX-NOTMATCHING
3462 # Do the work involved in comparing the system to a "known good" index
3464 workdir_init || return 1
3469 # Try to fetch the public key until we run out of servers.
3471 fetch_pick_server || return 1
3474 # Try to fetch the metadata index signature ("tag") until we run
3477 fetch_pick_server || return 1
3479 fetch_tagsanity || return 1
3481 # Fetch INDEX-OLD and INDEX-ALL.
3482 fetch_metadata INDEX-OLD INDEX-ALL || return 1
3484 # Generate filtered INDEX-OLD and INDEX-ALL files containing only
3486 fetch_filter_metadata INDEX-OLD || return 1
3487 fetch_filter_metadata INDEX-ALL || return 1
3489 # Merge the INDEX-OLD and INDEX-ALL files into INDEX-ALL.
3490 sort INDEX-OLD INDEX-ALL > INDEX-ALL.tmp
3491 mv INDEX-ALL.tmp INDEX-ALL
3492 rm INDEX-OLD
3494 # Translate /boot/${KERNCONF} to ${KERNELDIR}
3495 fetch_filter_kernel_names INDEX-ALL ${KERNCONF}
3497 # Inspect the system and generate an INDEX-PRESENT file.
3498 fetch_inspect_system INDEX-ALL INDEX-PRESENT /dev/null || return 1
3500 # Compare INDEX-ALL and INDEX-PRESENT and print warnings about any
3502 IDS_compare INDEX-ALL INDEX-PRESENT
3505 #### Main functions -- call parameter-handling and core functions
3520 if [ ! -t 0 -a $NOTTYOK -eq 0 ]; then
3521 echo -n "`basename $0` fetch should not "
3522 echo "be run non-interactively."
3524 exit 1
3527 fetch_run || exit 1
3528 ISFETCHED=1
3533 # send output to a temporary file; only print that file if the
3537 sleep `jot -r 1 0 3600`
3539 TMPFILE=`mktemp /tmp/freebsd-update.XXXXXX` || exit 1
3542 ! grep -q "No updates needed" ${TMPFILE} ||
3544 mail -s "`hostname` security updates" ${MAILTO} < ${TMPFILE}
3546 ISFETCHED=1
3551 # Fetch files for upgrading to a new release.
3556 upgrade_run || exit 1
3559 # Check if there are fetched updates ready to install.
3564 if ! [ -e "${WORKDIR}" ]; then
3565 echo "No updates are available to install."
3570 cd ${WORKDIR} || exit 1
3573 BDHASH=`echo ${BASEDIR} | sha256 -q`
3575 # Check that we have updates ready to install
3576 if ! [ -L ${BDHASH}-install ]; then
3577 echo "No updates are available to install."
3581 echo "There are updates available to install."
3582 echo "Run '`basename $0` [options] install' to proceed."
3590 install_run || exit 1
3597 rollback_run || exit 1
3604 IDS_run || exit 1
3621 if [ -z "$PAGER" ]; then
3625 # Set LC_ALL in order to avoid problems with character ranges like [A-Z].
3637 freebsd-update is incompatible with the use of packaged base. Please see
3640 exit 1