programmatic way to determine if there is a new release
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2008
    Posts
    4
    Mac OS X 10.13 Firefox 60.0

    programmatic way to determine if there is a new release

    hi,

    looking to determine if there is a way i can programmatically determine if there is a new release available.

    for check for patches - i can use dnf check-update, a return code of 100 indicates there are patches available for the system.
    I have tried messing with dnf, for the upgrade, thinking along the lines of dnf --releasever=(x+1) list, but this work for 29 as well and 29 is not available as a "general" release.

    something like latest-prod-release.fedora.org that returned (at the moment) 28 would be perfect

    thanks
    c

  2. #2
    Join Date
    Jun 2004
    Location
    Maryland, US
    Posts
    7,421
    Linux (Fedora) Firefox 61.0

    Re: programmatic way to determine if there is a new release

    Quote Originally Posted by the_c
    hi,

    looking to determine if there is a way i can programmatically determine if there is a new release available.

    for check for patches - i can use dnf check-update, a return code of 100 indicates there are patches available for the system.
    I have tried messing with dnf, for the upgrade, thinking along the lines of dnf --releasever=(x+1) list, but this work for 29 as well and 29 is not available as a "general" release.

    something like latest-prod-release.fedora.org that returned (at the moment) 28 would be perfect

    thanks
    c
    I'd think you could use

    wget -O - https://download.fedoraproject.org/p...linux/releases

    which would dump to standard out, then parse that for each line:
    Code:
    --2018-06-29 00:27:58--  https://download.fedoraproject.org/pub/fedora/linux//releases/
    Resolving download.fedoraproject.org (download.fedoraproject.org)... 209.132.190.2, 140.211.169.206, 140.211.169.196, ...
    Connecting to download.fedoraproject.org (download.fedoraproject.org)|209.132.190.2|:443... connected.
    HTTP request sent, awaiting response... 302 Found
    Location: http://mirror.math.princeton.edu/pub/fedora/linux/releases/ [following]
    --2018-06-29 00:27:58--  http://mirror.math.princeton.edu/pub/fedora/linux/releases/
    Resolving mirror.math.princeton.edu (mirror.math.princeton.edu)... 128.112.18.21
    Connecting to mirror.math.princeton.edu (mirror.math.princeton.edu)|128.112.18.21|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 4999 (4.9K) [text/html]
    Saving to: ‘STDOUT’
    
    -                                       0%[                                                                         ]       0  --.-KB/s               <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <html>
     <head>
      <title>Index of /pub/fedora/linux/releases</title>
     </head>
     <body>
    <h1>Index of /pub/fedora/linux/releases</h1>
      <table>
       <tr><th valign="top"><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>
       <tr><th colspan="5"><hr></th></tr>
    <tr><td valign="top"><img src="/icons/back.gif" alt="[PARENTDIR]"></td><td><a href="/pub/fedora/linux/">Parent Directory</a></td><td>&nbsp;</td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="7/">7/</a></td><td align="right">2016-05-20 23:28  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="8/">8/</a></td><td align="right">2016-05-20 22:12  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="9/">9/</a></td><td align="right">2013-04-25 04:48  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="10/">10/</a></td><td align="right">2013-04-25 04:48  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="11/">11/</a></td><td align="right">2013-04-25 04:48  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="12/">12/</a></td><td align="right">2013-04-25 04:48  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="13/">13/</a></td><td align="right">2013-04-25 04:48  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="14/">14/</a></td><td align="right">2013-04-25 04:48  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="15/">15/</a></td><td align="right">2013-09-05 15:09  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="16/">16/</a></td><td align="right">2013-09-05 15:20  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="17/">17/</a></td><td align="right">2013-09-05 15:25  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="18/">18/</a></td><td align="right">2015-02-23 19:45  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="19/">19/</a></td><td align="right">2015-02-23 19:57  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="20/">20/</a></td><td align="right">2015-07-16 13:32  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="21/">21/</a></td><td align="right">2016-05-17 16:38  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="22/">22/</a></td><td align="right">2017-09-21 13:00  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="23/">23/</a></td><td align="right">2017-09-21 13:27  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="24/">24/</a></td><td align="right">2017-09-22 13:36  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="25/">25/</a></td><td align="right">2016-11-18 09:41  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="26/">26/</a></td><td align="right">2017-07-07 12:03  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="27/">27/</a></td><td align="right">2017-11-10 16:20  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="28/">28/</a></td><td align="right">2018-04-27 10:46  </td><td align="right">  - </td><td>&nbsp;</td></tr>
    <tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="test/">test/</a></td><td align="right">2018-04-03 13:44  </td><td align="right">  - </td><td>&nbsp;</td></tr>
       <tr><th colspan="5"><hr></th></tr>
    </table>
    </body></html>
    to grab the number ## in each "href="##/"
    When you see a new larger number for ##, then there's a new release

  3. #3
    Join Date
    Nov 2008
    Posts
    4
    Mac OS X 10.13 Firefox 60.0

    Re: programmatic way to determine if there is a new release

    this is pretty good - and perhaps workable - the major issue seems to be that it goes to a "random" mirror each time the link it followed, and thus unexpected things may occurs on each different mirror site, making it hard to code for every eventuality.

    but thanks
    c

  4. #4
    PabloTwo's Avatar
    PabloTwo is offline "Registered User" T-Shirt Winner
    Join Date
    Mar 2007
    Location
    Seville, FL
    Posts
    7,836
    Linux Chrome 67.0.3396.99

    Re: programmatic way to determine if there is a new release

    How about a fixed url that doesn't change. Taking the baseurl from the fedora.repo file

    Code:
    http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
    and modifying it to

    Code:
    http://download.fedoraproject.org/pub/fedora/linux/releases/28/Everything/x86_64/os/
    gives me a valid url I can go to. It exists because it is the current Fedora release. Changing the "28" to "29" would result in a non accessible url, until the very day F29 had it's official release. Just a thought.

  5. #5
    Join Date
    Oct 2011
    Posts
    1,899
    Linux Chrome 66.0.3359.170

    Re: programmatic way to determine if there is a new release

    hmm URLs of a type http://download.fedoraproject.org/pu...linux/releases gets redirected to a mirror for me. I know it used to point to a Fedora server, but that seems to not be the case anymore.

    So you don't want rawhide nor beta release. You want to know when is a new stable release available.

    You could hack something together, but that is not guarantied to work in the future. I think your best bet would be to ask on IRC channel #fedora-admin. Maybe there is an easy and most importantly a reliable solution.

  6. #6
    Join Date
    Jun 2004
    Location
    Maryland, US
    Posts
    7,421
    Linux (Fedora) Firefox 60.0

    Re: programmatic way to determine if there is a new release

    Quote Originally Posted by srakitnican
    hmm URLs of a type http://download.fedoraproject.org/pu...linux/releases gets redirected to a mirror for me. I know it used to point to a Fedora server, but that seems to not be the case anymore. So you don't want rawhide nor beta release. You want to know when is a new stable release available. You could hack something together, but that is not guarantied to work in the future. I think your best bet would be to ask on IRC channel #fedora-admin. Maybe there is an easy and most importantly a reliable solution.
    This simply tests if the release directory exists that shows there's a release, this should work even if there are slight coding differences in a mirror. The URL goes all the way down to the releases/$ver/Everything/x86_64/os dir because sometimes I've seen them put an empty placeholder directory in some repos even before a release is out. The "man wget" says that --spider: "When invoked with this option, Wget will behave as a Web spider, which means that it will not download the pages, just check that they are there"
    Code:
    #!/bin/bash
    
    ver=28
    # we know that version "ver" exists
    newest=$ver
    rc=0
    until [[ "$rc" -eq 8 ]];
    do
         ((ver+=1))
         wget -q --spider https://download.fedoraproject.org/pub/fedora/linux/releases/$ver/Everything/x86_64/os
         rc="$?"
         if [ "$rc" -eq 0 ]; then
            newest="$ver"
         elif [ "$rc" -eq 8 ]; then
            echo "Version $ver missing, latest release is $newest"
         else
            echo "Other error $rc"
         fi
    done
    Last edited by marko; 30th June 2018 at 08:37 PM.

  7. #7
    Join Date
    Dec 2013
    Location
    United Kingdom
    Posts
    6,610
    Linux Firefox 61.0

    Re: programmatic way to determine if there is a new release

    why do you need a program to check for something that happens around every 6 months? subscribe to the announce mailing list and you will get notifications of all new releases and any other major developments related to fedora in your email inbox

    https://lists.fedoraproject.org/admi...raproject.org/

  8. #8
    PabloTwo's Avatar
    PabloTwo is offline "Registered User" T-Shirt Winner
    Join Date
    Mar 2007
    Location
    Seville, FL
    Posts
    7,836
    Linux (Android 5.0) Chrome 67.0.3396.87

    Re: programmatic way to determine if there is a new release

    Quote Originally Posted by antikythera
    why do you need a program to check for something that happens around every 6 months? subscribe to the announce mailing list and you will get notifications of all new releases and any other major developments related to fedora in your email inbox

    https://lists.fedoraproject.org/admi...raproject.org/
    Plus one to that. I was tempted earlier to make just such a comment. But I do understand the desire to do something even if it's not very practical, just to see if you can do it.
    Last edited by PabloTwo; 30th June 2018 at 10:20 PM.

Similar Threads

  1. Replies: 7
    Last Post: 21st July 2009, 03:59 AM
  2. Upgrading from pre-release (alpha, beta, snapshot, preview etc) to the final release
    By RahulSundaram in forum Alpha, Beta & Snapshots Discussions (Fedora 11 Only)
    Replies: 4
    Last Post: 23rd April 2009, 01:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •