Skip to content

Instantly share code, notes, and snippets.

@graysky2
Created August 14, 2014 22:01
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 graysky2/123a92d045bb02ce7634 to your computer and use it in GitHub Desktop.
Save graysky2/123a92d045bb02ce7634 to your computer and use it in GitHub Desktop.
getpkg function draft
# Optionally define a work directory.
work=/scratch
# Uncomment to end trunk. If left commented, end in the official repos.
favor=testing
getpkg() {
$(which svn >/dev/null)
[[ $? -ne 0 ]] && echo "I require subversion to operate." && return 1
[[ -z "$work" ]] && work=$(pwd)
if [[ -z "$1" ]]; then
echo "Supply a package name and try again."
return 1
else
[[ -d "$work/packages/$1" ]] && rm -rf "$work/packages/$1"
svn checkout --depth=empty svn://svn.archlinux.org/packages "$work/packages"
svn update "$work/packages/$1" &>/dev/null
if [[ -d "$work/packages/$1" ]]; then
svn update "$work/packages/$1"
cd "$work/packages/$1"
else
svn checkout --depth=empty svn://svn.archlinux.org/community "$work/community"
svn update "$work/community/$1"
if [[ -d "$work/community/$1" ]]; then
svn update "$work/community/$1" &>/dev/null
cd "$work/community/$1"
else
echo "Could not find $1 in the official repos."
return 1
fi
fi
fi
if [[ "$favor" = "testing" ]]; then
cd trunk
return 0
else
for i in core-x86_64 extra-x86_64 community-x86_64; do
[[ -d repos/$i ]] && cd repos/$i
done
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment