-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·37 lines (30 loc) · 894 Bytes
/
install
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
# vim: ft=sh
PREFIX="${PREFIX:-/usr/local}"
bin_dir="${PREFIX}"
man_dir="${PREFIX}/share"
fail(){ [[ $1 ]] && printf '%s\n' "failed: $1"; }
success(){ printf '%s\n' "successfully $1";}
install(){
for bin in ${bins[@]};{ copy "$bin" || break; success "installed $bin"; }
for man in ${mans[@]};{ copy "$man" || break; success "installed $man"; }
}
uninstall(){
for file in ${bins[@]} ${mans[@]};{ remove "$file";}
success "uninstalled"
}
copy(){
local dest="${PREFIX}/$1"
[[ "$1" -nt "$dest" || ! -a $dest ]] || { fail "nothing to do for $1"; return 1;}
cp -rf $1 "${dest//man\//share\/man/}" || fail $_
}
remove(){
local dest="${PREFIX}/$1"
[[ "$dest" ]] || return 1
rm "${dest//man\//share\/man/}" || fail "remove"
}
for bin in bin/*;{ [[ -a $bin ]] && bins+=($bin);}
for man in man/*/*.[0-9];{ [[ -a $man ]] && mans+=($man);}
case $1 in
u*) uninstall ;;
'') install ;;
esac