Created
June 29, 2012 17:35
-
-
Save Gen2ly/3019486 to your computer and use it in GitHub Desktop.
Download package source files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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