It is easy to get names of distinct Debian releases as you can always examine these on the Debian Releases web page. I will do something more interesting and demonstrate how to do that using a simple shell script.
The following shell script will demonstrate the idea of using a mirror network to download and parse distribution-specific Release
file.
#!/bin/sh # Download distribution specific release file # Associate distribution with codename # Simplest possible solution without error checking # define Debian mirror server="http://ftp.pl.debian.org"; # define codenames distributions="stable unstable testing oldstable oldoldstable" # define mirror server="http://ftp.hu.debian.org" for distribution in $distributions; do codename=$(curl ${server}/debian/dists/${distribution}/Release 2>/dev/null | head | awk -v FS=": " '/Codename/ {print $2}') echo "$distribution distribution codename is $codename" done
This shell script can be extended to print more information and handle the missing oldoldsatable
distribution error.
#!/bin/sh # Download distribution specific release file # Associate distribution with codename # Preferred solution # define Debian mirror server="http://ftp.pl.debian.org"; # check if ~oldoldstable~ distribution is removed from the Debian mirror network # and then define wanted distributions if curl --output /dev/null --silent --head --fail ${server}/debian/dists/oldoldstable/Release; then distributions="unstable testing stable oldstable oldoldstable" distributions_oldoldstable_is_removed=0 else distributions="unstable testing stable oldstable" distribution_oldoldstable_is_removed=1 fi # download distribution files for distribution in $distributions; do if [ ! -f release-$distribution ]; then curl -o release-$distribution --silent $server/debian/dists/$distribution/Release fi done # parse for distribution in $distributions; do #distribution is already set codename=$(awk -v FS=": " '/Codename/ {print $2}' release-$distribution) version=$(awk -v FS=": " '/Version/ {print $2}' release-$distribution) date=$(awk -v FS=": " '/Date/ {print $2}' release-$distribution | sed "s/.*,\(.*\) .* UTC/\1/") case "$distribution" in "testing") echo "The ${distribution} suite is the next generation ${codename} release" ;; "unstable") echo "The ${distribution} suite is the unstable development ${codename} release";; "stable") echo "The ${distribution} suite is the current stable ${codename} release, recent version ${version} was published on ${date}" ;; "oldstable") echo "The ${distribution} suite is the previous stable ${codename} release, latest version ${version} was published on ${date}" ;; "oldoldstable") echo "The ${distribution} suite is the previous release before last, ${codename} release, latest version ${version} was published on ${date}" ;; esac done if [ $distribution_oldoldstable_is_removed -eq 1 ]; then echo "The oldoldstable suite was not found on mirror server, please check Debian archive" fi
Sample output as of 6 March 2016
The unstable suite is the unstable development sid release The testing suite is the next generation stretch release The stable suite is the current stable jessie release, recent version 8.3 was published on 23 Jan 2016 The oldstable suite is the previous stable wheezy release, latest version 7.9 was published on 05 Sep 2015 The oldoldstable suite was not found on mirror server, please check Debian archive
This is cool.