#!/bin/bash #-- make sure we know how to handle the distro # Each file needs to define a function called get_source that will # be passed the working directory and a package name, and that must # return the full absolute path to the source tree. # # A similar remove_source function must also be defined (same parameters) # that just removes everything created in the working directory for this # package. # get_source() { pwd=$(pwd) workdir="$1" pkg="$2" #-- set up the proper environment cd "$workdir" [ ! -d $pkg ] && mkdir $pkg cd $pkg #-- fetch the source package res=$(apt-get source $pkg >/dev/null 2>&1) #-- all done. as you were. and report the path. path=$(ls -d ${pkg}-[0-9].* | head -1) if [ ! -z $path ] then echo $workdir/$pkg/$path else echo "" fi cd $pwd } remove_source () { pwd=$(pwd) workdir="$1" pkg="$2" cd "$workdir" rm -rf $pkg >/dev/null 2>&1 cd $pwd }