Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
750 lines (666 sloc) 24.2 KB
#!/bin/bash
#
# pacaur: a fast workflow AUR wrapper using cower as backend
#
name="pacaur"
version="2.2.10"
#
# Default config
#
# tmpdir
tmpDir="${TMPDIR:-/tmp}/${name}tmp-$USER"
[[ -d "$tmpDir" ]] && rm -rf "$tmpDir" &>/dev/null
mkdir -p "$tmpDir"
buildDir="$tmpDir" # build directory
editor=${EDITOR:-vi} # PKGBUILD editor
color=true # enable color
clean=true # cleanup after install
fallback=true # pacman fallback
#
# Source config
#
source /etc/${name}.conf
[[ -r "$HOME/.config/${name}/config" ]] && source "$HOME/.config/${name}/config"
#
# Color
#
if $color; then
pacmanBin="pacman-color"
cower='cower --color=always'
bold=$(tput bold)
reset=$(tput sgr0)
colorR="\e[1;31m"
colorG="\e[1;32m"
colorY="\e[1;33m"
colorB="\e[1;34m"
colorM="\e[1;35m"
colorC="\e[1;36m"
colorW="\e[1;37m"
else
pacmanBin="pacman"
cower='cower'
bold=''
reset=''
colorR=''
colorG=''
colorY=''
colorB=''
colorM=''
colorC=''
colorW=''
fi
#
# Functions
#
SearchAur() {
[[ ! $quiet ]] && $cower -s $@
[[ $quiet ]] && $cower -sq --color=never $@
}
InfoAur() {
[[ $count -eq 1 ]] && $cower -i $@
[[ $count -ne 1 ]] && $cower -ii $@
}
DownloadPkgs() {
# set architecture variables
source /etc/makepkg.conf
[[ $operation && ! $upgrade ]] && aurpkgs=(${pkgs[@]})
DownloadAur ${aurpkgs[@]}
# source pkgs
for i in ${aurpkgs[@]}; do
. "$buildDir/$i/PKGBUILD"
sourcedpkgs+=($(echo -e "${depends[*]}\n${makedepends[*]}"))
done
# remove versioning
local j=0
for i in ${sourcedpkgs[@]}; do
sourcedpkgs[$j]=${i%%=*}
sourcedpkgs[$j]=${sourcedpkgs[$j]%%>*}
sourcedpkgs[$j]=${sourcedpkgs[$j]%%<*}
((j++))
done
# remove installed deps
local j=0
for i in ${sourcedpkgs[@]}; do
[[ -z $(expac -Q %n $i) ]] && depspkgs[$j]="$i"
((j++))
done
# download pkgs
[[ ${depspkgs[@]} ]] && DownloadDepsAur ${depspkgs[@]}
# return deps pkgs
if [[ ! $noconfirm && ${ignorepkgs[@]} ]]; then
local j=0
for i in ${depspkgs[@]}; do
[[ -z $(expac -S %n $i) ]] && aurdepspkgs[$j]="$i"
((j++))
done
repodepspkgs=($(cat "$tmpDir/repodepspkgs" | awk -F "\t" '{print $2}'))
fi
}
DownloadAur() {
[[ $force ]] && f="-f"
[[ $operation = download ]] && deps+=($($cower -d $f $@ -t $buildDir | tee 1>&2 >(awk -F " " '{print $2}'| sed -r "s:\x1B\[[0-9;]*[mK]::g")))
[[ ! $operation = download ]] && deps+=($($cower -d $f $@ -t $buildDir | awk -F " " '{print $2}'| sed -r "s:\x1B\[[0-9;]*[mK]::g"))
timeout ${deps[@]}
}
DownloadDepsAur() {
[[ $force ]] && f="-f"
[[ $operation = download ]] && deps+=($($cower -dd $f $@ -t $buildDir | tee 1>&2 >(awk -F " " '{print $2}'| sed -r "s:\x1B\[[0-9;]*[mK]::g")))
[[ ! $operation = download ]] && deps+=($($cower -dd $f -b $@ -t $buildDir 2>"$tmpDir/repodepspkgs" | awk -F "\t" '{print $2}'))
[[ ! $operation = download ]] && cat "$tmpDir/repodepspkgs" | awk -F "\t" '{print $3}'
timeout ${deps[@]}
}
CheckAur() {
[[ $quiet ]] && $cower -uq --color=never $@ || [[ ! $quiet ]] && $cower -u $@
}
CheckRepo() {
outofdate=($($pacmanBin -Quq $@))
if [[ -n "${outofdate[@]}" ]]; then
Qversion=($(expac -Q %v ${outofdate[@]}))
Sversion=($(expac -S -1 %v ${outofdate[@]}))
for ((i=0; i<${#outofdate[@]}; i++)); do
Qgroup[$i]=$(expac -Q -l " " '%G' ${outofdate[$i]})
done
local i=0
for j in ${outofdate[@]}; do
[[ -n "${Qgroup[$i]}" ]] && Qgroup[$i]="(${Qgroup[$i]})"
[[ ! $quiet ]] && info "${colorW}$j ${colorR}${Qversion[$i]} ${reset}-> ${colorG}${Sversion[$i]}${reset} ${colorB}${Qgroup[$i]}${reset}" || echo $j
((i++))
done
fi
}
UpgradeAur() {
info "${colorW}Starting AUR upgrade...${reset}"
aurpkgs=($($cower -u ${pkgs[@]} | tee 1>&2 >(awk -F " " '{print $2}'| sed -r "s:\x1B\[[0-9;]*[mK]::g")))
# add devel packages
if [[ $devel ]]; then
allaurpkgs=($($pacmanBin -Qmq))
Qversion=($(expac -Q %v ${allaurpkgs[@]}))
for i in ${allaurpkgs[@]}; do
DownloadPkgbuild $i &
paraexec
done
wait
for ((i=0; i<${#allaurpkgs[@]}; i++)); do
unset _darcstrunk _cvsroot _gitroot _svntrunk _bzrtrunk _hgroot
. "$tmpDir/${allaurpkgs[$i]}.PKGBUILD"
if [[ ${_darcstrunk} || ${_cvsroot} || ${_gitroot} || ${_svntrunk} || ${_bzrtrunk} || ${_hgroot} ]]; then
info "${colorW}${allaurpkgs[$i]} ${colorY}${Qversion[$i]} ${reset}"
aurdevel=("${aurdevel[@]}" "${allaurpkgs[$i]}")
fi
done
[[ ! ${aurpkgs[@]} ]] && aurpkgs=("${aurdevel[@]}") || aurpkgs=("${aurpkgs[@]}" "${aurdevel[@]}")
fi
nothingtodo ${aurpkgs[@]}
timeout ${aurpkgs[@]}
}
EditPkgs() {
if [[ $edit && ! $noedit ]]; then
for i in "$@"; do
if [[ $option ]]; then
if ! proceedY "${colorB}::${reset} Edit ${colorW}$i${reset} PKGBUILD?"; then
continue
fi
fi
[[ -e $buildDir/$i/PKGBUILD ]] && $editor $buildDir/$i/PKGBUILD && success "${colorW}$i${reset} PKGBUILD edited" || error "Could not open ${colorW}$i${reset} PKGBUILD"
done
fi
}
CleanUp() {
if [[ $clean = true ]]; then
if [[ $count -eq 1 ]]; then
cd $buildDir
for i in "$@"; do
# hack for cvs protected files
chmod -R 755 $i &>/dev/null
rm -r $i &>/dev/null && success "${colorW}$i${reset} cleaned" || warn "Could not clean ${colorW}$i${reset}"
done
fi
if [[ $count -ne 1 ]]; then
# hack for cvs protected files
chmod -R 755 $buildDir/* &>/dev/null
rm -r $buildDir/* &>/dev/null && success "Build directory cleaned" || warn "Could not clean build directory"
fi
fi
}
MakePkgs() {
# warning checks
[[ ${ignoredpkgs[@]} ]] && IgnoreChecks ${deps[@]}
nothingtodo ${deps[@]}
ReinstallChecks ${deps[@]}
OutofdateChecks ${deps[@]}
[[ $option ]] && echo -e "\n${colorY}AUR Targets (${#deps[@]}):${reset} ${deps[@]}"
[[ ! $option ]] && echo "" && info "AUR package(s) to build: ${colorW}${deps[@]}${reset}"
echo ""
if [[ ! $noconfirm ]]; then
if ! proceedY "Proceed with installation?"; then
CleanUp ${deps[@]} &>/dev/null
exit
fi
fi
EditPkgs ${deps[@]}
# reverse deps order
deps=($(echo ${deps[@]} | awk -F "\n" '{print}' | awk -F " " '{for (i=NF;i>=1;i--) print $i}'))
# makepkg options
[[ $color != true ]] && makeopts+=("--nocolor")
export PACMAN=$pacmanBin
for i in "${deps[@]}"; do
# check package cache
[[ $PKGDEST && ! $rebuild ]] && GetAurVersion $i && FindCachedPkg "$i-$Aversion"
if [[ $cachedpkg ]]; then
if [[ $installpkg ]]; then
info "Installing ${colorW}$i${reset} cached package..."
runasroot $pacmanBin -U $cachedpkg ${pacopts[@]} --noconfirm
else
info "Package ${colorW}$i${reset} already available in cache"
fi
else
# build and install
if [[ -e $buildDir/$i/PKGBUILD ]]; then
info "Building ${colorW}$i${reset} package..."
cd $buildDir/$i
[[ $installpkg ]] && makepkg -sfi ${makeopts[@]} --noconfirm || makepkg -sf ${makeopts[@]} --noconfirm
else
error "Could not open ${colorW}$i${reset} PKGBUILD"
fi
fi
# set dep status
if [[ $installpkg && ! $upgrade ]]; then
isexpl=false
for j in ${pkgs[@]}; do
[[ $j = $i ]] && isexpl=true
done
[[ $isexpl != true ]] && runasroot $pacmanBin -D $i --asdeps ${pacopts[@]} &>/dev/null
fi
[[ $installpkg ]] && [[ " ${pacopts[@]} " =~ " --asdeps " ]] && runasroot $pacmanBin -D $i --asdeps ${pacopts[@]} &>/dev/null
[[ $installpkg ]] && [[ " ${pacopts[@]} " =~ " --asexplicit " ]] && runasroot $pacmanBin -D $i --asexplicit ${pacopts[@]} &>/dev/null
done
}
CleanCache() {
# set cache variables
source /etc/makepkg.conf
if [[ $PKGDEST && $PKGDEST != '/var/cache/pacman/pkg/' ]]; then
[[ ! $aur ]] && echo ""
echo -e "${colorW}AUR cache directory:${reset} $PKGDEST"
if [[ $count -eq 1 ]]; then
echo -e "${colorW}Packages to keep:${reset}\n All locally installed packages"
if ! proceedY "Do you want to remove all other packages from AUR cache?"; then
exit
fi
echo "removing old packages from cache..."
for i in $(ls $PKGDEST | sed "s#\(.*\)-.*#\1#g" ); do
pkgname=$(echo $i | sed "s#\(.*\)-.*-.*#\1#g")
[[ $i != $(expac -Q '%n-%v' $pkgname) ]] && rm $PKGDEST/$i-*
done
else
if ! proceedN "Do you want to remove ALL files from AUR cache?"; then
echo "removing all files from AUR cache..."
rm $PKGDEST/* &>/dev/null
fi
fi
fi
}
GetAurVersion() {
Apkgver=$(grep '^pkgver' "$buildDir/$@/PKGBUILD" | cut -d '=' -f 2-)
Apkgrel=$(grep '^pkgrel' "$buildDir/$@/PKGBUILD" | cut -d '=' -f 2-)
Aversion=$Apkgver-$Apkgrel
}
FindCachedPkg() {
cachedpkg="$PKGDEST/$@-${CARCH}${PKGEXT}"
[[ ! -f "$cachedpkg" ]] && cachedpkg="$PKGDEST/$@-any${PKGEXT}"
[[ ! -f "$cachedpkg" ]] && cachedpkg=""
}
OutofdateChecks() {
for i in ${deps[@]}; do
DownloadJson $i &
paraexec
done
wait
for i in ${deps[@]}; do
[[ -n $(grep '"OutOfDate":"1"}}' "$tmpDir/$i.json") ]] && warn "$i is flagged ${colorR}out of date${reset}"
done
}
ReinstallChecks() {
for i in "${deps[@]}"; do
if [[ -n $(expac -Q %n $i) ]]; then
exist+=("$i")
fi
done
if [[ ${exist[@]} ]]; then
Qversion=($(expac -Q %v ${exist[@]}))
for ((i=0; i<${#exist[@]}; i++)); do
GetAurVersion ${exist[$i]}
[[ $(vercmp "$Aversion" "${Qversion[$i]}") -gt 0 ]] && continue || warn "${exist[$i]}-${Qversion[$i]} is up to date -- reinstalling"
done
fi
}
IgnoreChecks() {
unset deps
if [[ ! $upgrade && ! $noconfirm ]]; then
# check targets
for i in "${aurpkgs[@]}"; do
if [[ " ${ignoredpkgs[@]} " =~ " $i " ]]; then
if ! proceedY "${colorY}::${reset} $i is in IgnorePkg/IgnoreGroup. Install anyway?"; then
continue
fi
fi
deps+=("$i")
done
# check depends
for i in "${repodepspkgs[@]}"; do
if [[ " ${ignoredpkgs[@]} " =~ " $i " ]]; then
if ! proceedY "${colorY}::${reset} $i is in IgnorePkg/IgnoreGroup. Install anyway?"; then
CleanUp ${deps[@]} &>/dev/null
error "Unresolved dependency '${colorW}$i${reset}'"
fi
fi
done
for i in "${aurdepspkgs[@]}"; do
if [[ " ${ignoredpkgs[@]} " =~ " $i " ]]; then
if ! proceedY "${colorY}::${reset} $i is in IgnorePkg/IgnoreGroup. Install anyway?"; then
CleanUp ${deps[@]} &>/dev/null
error "Unresolved dependency '${colorW}$i${reset}'"
fi
fi
deps+=("$i")
done
else
# ignore upgrades
for i in "${aurpkgs[@]}"; do
if [[ " ${ignoredpkgs[@]} " =~ " $i " ]]; then
warn "${colorW}$i${reset}: ignoring package upgrade"
continue
fi
deps+=("$i")
done
fi
}
GetIgnoredPkgs() {
ignoredpkgs+=($(grep '^ *IgnorePkg' '/etc/pacman.conf' | cut -d '=' -f 2-))
[[ -e "$HOME/.config/cower/config" ]] && ignoredpkgs+=($(grep '^ *IgnorePkg' "$HOME/.config/cower/config" | cut -d '=' -f 2-))
ignoredpkgs=(${ignoredpkgs[@]//,/ })
}
GetIgnoredGrps() {
ignoredgrps+=($(grep '^ *IgnoreGroup' '/etc/pacman.conf' | cut -d '=' -f 2-))
}
DownloadPkgbuild() {
if [[ ! -f "$tmpDir/$i.PKGBUILD" ]]; then
curl -Lfs "https://aur.archlinux.org/packages/$i/PKGBUILD" > "$tmpDir/$i.PKGBUILD"
fi
}
DownloadJson() {
if [[ ! -f "$tmpDir/$i.json" ]]; then
curl -Lfs "http://aur.archlinux.org/rpc.php?type=info&arg=$i" > "$tmpDir/$i.json"
fi
}
runasroot() {
if [[ $UID -eq 0 ]]; then
"$@"
elif sudo -v &>/dev/null && sudo -l "$@" &>/dev/null; then
sudo "$@"
else
echo -n "root "
# echo hack to ensure all of the args get taken into account
su root -c "$(echo $@)"
fi
}
proceedY() {
echo -ne "$* [Y/n] "
read -n 1 yn
echo ""
case $yn in
[Yy]|[Yy]es|'') return 0;;
*) return 1;;
esac
}
proceedN() {
echo -ne "$* [y/N] "
read -n 1 ny
echo ""
case $ny in
[Nn]|[Nn]o|'') return 0;;
*) return 1;;
esac
}
paraexec() {
while (( $(jobs | wc -l) >= 10 )); do
sleep 0.1
jobs > /dev/null
done
}
nothingtodo() {
if [[ -z "$@" ]]; then
echo " there is nothing to do"
exit
fi
}
timeout(){
if [[ -z "$(echo $@ | grep -v "Couldn't resolve host name" | grep -v "no results found for")" ]]; then
exit
fi
}
error() {
echo -e "${colorR}::${reset} $1" && exit
}
success() {
echo -e "${colorG}::${reset} $1"
}
warn() {
echo -e "${colorY}::${reset} $1"
}
info() {
echo -e "${colorB}::${reset} $1"
}
usage() {
echo "usage: ${name} <operation> [options] [package(s)]"
echo "operations:"
echo " -s, --search search AUR repository for matching strings"
echo " -i, --info view package information -- pass twice for details"
echo " -d, --download download target(s) -- pass twice to download AUR dependencies"
echo " -m, --makepkg download and make target(s)"
echo " -y, --sync download, make and install target(s)"
echo " -k, --check check for AUR update(s)"
echo " -u, --update update AUR package(s)"
echo ""
echo "options:"
echo " -f, --force force operation -- can be combined with the -d flag"
echo " -e, --edit edit target PKGBUILD -- can be combined with the -d, -m, -y, -u flags"
echo " -c, --clean clean target(s) build files -- pass twice to clean the entire build directory"
echo ""
echo "pacman options:"
echo " can be used with the -S, -Ss, -Si, -Sii, -Sw, -Su, -Qu, -Sc, -Scc operations"
echo " -a, --aur only search or install packages from the AUR"
echo " -r, --repo only search or install packages from the repositories"
echo " -q, --quiet show less information for query and search"
echo " --devel consider AUR development packages upgrade"
echo " --ignore ignore a package upgrade (can be used more than once)"
echo " --noconfirm do not prompt for any confirmation"
echo " --noedit do not prompt to edit files"
echo " --rebuild always rebuild package"
echo ""
echo "general options:"
echo " -v, --version display version information"
echo " -h, --help display help information"
echo ""
exit
}
version() {
echo "$name $version"
}
#
# Argument parsing
#
[[ $1 ]] || usage
pkgs=()
count=0
while [[ $1 ]]; do
case "$1" in
'-s'|'--search') operation=search;;
'-i'|'--info') operation=info; ((count++));;
'-d'|'--download') operation=download; ((count++));;
'-m'|'--makepkg') operation=makepkg; force=true;;
'-y'|'--sync') operation=makepkg; force=true; installpkg=true;;
'-k'|'--check') operation=check;;
'-u'|'--update') operation=makepkg; upgrade=true; force=true; installpkg=true;;
'-f'|'--force') force=true;;
'-e'|'--edit') edit=true; editpkg=true;;
'-c'|'--clean') clean=true; cleanpkg=true; ((count++));;
'-q'|'--quiet') quiet=true;;
# shortcuts
'-sq') operation=search; quiet=true;;
'-ii') operation=info; count=2;;
'-dd') operation=download; count=2;;
'-df') operation=download; ((count++)); force=true;;
'-de') operation=download; ((count++)); edit=true;;
'-def'|'-dfe') operation=download; ((count++)); edit=true; force=true;;
'-ddf') operation=download; count=2; force=true;;
'-dde') operation=download; count=2; edit=true;;
'-ddef'|'-ddfe') operation=download; count=2; edit=true; force=true;;
'-me') operation=makepkg; edit=true; force=true;;
'-ye') operation=makepkg; edit=true; force=true; installpkg=true;;
'-kq') operation=check; quiet=true;;
'-ue') operation=makepkg; upgrade=true; force=true; edit=true; installpkg=true;;
'-cc') clean=true; cleanpkg=true; count=2;;
# pacman
'-S'|'--sync') option=sync; installpkg=true; force=true; edit=true;;
'-Ss'|'--search') option=search;;
'-Si'|'--info') option=info; ((count++));;
'-Sii'|'--info') option=info; count=2;;
'-Sw'|'--downloadonly') option=sync; force=true; edit=true;;
'-Qu'|'--upgrades') option=upgrades;;
'-Sc'|'--clean') option=cleancache; ((count++)); pacmanarg="$1";;
'-Scc'|'--clean') option=cleancache; count=2; pacmanarg="$1";;
'-r'|'--repo') repo='1';;
'-a'|'--aur') aur='1';;
# pacman shortcuts
'-Sa') option=sync; installpkg=true; force=true; edit=true; aur='1';;
'-Sr') option=sync; installpkg=true; force=true; edit=true; repo='1';;
'-Ssa') option=search; aur='1';;
'-Ssr') option=search; repo='1';;
'-Ssq') option=search; quiet=true;;
'-Ssqa'|'-Ssaq') option=search; quiet=true; aur='1';;
'-Ssqr'|'-Ssrq') option=search; quiet=true; repo='1';;
'-Sia') option=info; ((count++)); aur='1';;
'-Sir') option=info; ((count++)); repo='1';;
'-Siia') option=info; count=2; aur='1';;
'-Siir') option=info; count=2; repo='1';;
'-Swa') option=sync; force=true; edit=true; aur='1';;
'-Swr') option=sync; force=true; edit=true; repo='1';;
'-Qua') option=upgrades; aur='1';;
'-Qur') option=upgrades; repo='1';;
'-Quq') option=upgrades; quiet=true;;
'-Quqa') option=upgrades; quiet=true; aur='1';;
'-Quqr') option=upgrades; quiet=true; repo='1';;
-S*u*w*a|-S*w*u*a) option=sysupgrade; upgrade=true; force=true; edit=true; pacmanarg="$1"; aur='1' ;;
-S*u*w*r|-S*w*u*r) option=sysupgrade; upgrade=true; force=true; edit=true; pacmanarg="$1"; repo='1' ;;
-S*u*w*|-S*w*u*) option=sysupgrade; upgrade=true; force=true; edit=true; pacmanarg="$1" ;;
-S*u*a) option=sysupgrade; upgrade=true; force=true; edit=true; installpkg=true; pacmanarg="$1"; aur='1';;
-S*u*r) option=sysupgrade; upgrade=true; force=true; edit=true; installpkg=true; pacmanarg="$1"; repo='1';;
-S*u*|'--sysupgrade') option=sysupgrade; upgrade=true; force=true; edit=true; installpkg=true; pacmanarg="$1";;
'-Sca') option=cleancache; ((count++)); pacmanarg="$1"; aur='1';;
'-Scr') option=cleancache; ((count++)); pacmanarg="$1"; repo='1';;
'-Scca') option=cleancache; count=2; pacmanarg="$1"; aur='1';;
'-Sccr') option=cleancache; count=2; pacmanarg="$1"; repo='1';;
# others
'--devel') devel=true;;
'--asroot') makeopts+=("--asroot");;
'--ignore') ignoredpkgs+=("$2"); ignorepkgs+=("--ignore" "$2"); shift;;
'--noconfirm') noconfirm=true; pacopts+=("--noconfirm");;
'--noedit') noedit=true;;
'--rebuild') rebuild=true;;
-D* | '--database') runasroot $pacmanBin $@; exit;;
-Q* | '--query') $pacmanBin $@; exit;;
-R* | '--remove') runasroot $pacmanBin $@; exit;;
-S* | '--sync') runasroot $pacmanBin $@; exit;;
-T* | '--deptest') runasroot $pacmanBin $@; exit;;
-U* | '--upgrade') runasroot $pacmanBin $@; exit;;
'-h'|'--help') usage; exit;;
'-v'|'--version') version; exit;;
--*) pacopts+=("$1");;
-*) echo "$name: invalid option -- '$1'"; exit;;
*) pkgs+=("$1");;
esac
shift
done
#
# Main
#
Core() {
DownloadPkgs $@
MakePkgs ${deps[@]}
CleanUp ${deps[@]}
}
ClassifyPkgs() {
if [[ $fallback = true ]]; then
[[ $repo ]] && repopkgs=(${pkgs[@]})
[[ $aur ]] && aurpkgs=(${pkgs[@]})
if [[ ! $repo && ! $aur ]]; then
GetIgnoredGrps
for i in ${pkgs[@]}; do
[[ " ${ignoredgrps[@]} " =~ " $i " ]] && repopkgs+=("$i") && continue
[[ -z "$($pacmanBin -S --print $i 2>&1 | grep -v "error:")" ]] && aurpkgs+=("$i") || repopkgs+=("$i")
done
fi
else
[[ ! $aur ]] && repopkgs=(${pkgs[@]}) || aurpkgs=(${pkgs[@]})
fi
}
# sanity check
[[ ! -d $buildDir ]] && error "Build directory does not exist!\nCheck configuration in /etc/${name}.conf"
[[ ! -f /usr/bin/$pacmanBin ]] && error "The binary ${colorW}$pacmanBin${reset} is not installed.\nCheck configuration in /etc/${name}.conf"
[[ ! $operation && ! $option && ! $cleanpkg && ! $editpkg ]] && error "no operation specified (use -h for help)"
[[ $repo && $aur ]] && error "target not found"
# search (-s) handling
if [[ $operation = search ]]; then
SearchAur ${pkgs[@]}
exit
fi
# info (-i) handling
if [[ $operation = info ]]; then
InfoAur ${pkgs[@]}
exit
fi
# download (-d) handling
if [[ $operation = download ]]; then
[[ $count -eq 1 ]] && DownloadAur ${pkgs[@]}
[[ $count -ne 1 ]] && DownloadDepsAur ${pkgs[@]}
EditPkgs ${deps[@]}
exit
fi
# makepkg (-m) handling
# sync (-y) handling
# update (-u) handling
if [[ $operation = makepkg ]]; then
[[ $upgrade ]] && UpgradeAur
GetIgnoredPkgs && Core ${pkgs[@]}
exit
fi
# check (-k) handling
if [[ $operation = check ]]; then
CheckAur ${pkgs[@]}
exit
fi
# pacman search (-Ss) handling
if [[ $option = search ]]; then
[[ ! $aur ]] && [[ ! $quiet ]] && $pacmanBin -Ss ${pkgs[@]}
[[ ! $aur ]] && [[ $quiet ]] && $pacmanBin -Ssq ${pkgs[@]}
[[ ! $repo ]] && [[ $fallback = true || $aur ]] && SearchAur ${pkgs[@]}
exit
fi
# pacman sync (-S) handling
# pacman downloadonly (-Sw) handling
if [[ $option = sync ]]; then
ClassifyPkgs ${pkgs[@]}
if [[ ${repopkgs[@]} ]]; then
[[ $installpkg ]] && runasroot $pacmanBin -S ${pacopts[@]} ${repopkgs[@]}
[[ ! $installpkg ]] && runasroot $pacmanBin -Sw ${pacopts[@]} ${repopkgs[@]}
fi
if [[ ${aurpkgs[@]} ]]; then
[[ $fallback = true && ! $aur ]] && warn "Package(s) ${colorW}${aurpkgs[@]}${reset} not found in repositories, trying ${colorM}aur${reset}..."
GetIgnoredPkgs && Core ${aurpkgs[@]}
fi
exit
fi
# pacman info (-Si) handling
if [[ $option = info ]]; then
ClassifyPkgs ${pkgs[@]}
if [[ ${repopkgs[@]} ]]; then
[[ $count -eq 1 ]] && $pacmanBin -Si ${repopkgs[@]}
[[ $count -ne 1 ]] && $pacmanBin -Sii ${repopkgs[@]}
fi
if [[ ${aurpkgs[@]} ]]; then
[[ $fallback = true && ! $aur ]] && warn "Package(s) ${colorW}${aurpkgs[@]}${reset} not found in repositories, trying ${colorM}aur${reset}..."
InfoAur ${aurpkgs[@]}
fi
exit
fi
# pacman sysupgrade (-Su) handling
if [[ $option = sysupgrade ]]; then
[[ -z "$(echo $pacmanarg | grep -v "r$")" ]] && pacmanarg=${pacmanarg%?}
[[ ! $aur ]] && runasroot $pacmanBin $pacmanarg ${pacopts[@]} ${ignorepkgs[@]}
[[ ! $repo ]] && [[ $fallback = true || $aur ]] && GetIgnoredPkgs && UpgradeAur && Core ${pkgs[@]}
exit
fi
# pacman upgrades (-Qu) handling
if [[ $option = upgrades ]]; then
[[ ! $aur ]] && CheckRepo ${pkgs[@]}
[[ ! $repo ]] && [[ $fallback = true || $aur ]] && CheckAur ${pkgs[@]}
exit
fi
# pacman clean (-Sc) handling
if [[ $option = cleancache ]]; then
[[ -z "$(echo $pacmanarg | grep -v "r$")" ]] && pacmanarg=${pacmanarg%?}
[[ ! $aur ]] && runasroot $pacmanBin $pacmanarg
[[ ! $repo ]] && [[ $fallback = true || $aur ]] && CleanCache ${pkgs[@]}
exit
fi
# edit (-e) handling
if [[ $editpkg && ! $noedit ]]; then
EditPkgs ${pkgs[@]}
exit
fi
# clean (-c) handling
if [[ $cleanpkg ]]; then
CleanUp ${pkgs[@]}
exit
fi
# vim:set ts=4 sw=2 et:
Jump to Line
Something went wrong with that request. Please try again.