2016-06-16 19:34:25 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Initializing and settings:
|
|
|
|
READ_PEM=0644
|
|
|
|
EXEC_PEM=0755
|
|
|
|
|
|
|
|
SCRIPT_NAME="git-secret"
|
|
|
|
SCRIPT_DESCRIPTION="A bash-tool to store your private data inside a git repository."
|
2016-07-02 09:46:54 +00:00
|
|
|
SCRIPT_VERSION=$(bash "${PWD}"/git-secret --version)
|
2016-06-16 19:34:25 +00:00
|
|
|
|
|
|
|
# This might be overridden someday:
|
2016-07-02 09:46:54 +00:00
|
|
|
: "${SCRIPT_EPOCH:=0}"
|
|
|
|
: "${SCRIPT_ITERATION:=1}"
|
2016-06-16 19:34:25 +00:00
|
|
|
|
|
|
|
# This may be overridden:
|
|
|
|
if [[ -z "$SCRIPT_BUILD_DIR" ]]; then
|
|
|
|
SCRIPT_BUILD_DIR="${PWD}/build"
|
|
|
|
fi
|
|
|
|
|
|
|
|
SCRIPT_DEST_DIR="${SCRIPT_BUILD_DIR}/buildroot"
|
|
|
|
|
|
|
|
|
2017-11-10 18:31:22 +00:00
|
|
|
function locate_apk {
|
|
|
|
find "$SCRIPT_DEST_DIR" -maxdepth 1 -name "*.apk" | head -1
|
|
|
|
}
|
|
|
|
|
2016-06-16 19:34:25 +00:00
|
|
|
function locate_deb {
|
2016-07-02 09:59:55 +00:00
|
|
|
find "$SCRIPT_DEST_DIR" -maxdepth 1 -name "*.deb" | head -1
|
2016-06-16 19:34:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function locate_rpm {
|
2016-07-02 09:59:55 +00:00
|
|
|
find "$SCRIPT_DEST_DIR" -maxdepth 1 -name "*.rpm" | head -1
|
2016-06-16 19:34:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function preinstall_files {
|
2017-11-10 18:31:22 +00:00
|
|
|
# Only requires `-T` or `-c` depending on the OS
|
|
|
|
local dir_switch="$1"
|
|
|
|
|
2016-06-16 19:34:25 +00:00
|
|
|
# Preparing the files:
|
|
|
|
rm -rf "$SCRIPT_BUILD_DIR"
|
|
|
|
mkdir -p "$SCRIPT_DEST_DIR"
|
|
|
|
|
|
|
|
# Coping the files inside the build folder:
|
2017-11-10 19:42:25 +00:00
|
|
|
install -D "${dir_switch}" -b -m "$EXEC_PEM" "${dir_switch}" "git-secret" "${SCRIPT_DEST_DIR}/usr/bin/git-secret"
|
2016-06-16 19:34:25 +00:00
|
|
|
install -m "$EXEC_PEM" -d "${SCRIPT_DEST_DIR}/usr/share/man/man1"
|
|
|
|
install -m "$EXEC_PEM" -d "${SCRIPT_DEST_DIR}/usr/share/man/man7"
|
|
|
|
for file in man/man1/* ; do
|
|
|
|
if [[ "$file" == *.ronn ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2017-11-10 19:42:25 +00:00
|
|
|
install -D "${dir_switch}" -b -m "$READ_PEM" "${dir_switch}" "$file" "${SCRIPT_DEST_DIR}/usr/share/$file"
|
2016-06-16 19:34:25 +00:00
|
|
|
done
|
2017-11-10 19:42:25 +00:00
|
|
|
install -D "${dir_switch}" -b -m "$READ_PEM" "${dir_switch}" "man/man7/git-secret.7" \
|
2016-06-16 19:34:25 +00:00
|
|
|
"${SCRIPT_DEST_DIR}/usr/share/man/man7/git-secret.7"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function build_package {
|
2017-11-10 18:31:22 +00:00
|
|
|
# Only requires `rpm`, `apk` or `deb` as first argument:
|
2016-06-16 19:34:25 +00:00
|
|
|
local build_type="$1"
|
|
|
|
|
|
|
|
# See https://github.com/jordansissel/fpm for docs:
|
|
|
|
fpm \
|
|
|
|
-s dir \
|
|
|
|
-t "$build_type" \
|
|
|
|
-a all \
|
|
|
|
-n "$SCRIPT_NAME" \
|
|
|
|
--version "$SCRIPT_VERSION" \
|
|
|
|
--description "$SCRIPT_DESCRIPTION" \
|
|
|
|
--url "https://sobolevn.github.io/git-secret/" \
|
|
|
|
--maintainer "Nikita Sobolev (mail@sobolevn.me)" \
|
|
|
|
--license "MIT" \
|
|
|
|
-C "$SCRIPT_DEST_DIR" \
|
|
|
|
-d "git" \
|
|
|
|
-d "gnupg" \
|
|
|
|
--deb-no-default-config-files \
|
|
|
|
.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function clean_up_files {
|
2016-07-02 09:46:54 +00:00
|
|
|
rm -rf "${SCRIPT_DEST_DIR:?}/usr"
|
2016-06-16 19:34:25 +00:00
|
|
|
}
|