How to check if there is a new FreeBSD release from the cmdline?

I am familiar with freebsd-update for patches, but for instance, I want to use the cmdline to see what releases exist. For instance, I want to see that I can upgrade from 14.0-RELEASE to 14.1-RELEASE.

I can determine that from the browser, but what about the cmdline?
 
I've played around with that curl command , piping it to
Code:
awk '{print $3}'
made it cleaner for me, giving me
/releases/amd64/</title> /releases/amd64/</h1> style="width:55%"><a href="../">Parent href="13.3-RELEASE/" href="13.4-BETA1/" href="13.4-BETA2/" href="14.0-RELEASE/" href="14.1-RELEASE/" href="amd64/" href="README.TXT"
I imagine you could make it even cleaner if you wished.
 
[…] I can easily parse that and take the latest to say, […]
KISS: No parsing necessary, though may be an unreliable heuristic (e. g. if there are server connection issues): ?​
Bash:
# As of 2024‑08‑13 this yields an HTTP status code 404 (resource not found).
# `fetch(1)` returns an exit status `1` (`EXIT_FAILURE`) in this case.
if fetch -o - -q 'https://download.freebsd.org/releases/amd64/14.2-RELEASE' 2>&- 1>&-
then
    printf 'new release available\n'
fi
Obviously, architecture, major and minor version need to be determined dynamically and you need an additional check for a major release leap (15.0). ?‍?​
[SUB]For some quite elaborate script, see Thread 86660.[/SUB]

PS: If you don’t mind an editorial delay, for a third‑party data source you can consult​
Bash:
fetch -o - -q 'http://www.wikidata.org/w/api.php?action=wbgetclaims&format=json&entity=Q34236&property=P348'
and then filter with jq(1) or similar tools. ?​
 
Also:

Code:
% curl --silent https://pkg.freebsd.org/FreeBSD:14:amd64/ | grep base_release
<tr><td class="link"><a href="base_release_0/" title="base_release_0">base_release_0/</a></td><td class="size">-</td><td class="date">2024-Aug-08 00:06</td></tr>
<tr><td class="link"><a href="base_release_1/" title="base_release_1">base_release_1/</a></td><td class="size">-</td><td class="date">2024-Aug-08 00:06</td></tr>
%
 
I have written little bash script

Bash:
#!/usr/local/bin/bash

platform=$(uname -p)
echo "platform: $platform"
if [ -z "$platform" ]; then
    echo "unknown platform"
    exit 1
fi

current_version=$(uname -r | grep -E -o '[[:digit:],\.]{4,}')
echo "version: $current_version"
if [ -z "$current_version" ]; then
    echo "unknown version"
    exit 2
fi

current_integer_version=$(echo "$current_version" | sed s/[.]//)
#echo "current integer version: $current_integer_version"

url="https://download.freebsd.org/releases/$platform/"
echo "url: $url"
lines=$(curl --silent $url)
if [ $? -ne 0 ]; then
    echo "error downloading release page"
    exit 3
fi

versions=$(echo $lines | grep -o -E '[[:digit:]]{2}\.[[:digit:]]{1}-[[:alpha:]]{4,}' | sort -u)

for version in $(echo "$versions"); do
    integer_version=$(echo "$version" | sed s/[[:alpha:],.-]//g)
    if [[ "$integer_version" -gt "$current_integer_version" ]]; then
    echo "available version: $version"
    fi;
done;

my result

platform: amd64
version: 13.3
url: https://download.freebsd.org/releases/amd64/
available version: 13.4-BETA
available version: 14.0-RELEASE
available version: 14.1-RELEASE
 
bash script

Thanks.

A nit: on 13.4-BETA2, it does not detect availability of 13.4-BETA3.

Code:
grahamperrin@pkg:/tmp % ./list-upgrades.sh
platform: amd64
version: 13.4
url: https://download.freebsd.org/releases/amd64/
available version: 14.0-RELEASE
available version: 14.1-RELEASE
grahamperrin@pkg:/tmp % uname -aKU
FreeBSD pkg 13.4-BETA2 FreeBSD 13.4-BETA2 releng/13.4-n258214-30b27afe3bc5 GENERIC amd64 1304000 1304000
grahamperrin@pkg:/tmp % su -
Password:
root@pkg:~ # freebsd-update fetch
Looking up update.FreeBSD.org mirrors... 3 mirrors found.
Fetching metadata signature for 13.4-BETA2 from update1.freebsd.org... done.
Fetching metadata index... done.
Inspecting system... done.
Preparing to download files... done.

No updates needed to update system to 13.4-BETA2-p0.
root@pkg:~ #

That is, coincidentally, an example of freebsd-update detecting but not reporting that a system is approaching end of life.
 
Thanks.

A nit: on 13.4-BETA2, it does not detect availability of 13.4-BETA3.

Code:
grahamperrin@pkg:/tmp % ./list-upgrades.sh
platform: amd64
version: 13.4
url: https://download.freebsd.org/releases/amd64/
available version: 14.0-RELEASE
available version: 14.1-RELEASE
grahamperrin@pkg:/tmp % uname -aKU
FreeBSD pkg 13.4-BETA2 FreeBSD 13.4-BETA2 releng/13.4-n258214-30b27afe3bc5 GENERIC amd64 1304000 1304000
grahamperrin@pkg:/tmp % su -
Password:
root@pkg:~ # freebsd-update fetch
Looking up update.FreeBSD.org mirrors... 3 mirrors found.
Fetching metadata signature for 13.4-BETA2 from update1.freebsd.org... done.
Fetching metadata index... done.
Inspecting system... done.
Preparing to download files... done.

No updates needed to update system to 13.4-BETA2-p0.
root@pkg:~ #

That is, coincidentally, an example of freebsd-update detecting but not reporting that a system is approaching end of life.

Yes, I have missed such situation. It can be solved with rising script complicity)
 
Back
Top