forked from realgud/realgud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-from-git.sh
executable file
·105 lines (97 loc) · 2.8 KB
/
install-from-git.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# This installs all realgud and its prerequisites. If you are lucky
# you can just run this:
#
# bash ./install-from-git.sh
#
# However we do provide for some customization...
#
# 1. GIT PROTOCOL
# ===============
#
# If your "git clone" can't handle the "http" protocol, you might be
# able to use the "git" protocol. To do this set the GIT_PROTOCOL
# variable like this:
#
# GIT_PROTOCOL=git sh ./install-from-git.sh
#
# 2. configure options (e.g --prefix)
# ====================================
# If you want to customize configuration parameters, for example,
# choose where to install, you can pass configure options to this
# script. For example:# can pass configure options.
#
# sh ./install-from-git.sh --prefix=/tmp
#
# 3. TO "sudo" or not to "sudo"?
# ==============================
# If you are running as root on a *Nix-like box, then there's no problem.
#
# If you are not running as root, "sudo" might be invoked to install
# code. On systems that don't have a "sudo" command but need
# filesystem permission, then you get by with setting SUDO_CMD to "su root-c"
# For example:
#
# SUDO_CMD='su root -c' sh ./install-from-git.sh
#
# If you have sufficient filesystem permission (which is often the
# case on Windows or cygwin) then you might not need or want sudo. So
# here, set SUDO_CMD to a blank:
#
# SUDO_CMD=' ' sh ./install-from-git.sh
#
#
# To finish here is an invocation using all 3 above options:
# GIT_PROTOCOL='git' SUDO_CMD=' ' sh ./install-from-git.sh --prefix=/tmp
GIT_PROTOCOL=${GIT_PROTOCOL:-https}
MAKE=${MAKE:-make}
# Run and echo a command
run_cmd() {
echo "--- Running command: $@"
$@
rc=$?
echo "--- $@ exit status is $?"
return $rc
}
# environment variable SUDO_CMD could be "sudo" or "su root -c" or " "
# for don't need sudo
if (( $(id -u) != 0)) ; then
if [[ -z "$SUDO_CMD" ]] ; then
need_sudo='sudo'
if which $need_sudo >/dev/null 2>&1 ; then
try_cmd=''
else
need_sudo='su root -c'
try_cmd='su'
fi
else
need_sudo="$SUDO_CMD"
fi
else
need_sudo=''
try_cmd=''
fi
for program in git make $try_cmd ; do
if ! which $program >/dev/null 2>&1 ; then
echo 2>&1 "Can't find program $program in $PATH"
exit 1
fi
done
cd /tmp
for pkg in rocky/emacs-{test-simple,load-relative,loc-changes} realgud/realgud ; do
echo '******************************************'
echo Trying to install ${pkg}...
echo '******************************************'
pkg_short=$(basename $pkg)
if [[ -d $pkg_short ]]; then
run_cmd $need_sudo rm -fr $pkg_short
fi
run_cmd git clone ${GIT_PROTOCOL}://github.com/${pkg}.git
(cd $pkg_short && \
run_cmd $SHELL ./autogen.sh && \
run_cmd ./configure $@ && \
run_cmd ${MAKE} && \
run_cmd ${MAKE} check && \
run_cmd $need_sudo ${MAKE} install
)
done