]> code.delx.au - gnu-emacs-elpa/blob - packages/load-relative/install-from-git.sh
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / load-relative / install-from-git.sh
1 #!/bin/bash
2
3 # This installs all realgud and its prerequisites. If you are lucky
4 # you can just run this:
5 #
6 # bash ./install-from-git.sh
7 #
8 # However we do provide for some customization...
9 #
10 # 1. GIT PROTOCOL
11 # ===============
12 #
13 # If your "git clone" can't handle the "http" protocol, you might be
14 # able to use the "git" protocol. To do this set the GIT_PROTOCOL
15 # variable like this:
16 #
17 # GIT_PROTOCOL=git sh ./install-from-git.sh
18 #
19 # 2. configure options (e.g --prefix)
20 # ====================================
21
22 # If you want to customize configuration parameters, for example,
23 # choose where to install, you can pass configure options to this
24 # script. For example:# can pass configure options.
25 #
26 # sh ./install-from-git.sh --prefix=/tmp
27 #
28 # 3. TO "sudo" or not to "sudo"?
29 # ==============================
30 # If you are running as root on a *Nix-like box, then there's no problem.
31 #
32 # If you are not running as root, "sudo" might be invoked to install
33 # code. On systems that don't have a "sudo" command but need
34 # filesystem permission, then you get by with setting SUDO_CMD to "su root-c"
35 # For example:
36 #
37 # SUDO_CMD='su root -c' sh ./install-from-git.sh
38 #
39 # If you have sufficient filesystem permission (which is often the
40 # case on Windows or cygwin) then you might not need or want sudo. So
41 # here, set SUDO_CMD to a blank:
42 #
43 # SUDO_CMD=' ' sh ./install-from-git.sh
44 #
45 #
46 # To finish here is an invocation using all 3 above options:
47 # GIT_PROTOCOL='git' SUDO_CMD=' ' sh ./install-from-git.sh --prefix=/tmp
48
49 GIT_PROTOCOL=${GIT_PROTOCOL:-http}
50
51 # Run and echo a command
52 run_cmd() {
53 echo "--- Running command: $@"
54 $@
55 rc=$?
56 echo "--- $@ exit status is $?"
57 return $rc
58 }
59
60 # environment variable SUDO_CMD could be "sudo" or "su root -c" or " "
61 # for don't need sudo
62
63 if (( $(id -u) != 0)) ; then
64 if [[ -z "$SUDO_CMD" ]] ; then
65 need_sudo='sudo'
66 if which $need_sudo >/dev/null 2>&1 ; then
67 try_cmd=''
68 else
69 need_sudo='su root -c'
70 try_cmd='su'
71 fi
72 else
73 need_sudo="$SUDO_CMD"
74 fi
75 else
76 need_sudo=''
77 try_cmd=''
78 fi
79
80 for program in git make $need_sudo ; do
81 if ! which $program >/dev/null 2>&1 ; then
82 echo "Cant find program $program in $PATH"
83 exit 1
84 fi
85 done
86
87 for pkg in emacs-{test-simple,load-relative} ; do
88 echo '******************************************'
89 echo Trying to install ${pkg}...
90 echo '******************************************'
91 run_cmd git clone ${GIT_PROTOCOL}://github.com/rocky/${pkg}.git
92 (cd $pkg && \
93 run_cmd $SHELL ./autogen.sh && \
94 run_cmd ./configure $@ && \
95 run_cmd make && \
96 run_cmd make check && \
97 run_cmd $need_sudo make install
98 )
99 done