Skip to content

Instantly share code, notes, and snippets.

@Gen2ly
Created June 29, 2012 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gen2ly/3019486 to your computer and use it in GitHub Desktop.
Save Gen2ly/3019486 to your computer and use it in GitHub Desktop.
Download package source files
#!/bin/bash
# Download package source files
# Download directories for source files (official and for the AUR) are defined
# /etc/abs.conf and in the cower config respectively
# Required program(s)
req_progs=(abs cower)
for p in ${req_progs[@]}; do
hash "$p" 2>&- || \
{ echo >&2 " Required program \"$p\" not installed."; exit 1; }
done
# Display usage if no parameters given
if [[ -z "$@" ]]; then
echo " ${0##*/} <repository/package> - download official/AUR package source files"
exit
fi
off_repos="$(grep ^REPOS /etc/abs.conf | sed -e 's/REPOS=(//' -e 's/!//g' -e \
's/ /\n /g' -e 's/^/ /')"
ofr_cases="$(grep ^REPOS /etc/abs.conf | sed -e 's/REPOS=(//' -e 's/!//g' -e \
's/ /\/* | /g' | perl -p -e 's/\n/\/*/')"
eval "case \$1 in
aur* ) cower -d "${1#*/}" ;;
$ofr_cases ) abs "$1" ;;
* ) printf ' Unknown repository:\n$off_repos\n' ;;
esac"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment