Update aur script

master
Taeyeon Mori 9 years ago
parent 98f6e01dee
commit b938c60bcf
  1. 59
      bin/aur.sh
  2. 8
      lib/libsh-utils.sh

@ -16,13 +16,26 @@ tmpbuild=${TMPDIR-/tmp}/aur.sh.$$
build="${BUILDDIR:-$tmpbuild}" build="${BUILDDIR:-$tmpbuild}"
test -d "$build" || mkdir -p "$build" || exit 1 test -d "$build" || mkdir -p "$build" || exit 1
# Parse commandline: anything prefixed with - is a makepkg option # ------------------------------------------------------------------------------
# Parse commandline: anything prefixed with - is a makepkg option, others are package names
packages=() packages=()
flags=() makepkg_args=()
aur_get=aur_get_aur4 # new one not working yet
aur_get=aur_get_aur4
DL_ONLY=false DL_ONLY=false
ASK=false
add_makepkg_arg() {
makepkg_args=("${makepkg_args[@]}" "$1")
}
_proxy_args=0
for cx in "$@"; do for cx in "$@"; do
if [ $_proxy_args -gt 0 ]; then
add_makepkg_arg "$cx"
_proxy_args=$[$_proxy_args - 1]
continue
fi
case "$cx" in case "$cx" in
--old-aur) --old-aur)
warn "[AUR] Using old AUR (--old-aur)" warn "[AUR] Using old AUR (--old-aur)"
@ -30,31 +43,43 @@ for cx in "$@"; do
-X|--download-only) -X|--download-only)
warn "[AUR] Building was disabled (-X)" warn "[AUR] Building was disabled (-X)"
DL_ONLY=true;; DL_ONLY=true;;
--ask)
ASK=true;;
-h|--help) -h|--help)
echo "Usage $0 [-h] [-X] [makepkg options] <packages>" echo "Usage $0 [-h] [-X] [makepkg options] <packages>"
echo "Taeyeon's aur.sh (c) 2014-2015 Taeyeon Mori (not related to http://aur.sh)"
echo
echo "A simple AUR client realized in bash/zsh"
echo echo
echo "aur.sh options:" echo "aur.sh options:"
echo " -h, --help Display this message" echo " -h, --help Display this message"
echo " -X, --download-only" echo " -X, --download-only"
echo " Only download the PKGBUILDs from AUR, don't build" echo " Only download the PKGBUILDs from AUR, don't build"
echo " --old-aur Use the old (non-git) AUR" echo " --old-aur Use the old (non-git) AUR"
echo " --ask Ask before installing packages (removes --noconfirm)"
echo echo
echo "Useful makepkg options:" echo "Useful makepkg options:"
echo " -i Install package after building it" echo " -i Install package after building it"
echo " -s Install dependencies from official repos" echo " -s Install dependencies from official repos"
echo " --pkg <list> Only build selected packages (when working with split packages)"
exit 0 exit 0
;; ;;
--pkg|--key|--config) # These take an additional value
_proxy_args=1
add_makepkg_arg "$cx";;
-*) -*)
makepkg_flags=("${makepkg_flags[@]}" "$cx");; add_makepkg_arg "$cx";;
*) *)
packages=("${packages[@]}" "$cx");; packages=("${packages[@]}" "$cx");;
esac esac
done done
# -------------------------------------------------------------------------
# aur functions # aur functions
aur_get_old() { aur_get_old() {
[ -d "$1/.git" ] && error "Local copy of $1 is from AUR4. Cannot use --old-aur with it!" && return 32 [ -d "$1/.git" ] && err "Local copy of $1 is a Git clone from AUR v4. Don't use --old-aur with it!" && return 32
curl https://aur.archlinux.org/packages/${1:0:2}/$1/$1.tar.gz | tar xz curl "https://aur.archlinux.org/packages/${1:0:2}/$1/$1.tar.gz" | tar xz
} }
aur_get_aur4() { aur_get_aur4() {
@ -67,18 +92,27 @@ aur_get_aur4() {
ans=n ans=n
ask "Overwrite $1?" ans ask "Overwrite $1?" ans
[ "$ans" = "y" ] || [ "$ans" = "yes" ] || [ "$ans" = "Y" ] || return 32 [ "$ans" = "y" ] || [ "$ans" = "yes" ] || [ "$ans" = "Y" ] || return 32
rm -rf $1 rm -rf "$1"
fi fi
git clone https://aur4.archlinux.org/$1.git/ git clone "https://aur4.archlinux.org/$1.git/" "$1"
fi fi
} }
# ----------------------------------------------------------------------------
# Actual work starts here
# Print some info # Print some info
msg "[AUR] AURDIR=$AURDIR; PKGDEST=$PKGDEST" msg "[AUR] AURDIR=$AURDIR; PKGDEST=$PKGDEST"
test "$build" = "$PWD" || \ test "$build" = "$PWD" || \
msg "[AUR] Working in $build." msg "[AUR] Working in $build."
msg "[AUR] Building packages: $packages" msg "[AUR] Building packages: $packages"
if ! $ASK && ! $DL_ONLY; then
msg "[AUR] Updating sudo timestamp"
sudo -v
add_makepkg_arg "--noconfirm"
fi
# Process packages # Process packages
for p in "${packages[@]}"; do for p in "${packages[@]}"; do
@ -91,7 +125,7 @@ for p in "${packages[@]}"; do
grep -q "#CUSTOMPKG" $p/PKGBUILD && \ grep -q "#CUSTOMPKG" $p/PKGBUILD && \
warn "[AUR] $p: Found #CUSTOMPKG; not updating PKGBUILD from AUR!" \ warn "[AUR] $p: Found #CUSTOMPKG; not updating PKGBUILD from AUR!" \
} || \ } || \
$aur_get $p || throw 2 "[AUR] $p: Couldn't download package" $aur_get "$p" || throw 2 "[AUR] $p: Couldn't download package"
if $DL_ONLY; then continue; fi if $DL_ONLY; then continue; fi
@ -99,9 +133,12 @@ for p in "${packages[@]}"; do
cp -r "$p" "$build" cp -r "$p" "$build"
cd "$build/$p" cd "$build/$p"
# Update timestamp, but don't ask for pw if it expired
sudo -vn
# Run makepkg # Run makepkg
msg "[AUR] $p: Building..." msg "[AUR] $p: Building..."
makepkg "${makepkg_flags[@]}" || \ makepkg "${makepkg_args[@]}" || \
throw 1 "[AUR] $p: Makepkg failed!" throw 1 "[AUR] $p: Makepkg failed!"
msg "[AUR] $p: Done!" msg "[AUR] $p: Done!"
@ -111,7 +148,7 @@ msg "[AUR] All Done!"
# Remove the builddir if we previously created it. # Remove the builddir if we previously created it.
cd "$AURDEST" cd "$AURDEST"
test "$build" = "$tmpbuild" && \ [ "$build" = "$tmpbuild" ] && \
warn "[AUR] Removing temporary directory $tmpbuild" && \ warn "[AUR] Removing temporary directory $tmpbuild" && \
rm -rf "$tmpbuild" rm -rf "$tmpbuild"

@ -19,11 +19,3 @@ color() {
return $res return $res
} }
# Append to array
push() {
local arr="$1"; shift
for val in "$@"; do
eval "$arr[\${#$arr[@]}]=\"\$val\""
done
}

Loading…
Cancel
Save