Am 16.10.2015 um 05:41 schrieb Mihai Moldovan:
On 16.10.2015 05:36 AM, Mike Gabriel wrote:
outside of a Debian system/chroot, this is not possible, I fear. At
least, I don't have an enlighting idea at the moment where to obtain
those mappings. Inside a chroot, the mapping could be obtained from
/etc/os-release. Yes, but that's probably not possible/practical.Is there a variable that will be substituted automatically by dh (or any other build utility) that maps to the major version number of the "affected" Debian version number? That was my best guess, but I fear there's none and I have to hardcode a list within the build scripts.
Assuming the system you are working on has Internet access ;-) - you could take the following script and name it codename2major:
#!/bin/bash # (c) 2015 Stefan Baur, x2go-ml-1@baur-itcs.de # Released into Public Domain
RELNAME=$1 LOOKUPTABLE='/SOMESTORAGEPLACE/codename2major' touch "$LOOKUPTABLE" RELMAJOR=$(awk '$1 == '$RELNAME' { print $2 }' "$LOOKUPTABLE")
if [ -z "$RELMAJOR" ] ; then
if wget -q -O /dev/null
ftp://ftp.debian.org/debian/dists/$RELNAME ; then # $RELNAME is a currently supported release RELMAJOR=$( wget -q -O - ftp://ftp.debian.org/debian/dists/$RELNAME/Release | awk -F '[ .]' '$1 == "Version:" { print $2 }' ) echo "$RELNAME $RELMAJOR" >> "$LOOKUPTABLE" elif wget -q -O /dev/null http://archive.debian.org/debian/dists/$RELNAME ; then # $RELNAME is an archived release RELMAJOR=$( wget -q -O - http://archive.debian.org/debian/dists/$RELNAME/Release | awk -F '[ .]' '$1 == "Version:" { print $2 }' ) echo "$RELNAME $RELMAJOR" >> "$LOOKUPTABLE" else # $RELNAME is unknown exit 1 fi fi
if [ -z "$RELMAJOR" ] ; then # unknown error exit 1 else echo "$RELMAJOR" exit 0 fi
Running this as codename2major RELEASENAME will return the major number of the matching release. It will first try to look up the name in a local cache file; if it can't find it there, it will query the current debian repo, and, if it can't find it there either, the debian archive repo. Assuming it finds a match, it will log the result into the cache file in each case. If it can't find a match anywhere, or if it can retrieve a release file, but fails at parsing it, it will exit with an error code of 1.
-Stefan
-- BAUR-ITCS UG (haftungsbeschränkt) Geschäftsführer: Stefan Baur Eichenäckerweg 10, 89081 Ulm | Registergericht Ulm, HRB 724364 Fon/Fax 0731 40 34 66-36/-35 | USt-IdNr.: DE268653243