-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·41 lines (33 loc) · 851 Bytes
/
Copy pathinstall.sh
File metadata and controls
executable file
·41 lines (33 loc) · 851 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
set -e
command -v stow > /dev/null || (echo -e "\033[1;31mError\033[0m: GNU stow is not installed" >&2 && exit 1)
get_absolute_path() {
realpath "$1" 2>/dev/null || { cd "$1" ; pwd ; }
}
dest="$(get_absolute_path "${DESTDIR:=$HOME}")"
echo "installing into $dest"
hook() {
hook="$1"
[ ! -x "$name/$hook.sh" ] && return
echo "$name: $hook"
"$name/$hook.sh" "$dest"
}
install_in_dir() {
dird="$(dirname "$1")"
name="$(basename "$1")"
echo "$name ..."
trap 'echo -e "$name \033[1;31m☓ failed\033[0m"' ERR
pushd "$dird" >/dev/null
hook "pre-install"
stow --target "$dest" --verbose \
--ignore '\.swp$' \
--ignore '^(pre|post)-install.sh$' \
"$name"
hook "post-install"
popd >/dev/null
trap - ERR
echo -e "$name \033[1;32m✓\033[0m"
}
for p in "$@" ; do
install_in_dir "$p"
done