aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/install.sh
blob: d8da4e1943ea6c2c5d0c74e1a446899549e1a75f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

set -e

CDPATH='' cd -- "$(dirname -- "$0")" || exit
TARGET=${TARGET:-$HOME}

if [ -r .installed ]; then
	read -r DOTFILES_INSTALLED <.installed
	export DOTFILES_INSTALLED
fi

printf "%s: Stowing packages\n" "$0"
# shellcheck disable=SC2086
stow -R "$@" ${1:-*}/ 2>&1 | tac | awk '
	/\(reverts previous action\)$/ { reverted[$2] = 1; next }
	/^LINK:/ { print $0 }
	/^UNLINK:/ { if (!reverted[$2]) { print $0 } }
' | tac

printf "%s: Installing packages\n" "$0"
for f in ${1:-*}/install.sh; do
	$f
done

git rev-parse ^@ >.installed