diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2013-01-25 22:25:29 -0600 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2013-01-25 22:25:29 -0600 |
commit | 5832f285ecf466c5d2875ce0514fe86354f2c8f7 (patch) | |
tree | 7f6c3f1e910a4e3c6a06bf4ff80144ed226e19f2 | |
parent | 269c52a4b32c56cc4e0c8a521f9a3037c3493577 (diff) |
tb: add an 'installation script'
by default we install with --prefix=/opt/lo/
-rwxr-xr-x | tb/install | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tb/install b/tb/install new file mode 100755 index 0000000..5577638 --- /dev/null +++ b/tb/install @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# get the abolute path to the directory containing the main script +BIN_DIR=$(dirname "$0") +pushd ${BIN_DIR?} > /dev/null +BIN_DIR=$(pwd) +popd > /dev/null + +dest_path=/opt/lo + +usage() +{ + cat <<EOF +Usage: $0 [ --prefix=<path> ] + +--prefix is used here in the sens of autoconf. +By default the prefix is /opt/lo, which means that tb and necesasry +shell files are installed in /opt/lo/bin + +EOF + +} + +while [ "${1}" != "" ]; do + parm=${1%%=*} + arg=${1#*=} + has_arg= + if [ "${1}" != "${parm?}" ] ; then + has_arg=1 + else + arg="" + fi + + case "${parm}" in + --prefix) # avoid calling *_clean functions (incremental build) + if [ -z "${has_arg}" ] ; then + shift; + arg="$1" + fi + if [ -z "${arg}" ] ; then + die "Missing argument for option $parm" + else + dest_path="$arg" + fi + ;; + --help) + usage + exit 0; + ;; + -*) + die "Invalid option $1" + ;; + *) + die "Invalid argument $1" + ;; + esac + shift +done + +if [ ! -d "${dest_path?}" ] ; then + mkdir -p "${dest_path?}/bin" +fi + +if [ ! -d "${dest_path?}/bin" ] ; then + mkdir "${dest_path?}/bin" +fi + +echo "Installing in ${dest_path?}/bin" +cp -v ${BIN_DIR}/tb* ${dest_path?}/bin/. +chmod +x ${dest_path?}/bin/tb +echo "Done." |