#!/usr/bin/env bash # Build Nacre from this checkout's last commit as an Arch package and install it with pacman, with every dependency. # ./install.sh build and install (or update) # ./install.sh --uninstall remove the package; your data in ~/.config and ~/.local/share stays # The build runs in a temporary folder that is deleted at the end, and so is target/ (cargo's old build output): only # the code stays here. set -euo pipefail root=$(cd "$(dirname "$0")" && pwd) case "${1:-}" in --uninstall) exec sudo pacman -Rs nacre ;; "") ;; *) sed -n '2,6s/^# \{0,1\}//p' "$0"; exit 2 ;; esac command -v makepkg >/dev/null || { echo "This installer needs Arch Linux (makepkg, base-devel)." >&2; exit 1; } [ "$(id -u)" != 0 ] || { echo "Run it as your user; it asks for your password when it needs it." >&2; exit 1; } [ -z "$(git -C "$root" status --porcelain --untracked-files=no)" ] || echo "Note: changes that aren't committed are left out." work=$(mktemp -d "${XDG_CACHE_HOME:-$HOME/.cache}/nacre-build.XXXXXX") trap 'rm -rf "$work"' EXIT export NACRE_SRC="$root" BUILDDIR="$work/build" SRCDEST="$work" PKGDEST="$work" LOGDEST="$work" cp "$root/packaging/arch/PKGBUILD" "$work/" cd "$work" makepkg -si --noconfirm --needed [ ! -f "$root/target/CACHEDIR.TAG" ] || rm -rf "$root/target" echo "Installed. Start it with: nacre"