Created
March 4, 2016 13:19
-
-
Save Caffe1neAdd1ct/c83c218ca1b2ac326497 to your computer and use it in GitHub Desktop.
AUR helper script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OPTIND=1 | |
AUR="https://aur.archlinux.org/" | |
INSTALL="0" | |
UPDATE="0" | |
PURGE="0" | |
REINSTALL="0" | |
NAME="0" | |
SEARCH="0" | |
while getopts "h?iuprsn:" opt; do | |
case "$opt" in | |
h|\?) | |
echo -e "usage ./aur.sh -i -n ttf-google-fonts-git"; | |
echo -e "'-n ttf-google-fonts-git' to clone git repo" | |
echo -e "'-i' install after git clone using makepkg -sric" | |
echo -e "'-p' purge package from the system" | |
echo -e "'-u' updates using git pull && makepkg -sric" | |
echo -e "'-r' reinstalls using the local copy" | |
exit 0 | |
;; | |
i) INSTALL="1" | |
;; | |
u) UPDATE="1" | |
;; | |
p) PURGE="1" | |
;; | |
r) REINSTALL="1" | |
;; | |
s) SEARCH="1" | |
;; | |
n) NAME=$OPTARG | |
;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
[ "$!" = "--" ] && shift | |
if [ "$NAME" != "0" ]; then | |
if [ "$UPDATE" == "0" ] && [ "$REINSTALL" == "0" ] && [ "$PURGE" == "0" ] && [ "$SEARCH" == 0 ]; then | |
git clone "$AUR$NAME.git" | |
fi | |
if [ "$INSTALL" == "1" ]; then | |
cd $NAME && makepkg -sric | |
fi | |
if [ "$UPDATE" == "1" ]; then | |
cd $NAME && git pull && makepkg -sric | |
fi | |
if [ "$REINSTALL" == "1" ]; then | |
cd $NAME && makepkg -sric | |
fi | |
if [ "$PURGE" == "1" ]; then | |
rm -rf $NAME && sudo pacman -R $NAME | |
fi | |
if [ "$SEARCH" == "1" ]; then | |
echo -e "Search Results:" | |
curl -X GET -s -G https://aur.archlinux.org/rpc -d v=5 -d type=search -d arg=$NAME | grep -Po '"Name":(\d*?,|.*?[^\\\\]",)' | |
fi | |
else | |
echo "Usage ./aur.sh -iurps -n package-name"; | |
exit 225; | |
fi | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
./aur.sh -n package-name - will fetch an aur package
./aur.sh -s -n package-name - will search for package by package-name
./aur.sh -i -n package-name - will fetch and install
./aur.sh -u -n package-name - will git pull to update and install package
./aur.sh -r -n package-name - will install package from current source (reinstall)
./aur.sh -p -n package-name - will purge package sources and uninstall