Ask Your Question
2

How do I detect from the command line that a new Fedora release is available?

asked 2018-12-03 11:31:40 -0600

jik gravatar image

updated 2018-12-05 10:41:39 -0600

I want to put code in a shell script to check if there is a new Fedora release available.

On Ubuntu, I can accomplish this with do-release-upgrade -c. Despite quite a bit of searching, I can't figure out what the equivalent would be for Fedora.

Can anyone advise?

UPDATE: Here's what I ended up doing:

def fedora_release_checker():
    try:
        os_release = open('/etc/os-release', 'r')
    except Exception:
        log.exception('Could not open /etc/os-release')
        return 'unknown'

    try:
        version_id_line = next(
            l for l in os_release if l.startswith('VERSION_ID=')).strip()
    except StopIteration:
        log.error('Could not find VERSION_ID= line in /etc/os-release')
        return 'unknown'

    try:
        current_version_number = int(version_id_line[11:])
    except Exception:
        log.error('Could not parse {} in /etc/os-release'.format(
            version_id_line))
        return 'unknown'

    next_version_number = current_version_number + 1

    try:
        subprocess.check_output(
            ('osinfo-query', 'os', 'short-id=fedora{}'.format(
                current_version_number)),
            stderr=subprocess.STDOUT).decode('utf8')
    except Exception:
        log.exception('Could not query current release with osinfo-query')
        return 'unknown'

    try:
        subprocess.check_output(
            ('osinfo-query', 'os', 'short-id=fedora{}'.format(
                next_version_number)),
            stderr=subprocess.STDOUT).decode('utf8')
    except subprocess.CalledProcessError:
        return False
    except Exception:
        log.exception('Error querying next release with osinfo-query')
        return 'unknown'
    else:
        return True
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
2

answered 2018-12-03 23:57:11 -0600

florian gravatar image

updated 2018-12-04 00:06:47 -0600

Another option is to use the osinfo-querycommand instead of looking at the potential release announcement on fedoramagazine.org.

You could use something like

LC_ALL=C osinfo-query --fields=short-id,version os vendor="Fedora Project"

in @fcomida 's script.

It could look like this:

echo "This script works best when the package osinfo-db is up-to-date"
CURRENT_VERSION=$(cat /etc/fedora-release | awk '{ print $3 }')
let NEXT_VERSION=$(expr $CURRENT_VERSION + 1)
IS_NEXT_VERSION_AVAILABLE=$(LC_ALL=C osinfo-query --fields=version os vendor="Fedora Project" | grep $(expr $CURRENT_VERSION + 1)) 
if [ -z "$IS_NEXT_VERSION_AVAILABLE" ]; then
    echo "No new version has yet been released."
else
    echo "THERE IS A NEW VERSION!!!"
fi
edit flag offensive delete link more
2

answered 2018-12-03 14:50:49 -0600

fcomida gravatar image

Then you have to be creative. Something like this:

CURRENT_VERSION=$(cat /etc/fedora-release | awk '{ print $3 }')
let NEXT_VERSION=$(expr $CURRENT_VERSION + 1)
IS_NEXT_VERSION_AVAILABLE=$(LC_ALL=C wget --spider https://fedoramagazine.org/announcing-fedora-$NEXT_VERSION/ 2>&1 | grep "^Remote file exists")
if [ -z "$IS_NEXT_VERSION_AVAILABLE" ]; then
    echo "No new version has yet been released."
else
    echo "THERE IS A NEW VERSION!!!"
fi
edit flag offensive delete link more

Comments

very creative; nice and functional!

florian gravatar imageflorian ( 2018-12-03 23:37:48 -0600 )edit
1

answered 2018-12-05 04:57:17 -0600

johanh gravatar image

updated 2018-12-05 05:20:29 -0600

Previous examples are good ideas. Here is another variant. This one checks that the actual repository is available.

#!/bin/bash
source <(grep VERSION_ID /etc/os-release)
let releasever=$(expr $VERSION_ID + 1)
basearch=$(uname -i)
source <(grep baseurl <(grep -A10 '\[fedora\]' /etc/yum.repos.d/fedora.repo)|sed -e 's/^#//' -e 's/=/="/' -e 's/$/"/')
if curl --output /dev/null --silent --head --fail "$baseurl"; then
    echo "THERE IS A NEW VERSION!!!"
else
    echo "No new version has yet been released."
fi
edit flag offensive delete link more

Comments

But isn't the problem with this approach that the repo exists before the release (during alpha and beta phase)? As far as I can imagine those repos are created when a release is branched from rawhide, no? (see https://fedoraproject.org/wiki/Releas...)

florian gravatar imageflorian ( 2018-12-05 09:16:06 -0600 )edit

You are correct that the repo may exist before the official announcement, but not until maybe a few days or so before the public release. The version under development is more likely to exist under a "development" directory, e.g. like https://download.fedoraproject.org/pu.... If you check the "releases" directory, e.g. https://download.fedoraproject.org/pu..., you will find that the 29 directory was created around 2018-10-26, whereas Fedora 29 was released 2018-10-30. Don't quote me on all of this, though, I'm not a Fedora developer.

johanh gravatar imagejohanh ( 2018-12-05 15:15:14 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-12-03 11:31:40 -0600

Seen: 116 times

Last updated: Dec 05