2016-03-13 09:14:28 +00:00
|
|
|
#!/usr/bin/env bash
|
2016-06-28 21:00:15 +00:00
|
|
|
|
2016-03-13 09:14:28 +00:00
|
|
|
set -e
|
|
|
|
|
2016-06-28 21:00:15 +00:00
|
|
|
|
2016-03-13 09:14:28 +00:00
|
|
|
# Credit goes to:
|
2018-06-12 15:24:47 +00:00
|
|
|
# https://github.com/sstephenson/bats/blob/master/install.sh
|
2016-06-16 19:34:25 +00:00
|
|
|
function resolve_link {
|
2018-06-12 15:24:47 +00:00
|
|
|
$(type -p greadlink readlink | head -1) "$1"
|
2016-03-13 09:14:28 +00:00
|
|
|
}
|
|
|
|
|
2016-06-16 19:34:25 +00:00
|
|
|
function abs_dirname {
|
2016-07-02 09:59:55 +00:00
|
|
|
local cwd
|
2018-06-09 12:15:32 +00:00
|
|
|
local path="$1"
|
2016-07-02 09:59:55 +00:00
|
|
|
|
2018-06-12 15:24:47 +00:00
|
|
|
cwd="$(pwd)"
|
|
|
|
|
|
|
|
|
2016-03-13 09:14:28 +00:00
|
|
|
while [ -n "$path" ]; do
|
|
|
|
cd "${path%/*}"
|
|
|
|
local name="${path##*/}"
|
|
|
|
path="$(resolve_link "$name" || true)"
|
|
|
|
done
|
|
|
|
|
|
|
|
pwd
|
|
|
|
cd "$cwd"
|
|
|
|
}
|
|
|
|
|
|
|
|
PREFIX="$1"
|
|
|
|
if [ -z "$PREFIX" ]; then
|
2018-06-12 15:24:47 +00:00
|
|
|
echo "usage: $0 <prefix>" >&2
|
2016-03-13 09:14:28 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-06-12 15:24:47 +00:00
|
|
|
SCRIPT_ROOT="$(dirname "$(abs_dirname "$0")")"
|
|
|
|
|
|
|
|
mkdir -p "$PREFIX"/bin "$PREFIX"/share/man/man1 "$PREFIX"/share/man/man7
|
|
|
|
cp "$SCRIPT_ROOT"/git-secret "$PREFIX"/bin/git-secret
|
|
|
|
|
2016-06-16 19:34:25 +00:00
|
|
|
# There was an issue with this line:
|
|
|
|
# cp -R "$SCRIPT_ROOT"/man/man1/* "$PREFIX"/share/man/man1
|
|
|
|
# see https://github.com/sobolevn/git-secret/issues/35 for reference.
|
2016-07-02 09:59:55 +00:00
|
|
|
find "$SCRIPT_ROOT"/man/man1 -name '*.1' -print0 | xargs -0 -I {} cp \
|
|
|
|
-a {} "$PREFIX"/share/man/man1
|
2016-06-28 21:00:15 +00:00
|
|
|
cp "$SCRIPT_ROOT"/man/man7/git-secret.7 "$PREFIX"/share/man/man7/git-secret.7
|
2016-03-13 09:14:28 +00:00
|
|
|
|
2016-05-14 11:03:33 +00:00
|
|
|
echo "Installed git-secret to ${PREFIX}/bin/git-secret"
|