2016-06-16 19:34:25 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2021-05-05 12:59:28 +00:00
|
|
|
# shellcheck disable=SC1090,SC1091
|
|
|
|
source "$SECRETS_PROJECT_ROOT/src/version.sh"
|
|
|
|
|
2016-06-16 19:34:25 +00:00
|
|
|
# Initializing and settings:
|
2021-05-04 18:58:36 +00:00
|
|
|
READ_PERM=0644
|
|
|
|
EXEC_PERM=0755
|
2016-06-16 19:34:25 +00:00
|
|
|
|
2021-05-03 12:43:04 +00:00
|
|
|
SCRIPT_NAME='git-secret'
|
|
|
|
SCRIPT_DESCRIPTION='A bash-tool to store your private data inside a git repository.'
|
2021-05-05 12:59:28 +00:00
|
|
|
SCRIPT_VERSION="$GITSECRET_VERSION"
|
2016-06-16 19:34:25 +00:00
|
|
|
|
|
|
|
# This may be overridden:
|
|
|
|
if [[ -z "$SCRIPT_BUILD_DIR" ]]; then
|
2021-05-04 18:58:36 +00:00
|
|
|
SCRIPT_BUILD_DIR="$PWD/build"
|
2016-06-16 19:34:25 +00:00
|
|
|
fi
|
|
|
|
|
2021-05-04 18:58:36 +00:00
|
|
|
SCRIPT_DEST_DIR="$SCRIPT_BUILD_DIR/buildroot"
|
2016-06-16 19:34:25 +00:00
|
|
|
|
|
|
|
|
2021-05-04 18:58:36 +00:00
|
|
|
function locate_release {
|
|
|
|
local release_type="$1"
|
2021-05-06 15:52:35 +00:00
|
|
|
local arch="${2:-}"
|
2021-05-06 14:47:41 +00:00
|
|
|
|
|
|
|
find "$SCRIPT_DEST_DIR" \
|
|
|
|
-maxdepth 1 \
|
|
|
|
-name "*${arch}.$release_type" | 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:
|
2021-05-04 18:58:36 +00:00
|
|
|
install -D "$dir_switch" \
|
|
|
|
-b -m "$EXEC_PERM" "$dir_switch" "$SCRIPT_NAME" \
|
2021-05-06 14:47:41 +00:00
|
|
|
"$SCRIPT_BUILD_DIR/usr/bin/$SCRIPT_NAME"
|
2021-05-04 18:58:36 +00:00
|
|
|
|
|
|
|
# Install the manualls:
|
2021-05-06 14:47:41 +00:00
|
|
|
install -m "$EXEC_PERM" -d "$SCRIPT_BUILD_DIR/usr/share/man/man1"
|
|
|
|
install -m "$EXEC_PERM" -d "$SCRIPT_BUILD_DIR/usr/share/man/man7"
|
2021-05-06 10:16:48 +00:00
|
|
|
for file in man/man1/*.1 ; do
|
2021-05-04 18:58:36 +00:00
|
|
|
install -D "$dir_switch" \
|
|
|
|
-b -m "$READ_PERM" "$dir_switch" "$file" \
|
2021-05-06 14:47:41 +00:00
|
|
|
"$SCRIPT_BUILD_DIR/usr/share/$file"
|
2016-06-16 19:34:25 +00:00
|
|
|
done
|
2021-05-04 18:58:36 +00:00
|
|
|
install -D "$dir_switch" \
|
|
|
|
-b -m "$READ_PERM" "$dir_switch" 'man/man7/git-secret.7' \
|
2021-05-06 14:47:41 +00:00
|
|
|
"$SCRIPT_BUILD_DIR/usr/share/man/man7/git-secret.7"
|
2016-06-16 19:34:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function build_package {
|
2021-05-04 18:58:36 +00:00
|
|
|
# Only requires `rpm`, `apk`, or `deb` as first argument:
|
2016-06-16 19:34:25 +00:00
|
|
|
local build_type="$1"
|
2021-05-06 14:47:41 +00:00
|
|
|
local arch_type="${2:-all}"
|
2016-06-16 19:34:25 +00:00
|
|
|
|
2019-08-21 21:39:39 +00:00
|
|
|
# coreutils is for sha256sum
|
2016-06-16 19:34:25 +00:00
|
|
|
# See https://github.com/jordansissel/fpm for docs:
|
|
|
|
fpm \
|
2021-05-05 12:59:28 +00:00
|
|
|
--input-type 'dir' \
|
|
|
|
--output-type "$build_type" \
|
2021-05-06 14:47:41 +00:00
|
|
|
--chdir "$SCRIPT_BUILD_DIR" \
|
|
|
|
--architecture "$arch_type" \
|
2021-05-05 12:59:28 +00:00
|
|
|
--name "$SCRIPT_NAME" \
|
2016-06-16 19:34:25 +00:00
|
|
|
--version "$SCRIPT_VERSION" \
|
|
|
|
--description "$SCRIPT_DESCRIPTION" \
|
2021-05-05 12:59:28 +00:00
|
|
|
--url 'https://git-secret.io' \
|
|
|
|
--maintainer 'Nikita Sobolev (mail@sobolevn.me)' \
|
|
|
|
--license 'MIT' \
|
|
|
|
--depends 'bash' \
|
|
|
|
--depends 'coreutils' \
|
|
|
|
--depends 'gawk' \
|
|
|
|
--depends 'git' \
|
|
|
|
--depends 'gnupg' \
|
2016-06-16 19:34:25 +00:00
|
|
|
--deb-no-default-config-files \
|
|
|
|
.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function clean_up_files {
|
2021-05-06 14:47:41 +00:00
|
|
|
# Pre-installed files:
|
|
|
|
rm -rf "${SCRIPT_BUILD_DIR:?}/usr"
|
|
|
|
# nfpm configs:
|
|
|
|
rm -rf "$SCRIPT_BUILD_DIR"/*.yml
|
2016-06-16 19:34:25 +00:00
|
|
|
}
|