#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;
#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;
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 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" `
version=`wget -q -O - "http://
#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! ftp.debian. org/debian/ pool/main/ $first/ $1/$1_$ version. dsc"
first=`echo $1 | cut -c 1`
dget "http://
exit 0
Instead of ftp.debian.org one can use his preferred mirror of course.