Changeset View
Standalone View
usr.sbin/freebsd-update/freebsd-update.sh
Show First 20 Lines • Show All 649 Lines • ▼ Show 20 Lines | stats) | ||||||||||
STATSREDIR="/dev/stdout" | STATSREDIR="/dev/stdout" | ||||||||||
DDSTATS="" | DDSTATS="" | ||||||||||
XARGST="" | XARGST="" | ||||||||||
NDEBUG="-n" | NDEBUG="-n" | ||||||||||
;; | ;; | ||||||||||
esac | esac | ||||||||||
} | } | ||||||||||
# Check if there are any kernel modules installed from ports. | |||||||||||
# In that case warn the user that a rebuild from ports (i.e. not from | |||||||||||
# packages) might need necessary for the modules to work in the new release. | |||||||||||
upgrade_check_kmod_ports() { | |||||||||||
local mod_name | |||||||||||
local modules | |||||||||||
local pattern | |||||||||||
local pkg_name | |||||||||||
local port_name | |||||||||||
local report | |||||||||||
local w | |||||||||||
if ! command -v pkg >/dev/null; then | |||||||||||
delphij: Before proceeding any further, we should check if `pkg` is present. Something like:
```
if… | |||||||||||
Done Inline ActionsThanks, that makes sense. fernape: Thanks, that makes sense. | |||||||||||
echo "Skipping kernel modules check. pkg(8) not present." | |||||||||||
return | |||||||||||
Done Inline Actions
I think it's probably a good idea to only match the last module_path= instead of matching all module_path (they may be commented out, or overridden by a later occurrence). delphij: I think it's probably a good idea to only match the last `module_path=` instead of matching all… | |||||||||||
Done Inline ActionsDone. I also added /boot/modules as a fallback case. fernape: Done.
I also added `/boot/modules` as a fallback case. | |||||||||||
fi | |||||||||||
# Most modules are in /boot/modules but we should actually look | |||||||||||
# in every path configured in module_path | |||||||||||
search_files="/boot/defaults/loader.conf /boot/loader.conf" | |||||||||||
Done Inline Actions
I think you can avoid hardcoding the value by simply grep'ing the defaults and the canonical loader.conf in this order... delphij: I think you can avoid hardcoding the value by simply grep'ing the defaults and the canonical… | |||||||||||
Done Inline ActionsNice! Thank you. fernape: Nice!
Thank you. | |||||||||||
pattern=$(grep -shE '^module_path=' ${search_files} | | |||||||||||
Done Inline Actions
Shall it be warned if either /boot/defaults/loader.conf or /boot/loader.conf does not exist ? zlei: Shall it be warned if either `/boot/defaults/loader.conf` or `/boot/loader.conf` does not exist… | |||||||||||
tail -1 | | |||||||||||
cut -f2 -d\" | | |||||||||||
tr ";" "|") | |||||||||||
if [ -z "${pattern}" ]; then | |||||||||||
# Not having module_path in loader.conf is probably an error. | |||||||||||
# Check at least the most common path | |||||||||||
pattern="/boot/modules" | |||||||||||
fi | |||||||||||
# Check the pkg database for modules installed in those directories | |||||||||||
modules=$(pkg query '%Fp' | grep -E "${pattern}") | |||||||||||
if [ -z "${modules}" ]; then | |||||||||||
return | |||||||||||
fi | |||||||||||
echo -e "\n" | |||||||||||
echo "The following modules have been installed from packages." | |||||||||||
echo "As a consequence they might not work when performing a major or minor upgrade." | |||||||||||
Done Inline Actions
Minor upgrade should also be warned. zlei: Minor upgrade should also be warned. | |||||||||||
echo -e "It is advised to rebuild these ports:\n" | |||||||||||
Not Done Inline Actions
Or These modules are previously installed from packages, users may prefer to re-install them rather than rebuild from ports. zlei: > It is advised to rebuild these ports:
Or
`It is advised to re-install these packages or… | |||||||||||
Done Inline ActionsReinstalling packages might not work depending on the timing. Packages are built for the minor version of FreeBSD. If someone upgrades from 13.1 to 13.2 today (as I did) and then try to load, for instance, the virtualbox modules , they will get these messages: kldload: an error occurred while loading module vboxdrv. Please check dmesg(8) for more details. kldload: an error occurred while loading module vboxnetadp. Please check dmesg(8) for more details. and in dmesg(8): KLD vboxdrv.ko: depends on kernel - not available or version mismatch linker_load_file: /boot/modules/vboxdrv.ko - unsupported file type KLD vboxnetadp.ko: depends on vboxdrv - not available or version mismatch linker_load_file: /boot/modules/vboxnetadp.ko - unsupported file type Reinstalling from packages will only work once the package builders are using 13.2 (in the example) which will presumably be when 13.1 is EOLed. See this note in the Handbook. fernape: Reinstalling packages might not work depending on the timing. Packages are built for the minor… | |||||||||||
Not Done Inline ActionsI see. For minor version upgrades (e.g., 13.1 to 13.2), the ABI is guaranteed to be stable, so normal packages ( those built on 13.1 ) will continue to work, but some special packages those providing kernel modules such as virtualbox-ose-kmod may not work. So can we have different port build policy for those special packages ? Just build them ( on 13.2 ) immediately so that the upgrade will be smooth. Also CC releng . zlei: I see.
For minor version upgrades (e.g., 13.1 to 13.2), the ABI is guaranteed to be stable… | |||||||||||
Done Inline ActionsYes, that would reduce the problematic window, although I don't know how many resources we have for that.
And that might be very expensive. For instance, after upgrading from 13.1 to 13.2 I rebuilt virtualbox-ose-kmod for 13.2 using a poudriere jail. But it took a while because it builds with gcc and it needed to be rebuilt. Some Linux distros trigger the rebuilding of drivers when upgrading. Because the system is so bloated in the first time, they don't need any extra dependencies, everything is in the system already (git, gcc, binutils, etc.) fernape: Yes, that would reduce the problematic window, although I don't know how many resources we have… | |||||||||||
Not Done Inline Actions
Explicitly note build from source . zlei: Explicitly note `build from source` . | |||||||||||
Done Inline ActionsAren't ports by definition built always from source? fernape: Aren't ports by definition built always from source? | |||||||||||
Done Inline Actions
I think YES. So
is not needed. zlei: > Aren't ports by definition built always from source?
I think YES. So
> Explicitly note build… | |||||||||||
report="Module Package Port\n------ ------- ----\n" | |||||||||||
for module in ${modules}; do | |||||||||||
w=$(pkg which "${module}") | |||||||||||
mod_name=$(echo "${w}" | awk '{print $1;}') | |||||||||||
pkg_name=$(echo "${w}" | awk '{print $6;}') | |||||||||||
Not Done Inline Actions
zlei: | |||||||||||
port_name=$(pkg info -o "${pkg_name}" | awk '{print $2;}') | |||||||||||
report="${report}${mod_name} ${pkg_name} ${port_name}\n" | |||||||||||
done | |||||||||||
echo -e "${report}" | column -t | |||||||||||
echo -e "\n" | |||||||||||
} | |||||||||||
# Perform sanity checks and set some final parameters | # Perform sanity checks and set some final parameters | ||||||||||
# in preparation for fetching files. Figure out which | # in preparation for fetching files. Figure out which | ||||||||||
# set of updates should be downloaded: If the user is | # set of updates should be downloaded: If the user is | ||||||||||
# running *-p[0-9]+, strip off the last part; if the | # running *-p[0-9]+, strip off the last part; if the | ||||||||||
# user is running -SECURITY, call it -RELEASE. Chdir | # user is running -SECURITY, call it -RELEASE. Chdir | ||||||||||
# into the working directory. | # into the working directory. | ||||||||||
fetchupgrade_check_params () { | fetchupgrade_check_params () { | ||||||||||
export HTTP_USER_AGENT="freebsd-update (${COMMAND}, `uname -r`)" | export HTTP_USER_AGENT="freebsd-update (${COMMAND}, `uname -r`)" | ||||||||||
▲ Show 20 Lines • Show All 2,795 Lines • ▼ Show 20 Lines | cmd_cron () { | ||||||||||
rm ${TMPFILE} | rm ${TMPFILE} | ||||||||||
} | } | ||||||||||
# Fetch files for upgrading to a new release. | # Fetch files for upgrading to a new release. | ||||||||||
cmd_upgrade () { | cmd_upgrade () { | ||||||||||
finalize_components_config ${COMPONENTS} | finalize_components_config ${COMPONENTS} | ||||||||||
upgrade_check_params | upgrade_check_params | ||||||||||
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. | ||||||||||
cmd_updatesready () { | cmd_updatesready () { | ||||||||||
finalize_components_config ${COMPONENTS} | finalize_components_config ${COMPONENTS} | ||||||||||
# Check if working directory exists (if not, no updates pending) | # Check if working directory exists (if not, no updates pending) | ||||||||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |
Before proceeding any further, we should check if pkg is present. Something like:
would do it. Otherwise freebsd-update will attempt to install pkg.