aur.sh: [h1] Import changes

master
Taeyeon Mori 7 years ago
parent cc40c69085
commit fa5fb4432a
  1. 68
      bin/aur.sh

@ -57,6 +57,7 @@ ADD_UPDATES=false
ADD_SCMPKGS=false ADD_SCMPKGS=false
RECURSE_DEPS=false RECURSE_DEPS=false
NEED_COWER=false NEED_COWER=false
NEED_ROOT=false
LIST_ONLY=false LIST_ONLY=false
IGNORE_ERRORS=false IGNORE_ERRORS=false
EXCLUDE= EXCLUDE=
@ -64,6 +65,8 @@ ASDEPS=true
NEEDED=true NEEDED=true
NOCONFIRM=true NOCONFIRM=true
USECUSTOM=true USECUSTOM=true
LOCAL_ONLY=false
NOCLEAN=false
add_makepkg_arg() { add_makepkg_arg() {
makepkg_args=("${makepkg_args[@]}" "$1") makepkg_args=("${makepkg_args[@]}" "$1")
@ -106,10 +109,14 @@ process_arg() {
DL_ONLY=true;; DL_ONLY=true;;
-a|--ask) -a|--ask)
ASK=true;; ASK=true;;
--offline)
LOCAL_ONLY=true;;
--aur-host|--exclude) # need more args --aur-host|--exclude) # need more args
_next_arg="$cx";; _next_arg="$cx";;
--no-custom) --no-custom)
USECUSTOM=false;; USECUSTOM=false;;
--noclean)
NOCLEAN=true;;
-j|--threads) -j|--threads)
_next_arg=--threads;; _next_arg=--threads;;
-1) -1)
@ -122,6 +129,7 @@ process_arg() {
-S|--recurse-deps) -S|--recurse-deps)
NEED_COWER=true NEED_COWER=true
RECURSE_DEPS=true RECURSE_DEPS=true
NEED_ROOT=true
add_makepkg_arg -i;; add_makepkg_arg -i;;
-L|--list-only) -L|--list-only)
LIST_ONLY=true;; LIST_ONLY=true;;
@ -145,6 +153,7 @@ process_arg() {
echo " Only list all affected packages" echo " Only list all affected packages"
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 " --offline Don't try to download new PKGBUILDs"
echo " -E, --ignore-errors" echo " -E, --ignore-errors"
echo " Continue with the next package even after a failure." echo " Continue with the next package even after a failure."
echo " -j, --threads [+-]<n>" echo " -j, --threads [+-]<n>"
@ -155,15 +164,18 @@ process_arg() {
echo " --exclude <pkgs>" echo " --exclude <pkgs>"
echo " Exclude packages from -u" echo " Exclude packages from -u"
echo " --no-custom Don't use custom packages from $CUSTOMDIR" echo " --no-custom Don't use custom packages from $CUSTOMDIR"
echo " --noclean Don't clean up temporary build directory when done."
echo
echo " --clean Clean up leaftover temporary files (of previous (failed) builds) and exit"
echo
echo "AUR backend options:"
echo " --aur-host <url>" echo " --aur-host <url>"
echo " Use a different AUR server. default: https://aur.archlinux.org/" echo " Use a different AUR server. default: https://aur.archlinux.org/"
echo " --old-aur Use the old (non-git) AUR methods" echo " --old-aur Use the old (non-git) AUR methods"
echo echo
echo " --clean Clean up leaftover temporary files (of failed builds) and exit"
echo
echo "Makepkg/Pacman options:" echo "Makepkg/Pacman options:"
echo " -i Install package after building it" echo " -i Install package after building it (requires superuser)"
echo " -s Install dependencies from official repos" echo " -s Install dependencies from official repos (requires superuser)"
echo " --pkg <list> Only build selected packages (when working with split packages)" echo " --pkg <list> Only build selected packages (when working with split packages)"
echo " --no-asdeps, --asexplicit" echo " --no-asdeps, --asexplicit"
echo " Don't pass --asdeps to pacman" echo " Don't pass --asdeps to pacman"
@ -171,6 +183,7 @@ process_arg() {
echo " Don't pass --needed to pacman" echo " Don't pass --needed to pacman"
echo " --no-noconfirm" echo " --no-noconfirm"
echo " Don't pass --noconfirm to makepkg/pacman" echo " Don't pass --noconfirm to makepkg/pacman"
echo " -o, --nobuild Download and extract sources only. Implies --noclean"
echo echo
echo "NOTE: options marked [c] require cower to be installed (\$ aur.sh -is cower)" echo "NOTE: options marked [c] require cower to be installed (\$ aur.sh -is cower)"
echo " However, certain cower-only features are automatically enabled when cower is found." echo " However, certain cower-only features are automatically enabled when cower is found."
@ -203,6 +216,12 @@ process_arg() {
--no-noconfirm) --no-noconfirm)
NOCONFIRM=false;; NOCONFIRM=false;;
# Makepkg args # Makepkg args
-o|--nobuild) # Remember some stuff for own use
NOCLEAN=true
add_makepkg_arg "$cx";;
-i|--install|-s|--syncdeps)
NEED_ROOT=true
add_makepkg_arg "$cx";;
--pkg|--key|--config|-p) # These take an additional value --pkg|--key|--config|-p) # These take an additional value
_proxy_args=1 _proxy_args=1
add_makepkg_arg "$cx";; add_makepkg_arg "$cx";;
@ -411,7 +430,7 @@ fetch_package() {
warn "[AUR] $p: Found #CUSTOMPKG; not updating PKGBUILD from AUR!" \ warn "[AUR] $p: Found #CUSTOMPKG; not updating PKGBUILD from AUR!" \
} || \ } || \
$aur_get "$p" || \ $aur_get "$p" || \
{ pkg_failed "$p" 2 "[AUR] $p: Couldn't download package!"; return $? } warn "[AUR] $p: Couldn't download PKGBUILD from aur!"
PKG_INFO[$p:From]="$AURDEST/$p" PKG_INFO[$p:From]="$AURDEST/$p"
fi fi
@ -424,9 +443,6 @@ build_package() {
cp -Lr "$PKG_INFO[$p:From]" "$build/$p" cp -Lr "$PKG_INFO[$p:From]" "$build/$p"
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_args[@]}" || \ makepkg "${makepkg_args[@]}" || \
@ -532,14 +548,29 @@ if $ASK; then
fi fi
# Fetch packages -------------------------- # Fetch packages --------------------------
if ! $LOCAL_ONLY; then
for p in "${AFFECTED_PKGS[@]}"; do for p in "${AFFECTED_PKGS[@]}"; do
fetch_package "$p" fetch_package "$p"
done done
elif $DL_ONLY; then
warn "[AUR] --offline and --download-only both given. Doing nothing. (Like --list-only)"
fi
if $DL_ONLY; then if $DL_ONLY; then
clean_exit clean_exit
fi fi
# Add PKGBUILDs from cache
for p in "${AFFECTED_PKGS[@]}"; do
if [ -z "$PKG_INFO[$p:From]" ]; then
if [ -d "$AURDEST/$p" ]; then
PKG_INFO[$p:From]="$AURDEST/$p"
else
pkg_failed "$p" 2 "[AUR] $p: Could not find PKGBUILD anywhere"
fi
fi
done
if (( ${#FAILED_PKGS} )); then if (( ${#FAILED_PKGS} )); then
warn "[AUR]: Failed to fetch packages (${#FAILED_PKGS}): ${FAILED_PKGS[*]}" warn "[AUR]: Failed to fetch packages (${#FAILED_PKGS}): ${FAILED_PKGS[*]}"
AFFECTED_PKGS=(${AFFECTED_PKGS:|${FAILED_PKGS[@]}}) AFFECTED_PKGS=(${AFFECTED_PKGS:|${FAILED_PKGS[@]}})
@ -553,6 +584,7 @@ test -d "$build" || mkdir -p "$build" || throw 1 "Couldn't create build director
clean_exit() { clean_exit() {
rm "$build/aur.sh.running" 2>/dev/null || true rm "$build/aur.sh.running" 2>/dev/null || true
[ -n "$SUDO_PROC" ] && kill $SUDO_PROC
exit ${1-0} exit ${1-0}
} }
@ -563,9 +595,17 @@ touch "$build/aur.sh.running"
test "$build" = "$PWD" || \ test "$build" = "$PWD" || \
msg "[AUR] Working in $build." msg "[AUR] Working in $build."
if $NOCONFIRM; then # Sudo
if $NEED_ROOT && $NOCONFIRM; then
# Ask now
msg "[AUR] Updating sudo timestamp" msg "[AUR] Updating sudo timestamp"
sudo -v sudo -v
# Keep up
while true; do
sleep 250
sudo -vn
done &
SUDO_PROC=$!
fi fi
msg "[AUR] Makepkg args: ${makepkg_args[*]}" msg "[AUR] Makepkg args: ${makepkg_args[*]}"
@ -586,8 +626,14 @@ msg "[AUR] All Done!"
# Remove the builddir if we previously created it. # Remove the builddir if we previously created it.
cd "$AURDEST" cd "$AURDEST"
[ "$build" = "$tmpbuild" ] && \ if [ "$build" = "$tmpbuild" ]; then
warn "[AUR] Removing temporary directory $tmpbuild" && \ if $NOCLEAN; then
msg "[AUR] Files in: $tmpbuild"
warn "[AUR] Clean up later with aur.sh --clean"
else
warn "[AUR] Removing temporary directory $tmpbuild"
rm -rf "$tmpbuild" rm -rf "$tmpbuild"
fi
fi
clean_exit clean_exit

Loading…
Cancel
Save