OILS / uninstall View on Github | oilshell.org

68 lines, 36 significant
1#!/bin/sh
2#
3# POSIX shell script to uninstall oil shell from the system.
4# Distributed with the source tarball.
5
6log() {
7 # indent it a bit
8 echo " $@" 1>&2
9}
10
11die() {
12 echo "FATAL install error: $@" 1>&2
13 exit 1
14}
15
16# NOTE: The configure step
17main() {
18 if ! . _build/detected-config.sh; then
19 die "Can't find _build/detected-config.sh. Run './configure'"
20 fi
21 # Now $PREFIX should be defined
22
23 #
24 # Remove the shell binary
25 #
26
27 #local exec_filename=oil.ovm-dbg
28 local exec_filename=oil.ovm
29 local bin_dest="${DESTDIR}${PREFIX}/bin/"
30
31 if ! rm "$bin_dest/$exec_filename"; then
32 log "Couldn't remove $exec_filename binary in $bin_dest"
33 else
34 log "Removed executable"
35 fi
36
37 local working_dir=$PWD # save for later
38
39 cd "$bin_dest"
40 for link in osh oil ysh; do
41 if ! rm "$bin_dest/$link"; then
42 log "Couldn't remove $link symlink in $bin_dest"
43 else
44 log "Removed '$link' symlink"
45 fi
46 done
47
48 #
49 # Remove man page
50 #
51
52 # Relevant:
53 # https://unix.stackexchange.com/questions/90759/where-should-i-install-manual-pages-in-user-directory
54 # https://www.freebsd.org/cgi/man.cgi?query=install
55
56 cd "$working_dir"
57
58 # e.g. /usr/local/share/man/man1
59 local man_dest="${DESTDIR}${DATAROOTDIR}/man/man1/"
60
61 if ! rm "$man_dest/osh.1"; then
62 log "Couldn't remove osh.1 in $man_dest"
63 else
64 log "Removed man page"
65 fi
66}
67
68main "$@"