2020-02-24 10:42:23 +01:00
|
|
|
#!/usr/bin/env bash
|
2020-02-23 14:25:06 +01:00
|
|
|
#
|
|
|
|
|
# Wraps "make" and ensures basic packages are installed:
|
|
|
|
|
#
|
|
|
|
|
# - make itself
|
|
|
|
|
# - python3-virtualenv (needed for ansible)
|
|
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
|
set -o nounset
|
|
|
|
|
|
2020-12-09 19:32:11 +01:00
|
|
|
DOTDIR="/var/lib/dotfiles"
|
|
|
|
|
|
2020-02-23 14:55:54 +01:00
|
|
|
os_release_file=/etc/os-release
|
|
|
|
|
if [[ ! -e "${os_release_file}" ]] ; then
|
|
|
|
|
2>&1 printf "Could not find ${os_release_file}, exiting"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2024-04-22 14:02:56 +02:00
|
|
|
source "${os_release_file}"
|
2020-02-23 14:25:06 +01:00
|
|
|
|
2020-12-08 23:09:09 +01:00
|
|
|
sudowrap() {
|
2024-04-22 14:02:56 +02:00
|
|
|
if (( $(id -u) != 0 )) ; then
|
2020-12-08 23:09:09 +01:00
|
|
|
sudo "${@}"
|
|
|
|
|
else
|
|
|
|
|
"${@}"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-02 12:28:37 +02:00
|
|
|
cache_updated=0
|
2024-04-22 14:02:56 +02:00
|
|
|
install() {
|
|
|
|
|
local package="$1" ; shift
|
|
|
|
|
|
2024-04-10 15:57:38 +02:00
|
|
|
if [[ $NAME == "Arch Linux" ]] ; then
|
2024-04-22 14:16:32 +02:00
|
|
|
if (( ! cache_updated )) ; then
|
|
|
|
|
sudowrap pacman -Sy
|
|
|
|
|
cache_updated=1
|
|
|
|
|
fi
|
2024-04-22 14:02:56 +02:00
|
|
|
sudowrap pacman -S --needed --noconfirm "${package}"
|
2020-02-23 14:25:06 +01:00
|
|
|
else
|
|
|
|
|
2>&1 printf "Unsupported distro $NAME, exiting"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ! command -v make >/dev/null ; then
|
|
|
|
|
printf 'Make not installed, installing ...\n'
|
2024-04-22 14:02:56 +02:00
|
|
|
install "make"
|
2020-02-23 14:25:06 +01:00
|
|
|
printf 'Done\n'
|
|
|
|
|
fi
|
|
|
|
|
|
2024-04-22 14:02:56 +02:00
|
|
|
if ! command -v ansible >/dev/null ; then
|
|
|
|
|
printf 'Ansible not installed, installing ...\n'
|
|
|
|
|
install "ansible"
|
|
|
|
|
printf 'Done\n'
|
2022-06-30 06:38:05 +02:00
|
|
|
fi
|
|
|
|
|
|
2024-04-22 14:02:56 +02:00
|
|
|
cd "${DOTDIR}" && make
|