forked from timo-reymann/deterministic-zip
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller
More file actions
executable file
·66 lines (56 loc) · 1.97 KB
/
installer
File metadata and controls
executable file
·66 lines (56 loc) · 1.97 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
#!/bin/bash
set -eo pipefail
_ok() {
echo -e "\033[0;32m OK\033[0m"
}
{
if uname -a | grep -q "Darwin"; then
SYS_ENV_PLATFORM=macos
elif uname -a | grep -q "x86_64 GNU/Linux"; then
SYS_ENV_PLATFORM=linux_x86
elif uname -a | grep -q "aarch64 GNU/Linux"; then
SYS_ENV_PLATFORM=linux_arm
else
echo "This installer does not currently support your platform. If you believe it should, please consider opening an issue on the GitHub repository:"
echo "https://github.com/timo-reymann/deterministic-zip/issues/new"
exit 1
fi
_pid="$$"
if [ "${UID:-$(id -u)}" -ne 0 ]; then
echo -n "Installer is not running as root, trying to use sudo ..."
SUDO="sudo"
$SUDO whoami >/dev/null
_ok
fi
if [ -n "$DETERMINISTIC_ZIP_VERSION" ];
then
echo -n "Using version from DETERMINISTIC_ZIP_VERSION ..."
version="$DETERMINISTIC_ZIP_VERSION"
else
echo -n "Fetch the latest version from GitHub ... "
# shellcheck disable=SC1083
version="$(curl -Lso /dev/null -w %{url_effective} https://github.com/timo-reymann/deterministic-zip/releases/latest | grep -o '[^/]*$')"
fi
_ok
echo -n "Determine artifact to download based on host OS ... "
# Install per platform
case $SYS_ENV_PLATFORM in
linux_x86)
artifact="deterministic-zip_linux-amd64"
;;
linux_arm)
artifact="deterministic-zip_linux-arm64"
;;
macos)
artifact="deterministic-zip_darwin-amd64"
;;
esac
_ok
echo -n "Download binary for ${version} ... "
curl --fail -LsS https://github.com/timo-reymann/deterministic-zip/releases/download/${version}/${artifact} -o /tmp/deterministic-zip.${_pid} || { echo -e "\n\033[0;31mERR: Failed to download from https://github.com/timo-reymann/deterministic-zip/releases/download/${version}/${artifact}\033[0m" && exit 2; }
_ok
echo -n "Installing to /usr/local/bin ..."
$SUDO mv /tmp/deterministic-zip.${_pid} /usr/local/bin/deterministic-zip
$SUDO chmod +x /usr/local/bin/deterministic-zip
_ok
}