Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 103 lines (94 sloc) 2.763 kb
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
#!/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}

# 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 "Can't find program $program in $PATH"
exit 1
    fi
done

for pkg in emacs-{test-simple,load-relative,loc-changes,dbgr} ; do
echo '******************************************'
    echo Trying to install ${pkg}...
    echo '******************************************'
    if [[ -d $pkg ]]; then
run_cmd $need_sudo rm -fr $pkg
    fi
run_cmd git clone ${GIT_PROTOCOL}://github.com/rocky/${pkg}.git
    (cd $pkg && \
        run_cmd $SHELL ./autogen.sh && \
run_cmd ./configure $@ && \
run_cmd make && \
run_cmd make check && \
        run_cmd $need_sudo make install
    )
done
Something went wrong with that request. Please try again.