aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/install.sh
blob: 22cfb6a2538631251a52e911217ecbdf31b41b0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
# shellcheck disable=SC2035,SC2016

set -e

CDPATH='' cd -- "$(dirname -- "$0")" || exit

printf "%s: Removing bad links\n" "$0"
{
	git log --pretty=format: --name-only --no-renames --diff-filter=D
	git status --porcelain --no-renames | grep -oP '^\s*\w*[DR?]+\w*\s*\K(.*)'
} | sort -u | sed -n 's/^[^/]\+\//..\//p' | while read -r f; do
	if [ -L "$f" ] && [ ! -e "$f" ]; then
		rm -v "$f"
	fi
done

printf "%s: Stowing packages\n" "$0"
stow "$@" */

for f in */install.sh; do
	$f
done