Comment 1 for bug 289141

Revision history for this message
Cesare Tirabassi (norsetto) wrote :

A KISS version using wget/dget:

#!/bin/bash

#Check invocation
if [ -z "$1" ]; then
   name=`basename $0`
   echo "Usage: $name <package> [suite]"
   echo "Download given Debian source package from Debian archive"
   exit 1
fi;

#Escapes any + sign in the package name
arg_uri=`echo "$1" | sed -n 's/\+/%2b/p'`
if [ -z "$arg_uri" ]; then
   arg_uri="$1"
fi;

#Set suite to unstable unless given
#(most probably its worth checking if given suite is valid too)
suite="$2"
if [ -z "$suite" ]; then
   echo "Using the unstable suite"
   suite="unstable"
fi;

#Retrieve version
version=`wget -q -O - "http://qa.debian.org/madison.php?package=$arg_uri&a=source&c=&s=$suite&text=on" | sed -n "/source/s/\s*$1\s|\s*\(\S*\)\s|.*/\1/p"`

#If package do not exist in given suite, exit with error
if [ -z "$version" ]; then
   echo "Either the source package doesn't exist, or its not in the given suite"
   exit 1
fi;

#dget it!
first=`echo $1 | cut -c 1`
dget "http://ftp.debian.org/debian/pool/main/$first/$1/$1_$version.dsc"

exit 0

Instead of ftp.debian.org one can use his preferred mirror of course.