Created
April 18, 2020 23:23
-
-
Save Jkotheimer/89a483c1b983e58f75c5fc9b1893a797 to your computer and use it in GitHub Desktop.
Simple installer for AUR packages
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 | |
[ -z $1 ] && echo "No package name specified" && exit 1 | |
# If the package does not exist in the aur, exit with an error | |
[ "$(curl -I -s "https://aur.archlinux.org/packages/${1}" | head -n 1 | cut -d$' ' -f2)" = 404 ] && { | |
echo "Could not locate package: ${1}" | |
exit -1 | |
} | |
cd $HOME/Downloads | |
# If the directory already exists, prompt for reinstallation | |
[ -d "${1}-aur" ] && { | |
read -n 1 -p "$HOME/Downloads/${1}-aur already exists. Reinstall? [Y/n] " REINSTALL | |
echo "" | |
if [[ -z $REINSTALL || "${REINSTALL^^}" = "Y" ]]; then | |
sudo rm -rf "${1}-aur" | |
else | |
exit 0 | |
fi | |
} | |
# Clone the repository, move into it, and install | |
git clone "https://aur.archlinux.org/${1}.git" "${1}-aur" | |
cd "${1}-aur" | |
makepkg -si | |
# If the installation failed, remove the cloned directory | |
[ $? != 0 ] && rm -rf "${1}-aur" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment