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