#!/bin/bash # # pbrisbin 2010 # # aurget: A simple pacman-like interface to the AUR # # http://pbrisbin.com/pages/aurget.html # ### # script info {{{ SCRIPT_NAME='Aurget' SCRIPT_DESCRIPTION='A simple pacman-like interface to the AUR' SCRIPT_AUTHOR='Patrick Brisbin ' SCRIPT_VERSION='3.0.9' SCRIPT_DATE='8/30/2010' # }}} # script utilities {{{ display() { echo -e "${colorB}:: ${colorW}$*${nocolor}"; } warn() { echo -e "${colorY}warning: ${nocolor}$*"; } errorout() { echo -e "${colorR}error: ${nocolor}$*" [[ -d "$tmpdir" ]] && rm -r "$tmpdir" set_lock_file -r exit 1 } builderror() { local pkg="$1" src="$2" dep="$3" msg msg="notice: $pkg failed while building, remove source files ($src)" # $src must be nonzero so we don't attempt to rm -rf /* prompt "$msg" && [[ -n "$src" ]] && rm -rf "$src/"* # if it's a dep we need to errorout entirely if [[ $dep -eq 1 ]]; then errorout "dependency package $pkg failed to build. unable to continue." # otherwise, warn but continue else warn "package $pkg failed to build and won't be installed." fi } # prompt and return based on choice prompt() { local a echo -en "$*? [Y/n] " if $noconfirm; then echo 'Y' return 0 else read a fi case "${a:-y}" in y|Y) return 0 ;; q|Q) clean_exit 1 ;; *) return 1 ;; esac } # uses eval to process --option=value type arguments runtime_flag() { eval ${1/--/}; } # prints one array element per line print_array() { local x for x in "$@"; do echo $x; done } # called before sourcing config or on --nocolor set_nocolor() { # disable pacman color pacman="${pacman/pacman-color/pacman}" # disable makepkg color makepkg="$makepkg --nocolor" # disable aurget color nocolor='' colorW='' colorB='' colorR='' colorG='' colorY='' colorM='' } # set or remove our lock file set_lock_file() { local lock_file='/tmp/aurget.lock' if [[ "$1" = '-r' ]]; then if [[ -f "$lock_file" ]]; then rm "$lock_file" || errorout 'error removing lock file' fi return 0 fi if [[ -f "$lock_file" ]]; then cat << EOF $lock_file exists. if you're certain that no other aurget process is running, remove this file and try again. EOF exit 1 fi touch "$lock_file" || errorout 'error setting lock file' } # clear our temp dir clear_temp() { tmpdir='/tmp/aurget' [[ -d "$tmpdir" ]] && rm -r "$tmpdir" mkdir -p "$tmpdir" } # }}} # message {{{ message() { echo 'usage: aurget [ -v | -h | -S* [ --options ] [ -- ] ]' echo echo ' options:' echo echo ' -S process using your default sync_mode' echo echo ' -Sd download ' echo ' -Sb download and build ' echo ' -Sy download, build, and install ' echo echo ' -Su process available upgrades using your default sync_mode' echo echo ' -Sdu download available upgrades' echo ' -Sbu download and build available upgrades' echo ' -Syu download, build, and install available upgrades' echo echo ' -Ss search aur for ' echo ' -Ssq search aur for , print only package names' echo ' -Sp print the PKGBUILD for ' echo ' -Si print extended info for ' echo echo ' --devel used with -Su to upgrade all development packages' echo echo ' --deps resolve dependencies' echo ' --nodeps don'\''t resolve dependencies' echo echo ' --edit prompt to edit all pkgbuilds' echo ' --noedit don'\''t prompt to edit any pkgbuilds' echo echo ' --discard discard source files after building' echo ' --nodiscard don'\''t discard source files after building' echo echo ' --nocolor disable colorized output' echo ' --noconfirm auto-answer y to all prompts' echo echo ' --ignore '\'' <...>'\''' echo ' add additional packages to be ignored' echo echo ' --mopt '\''-opt -opt ...'\''' echo ' add additional options to the build command' echo echo ' --popt '\''-opt -opt ...'\''' echo ' add additional options to the install command' echo echo ' -v, --version display version info' echo ' -h, --help display this' echo echo ' --option=value set config