How to name distinct Debian releases

It is easy to name and remember distinct Debian releases as you can always examine these on Debian Releases web page. I will do something more interesting and demonstrate you how to do that using simple shell script.

Simple shell script to demonstrate the idea of using mirror network to download and then 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 scipt 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 distributuions
if curl --output /dev/null --silent --head --fail  ${server}/debian/dists/oldoldstable/Releasce; 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

That is all.

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system.

Gdansk, Poland https://sleeplessbeastie.eu