Skip to content
Newer
Older
100755 100 lines (91 sloc) 2.62 KB
d4d0228 @rocky Add install-from-git script
authored Mar 16, 2011
1 #!/bin/bash
7de0162 @rocky load-relative.el: beef up documentation. install-from-git.sh: remove …
authored Apr 6, 2013
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
d4d0228 @rocky Add install-from-git script
authored Mar 16, 2011
52 run_cmd() {
53 echo "--- Running command: $@"
54 $@
55 rc=$?
56 echo "--- $@ exit status is $?"
57 return $rc
58 }
59
7de0162 @rocky load-relative.el: beef up documentation. install-from-git.sh: remove …
authored Apr 6, 2013
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
d4d0228 @rocky Add install-from-git script
authored Mar 16, 2011
75 else
76 need_sudo=''
7de0162 @rocky load-relative.el: beef up documentation. install-from-git.sh: remove …
authored Apr 6, 2013
77 try_cmd=''
d4d0228 @rocky Add install-from-git script
authored Mar 16, 2011
78 fi
7de0162 @rocky load-relative.el: beef up documentation. install-from-git.sh: remove …
authored Apr 6, 2013
79
d4d0228 @rocky Add install-from-git script
authored Mar 16, 2011
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
7de0162 @rocky load-relative.el: beef up documentation. install-from-git.sh: remove …
authored Apr 6, 2013
87 for pkg in emacs-{test-simple,load-relative} ; do
d4d0228 @rocky Add install-from-git script
authored Mar 16, 2011
88 echo '******************************************'
89 echo Trying to install ${pkg}...
90 echo '******************************************'
7de0162 @rocky load-relative.el: beef up documentation. install-from-git.sh: remove …
authored Apr 6, 2013
91 run_cmd git clone ${GIT_PROTOCOL}://github.com/rocky/${pkg}.git
d4d0228 @rocky Add install-from-git script
authored Mar 16, 2011
92 (cd $pkg && \
93 run_cmd $SHELL ./autogen.sh && \
7de0162 @rocky load-relative.el: beef up documentation. install-from-git.sh: remove …
authored Apr 6, 2013
94 run_cmd ./configure $@ && \
d4d0228 @rocky Add install-from-git script
authored Mar 16, 2011
95 run_cmd make && \
96 run_cmd make check && \
97 run_cmd $need_sudo make install
98 )
99 done
Something went wrong with that request. Please try again.