forked from heroku/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_init
More file actions
executable file
·104 lines (87 loc) · 2.24 KB
/
_init
File metadata and controls
executable file
·104 lines (87 loc) · 2.24 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
# shellcheck disable=SC2034
# fail wait when any children fails
set -m
set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace
# Set magic variables for current file & dir
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)"
cd "${ROOT_DIR}"
TMP_DIR="$ROOT_DIR/tmp"
BASE_DIR="$TMP_DIR/base"
DIST_DIR="$ROOT_DIR/dist"
DIST_APT_DIR="$ROOT_DIR/dist/apt"
mkdir -p "$TMP_DIR"
mkdir -p "$DIST_DIR"
PLATFORMS=(
darwin-x64
)
function script () {
"$ROOT_DIR/scripts/$1"
}
CHANNEL=$(script "_vars/channel")
VERSION=$(script "_vars/version")
SHORT_VERSION=$(node -p "require('$ROOT_DIR/package.json').version")
DEB_VERSION="${SHORT_VERSION}-1"
function archs () {
if [ "$OS" = darwin ]; then
echo "x64"
elif [ "$OS" = windows ]; then
echo "x64|x86"
elif [ "$OS" = linux ]; then
echo "x64|x86|arm"
fi
}
function setos () {
export OS=$1
if [ ! -z "${ARCH:-}" ]; then
setarch "$ARCH"
fi
}
function setarch () {
export ARCH=$1
export VERSIONED_BASE="heroku-cli-v${VERSION}-${OS}-${ARCH}"
export UNVERSIONED_BASE="heroku-cli-${OS}-${ARCH}"
export WORKSPACE_DIR="$TMP_DIR/${OS}_${ARCH}"
export TGZ_PATH="$DIST_DIR/$UNVERSIONED_BASE.tar.gz"
export TXZ_PATH="$DIST_DIR/$UNVERSIONED_BASE.tar.xz"
if [ "$OS" = linux ]; then
if [ "$ARCH" = x64 ]; then
export DEB_ARCH=amd64
elif [ "$ARCH" = x86 ]; then
export DEB_ARCH=i386
elif [ "$ARCH" = arm ]; then
export DEB_ARCH=armel
fi
export VERSIONED_DEB_BASE="heroku_${DEB_VERSION}_$DEB_ARCH"
export UNVERSIONED_DEB_BASE="heroku_$DEB_ARCH"
export VERSIONED_DEB_PATH="$DIST_APT_DIR/$VERSIONED_DEB_BASE.deb"
export UNVERSIONED_DEB_PATH="$DIST_APT_DIR/$UNVERSIONED_DEB_BASE.deb"
fi
}
function bg () {
"$@" &
pids="${pids:-} $!"
}
function wait_all () {
for pid in $pids; do
wait "${pid}" || exit 1
done
}
function s3upload () {
aws s3 cp --cache-control max-age=86400 "$@"
}
if [[ "${CIRCLE_JOB-}" == build_os_* ]]; then
IFS='_' read -ra _platform <<< "$CIRCLE_JOB"
export OS=${_platform[1]}
fi
if [[ "${CIRCLE_JOB-}" == build_os_* ]]; then
IFS='_' read -ra _platform <<< "$CIRCLE_JOB"
export OS=${_platform[2]}
fi
if [ ! -z "${OS:-}" ]; then
setos "$OS"
IFS='|' read -ra ARCHS <<< "$(archs)"
fi