misc_debian_download() { local deb_name="$name" local dir_version="$version" local repo='main' local orig_ext='tar.gz' local dlorig=true local updver=true local OPTIND=1 local opt while getopts 'n:v:r:e:OV' opt; do case "$opt" in n) local deb_name="$OPTARG" ;; v) local dir_version="$OPTARG" ;; r) local repo="$OPTARG" ;; e) local orig_ext="$OPTARG" ;; O) local dlorig=false ;; V) local updver=false ;; esac; done shift $(expr $OPTIND - 1) [ "$1" = '--' ] && shift || true # Get the short name case "$deb_name" in lib*) local short_name="$(echo "$deb_name" | cut -c -4)" ;; *) local short_name="$(echo "$deb_name" | cut -c 1)" ;; esac # Append deb version to the regular version, keep the orig_version around. if [ "$updver" = true ]; then orig_version="$version" version="$orig_version-$1" else local orig_version="$version" local version="$orig_version-$1" fi # Set the proper update_url update_url="http://http.debian.net/debian/pool/$repo/$short_name/$deb_name/" # Download debian archive download "http://http.debian.net/debian/pool/$repo/$short_name/$deb_name/${deb_name}_$version.debian.tar.xz" \ "$2" # Download orig archive if [ "$dlorig" = true ]; then dlextract "http://http.debian.net/debian/pool/$repo/$short_name/$deb_name/${deb_name}_$orig_version.orig.$orig_ext" \ "$3" # Prepare the source directory if [ "$download_only" = false ]; then mv "$deb_name-$dir_version" "$deb_name-$version" ( cd "$deb_name-$version" extract "${deb_name}_$version.debian.tar.xz" ) fi fi } misc_debian_patch() { egrep -v '^#' debian/patches/series | xargs -I% patch -p1 -i debian/patches/% } misc_debian_patch_exclude() { fgrep -vx "$1" debian/patches/series > debian/patches/series.new mv debian/patches/series.new debian/patches/series }