Skip to content

Instantly share code, notes, and snippets.

@x3rAx
Last active March 24, 2018 15:48
Show Gist options
  • Save x3rAx/62fb52e4277f0fbbc1e9b420efff9c0e to your computer and use it in GitHub Desktop.
Save x3rAx/62fb52e4277f0fbbc1e9b420efff9c0e to your computer and use it in GitHub Desktop.
Simple install script for pacaur
#!/bin/bash
################################################################################
# If you are new to arch, I strongly recommend you to read the arch wiki page
# about AUR (https://wiki.archlinux.org/index.php/Arch_User_Repository) and to
# read and understand what this script does before blindly running it.
#
# This scripts purpose is in first line to save me some minutes when I want to
# install pacaur on a new system.
#
# But of course you are free to use it at your own risk (though I don't think
# there is anything dangerous in here ;) )
#
# This script must be run from a non-root user that is allowed to run sudo.
#
# Run the following command from a terminal to easily install pacaur:
#
# $ bash <(curl -s https://gist.githubusercontent.com/x3rAx/62fb52e4277f0fbbc1e9b420efff9c0e/raw/install-pacaur.sh)
#
FORCE=$([[ $1 == '-f' ]] && echo true || echo false)
function aurInstall() {
local pkg="$1"
if $FORCE || ! pacman -Qs "${pkg}" >/dev/null; then
echo "==> Install ${pkg} from AUR <==" >&2
mkdir "$pkg" || exit $?
cd "$pkg" || exit $?
curl -o PKGBUILD https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h="$pkg" || exit $?
makepkg --syncdeps --skippgpcheck --install || exit $?
cd .. || exit $?
fi
}
if ! $FORCE && pacman -Qs pacaur >/dev/null; then
echo 'It seems that pacaur is already installed.' >&2
echo 'To forece installation run the command with `-f` appended.' >&2
exit 1
fi
tmpdir="$(mktemp -d --tmpdir install-pacaur.XXXXXXXXXX)"
cd "$tmpdir"
echo '==> Check for updates <==' >&2
sudo pacman -Suy || exit $?
# base-devel is required for building packages
# curl is required to download PKGBUILDs
# expac and yajl are pacaur dependencies
packmanPackages=(base-devel curl expac yajl)
pacmanInstall=()
# Check for packages already installed
for pkg in ${packmanPackages[@]}; do
if $FORCE || ! pacman -Qs "${pkg}" >/dev/null; then
pacmanInstall+=("${pkg}")
fi
done
# Install missing packages
if [[ ${#pacmanInstall[@]} > 0 ]]; then
echo "==> Install ${pacmanInstall[@]} <==" >&2
sudo pacman -S ${pacmanInstall[@]} || exit $?
fi
# pacaur dependency
aurInstall cower || exit $?
# And finally: pacaur
aurInstall pacaur || exit $?
# Now do some cleanup...
echo '==> Cleanup <==' >&2
cd ~
rm -rf "$tmpdir"
echo '==> Done <=='
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment