Dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.7 KiB

10 years ago
#!/bin/zsh
# vim: ft=sh:ts=2:sw=2:et
# Load libraries and configuraion
source "$DOTFILES/lib/libzsh-utils.zsh"
10 years ago
source "$DOTFILES/etc/aur.conf"
function throw {
err "$2"
exit $1
}
# Figure out build directory
tmpbuild=${TMPDIR-/tmp}/aur.sh.$$
10 years ago
build="${BUILDDIR:-$tmpbuild}"
test -d "$build" || mkdir -p "$build" || exit 1
# Parse commandline: anything prefixed with - is a makepkg option
10 years ago
packages=(${@##-*})
makepkg_flags=(${@##[^\-]*})
if echo "${makepkg_flags[*]}" | grep -q "\\-X"; then
warn "[AUR] Building was disabled (-X)"
DL_ONLY=true
else
DL_ONLY=false
fi
# Print some info
10 years ago
msg "[AUR] AURDIR=$AURDIR; PKGDEST=$PKGDEST"
test "$build" = "$PWD" || \
msg "[AUR] Working in $build."
msg "[AUR] Building packages: $packages"
# Process packages
10 years ago
for p in "${packages[@]}"; do
# First, download the PKGBUILD from AUR, to $AURDEST
cd "$AURDEST"
10 years ago
msg "[AUR] $p: Getting PKGBUILD"
{
test -d $p && \
test -f $p/PKGBUILD && \
grep -q "#CUSTOMPKG" $p/PKGBUILD && \
warn "[AUR] $p: Found #CUSTOMPKG; not updating PKGBUILD from AUR!" \
} || \
{ curl https://aur.archlinux.org/packages/${p:0:2}/$p/$p.tar.gz | tar xz } || \
throw 2 "[AUR] $p: Couldn't download package"
if $DL_ONLY; then continue; fi
# Copy it to the build directory $build and change there
cp -r "$p" "$build"
cd "$build/$p"
10 years ago
# Run makepkg
10 years ago
msg "[AUR] $p: Building..."
makepkg "${makepkg_flags[@]}" || \
throw 1 "[AUR] $p: Makepkg failed!"
msg "[AUR] $p: Done!"
done
msg "[AUR] All Done!"
# Remove the builddir if we previously created it.
cd "$AURDEST"
10 years ago
test "$build" = "$tmpbuild" && \
warn "[AUR] Removing temporary directory $tmpbuild" && \
rm -rf "$tmpbuild"