Script to check if you are on the latest point release

Script checking if running kernel is point-release of git source,
cat checkit
Code:
#!/bin/sh

URL="https://raw.githubusercontent.com/freebsd/freebsd-src/refs/heads/releng/15.1/sys/conf/newvers.sh"

# 1. Fetch data from GitHub and evaluate assignments safely
REMOTE_DATA=$(wget -qO- "$URL")
eval "$(echo "$REMOTE_DATA" | grep -E '^(TYPE|REVISION|BRANCH)=')"

# 2. Get local version
LOCAL_VER=$(freebsd-version -k)

# 3. Format remote version exactly like local
REMOTE_VER="${REVISION}-${BRANCH}"

# 4. Print outputs
echo "Local Kernel:   $LOCAL_VER"
echo "GitHub Version: $TYPE $REMOTE_VER"

# 5. Pure shell string manipulation (Zero seds)
# Extracts everything after the last "-p"
LOCAL_PATCH="${LOCAL_VER##*-p}"
REMOTE_PATCH="${REMOTE_VER##*-p}"

# If no "-p" existed, the variable won't change; reset to 0
[ "$LOCAL_PATCH" = "$LOCAL_VER" ] && LOCAL_PATCH=0
[ "$REMOTE_PATCH" = "$REMOTE_VER" ] && REMOTE_PATCH=0

# 6. Final comparison
if [ "$REMOTE_PATCH" -gt "$LOCAL_PATCH" ]; then
    echo "Status:         NEWER AVAILABLE"
else
    echo "Status:         Up to date"
fi
 
Kernel isn't always updated. So REVISION from newvers.sh might not match with your installed/running kernel.

Code:
# 2. Get local version
LOCAL_VER=$(freebsd-version -k)
Should be:
Code:
# 2. Get local version
LOCAL_VER=$(freebsd-version -u)
Because the userland patch version is ALWAYS updated.
 
Nice Alain De Vos !!

You might avoid the hardcoded release number in the $URL.
Code:
CURRENT_VER=$(uname -r | cut -d- -f1)
URL="https://raw.githubusercontent.com/freebsd/freebsd-src/refs/heads/releng/$CURRENT_VER/sys/conf/newvers.sh"

Also wget isn't part of FreeBSD we can change it for fetch:
Code:
REMOTE_DATA=$(fetch -qo - "$URL")

Otherwise I really like it and it will certainly be useful, thank you :)

I wrote the same kind of script but it works only with freebsd-update so not for PKGBase system:

PS:
Next time post it the script thread, it will be easier to find it after many years ;)
 
Back
Top