|
1 | 1 | #!/usr/bin/env bash |
| 2 | +set -e |
| 3 | +source "$(dirname "$0")/utils.sh" |
| 4 | + |
2 | 5 | # DEPENDENCIES (binaries should be in PATH): |
3 | 6 | # 0. 'git' |
4 | 7 | # 1. 'curl' |
5 | 8 | # 2. 'nix-shell' |
6 | 9 |
|
7 | | -set -e |
8 | | - |
9 | 10 | CLUSTERS="$(xargs echo -n < "$(dirname "$0")"/../installer-clusters.cfg)" |
10 | 11 |
|
11 | | -usage() { |
12 | | - test -z "$1" || { echo "ERROR: $*" >&2; echo >&2; } |
13 | | - cat >&2 <<EOF |
14 | | - Usage: |
15 | | - $0 OPTIONS* |
16 | | -
|
17 | | - Build a Daedalus installer. |
18 | | -
|
19 | | - Options: |
20 | | - --clusters "[CLUSTER-NAME...]" |
21 | | - Build installers for CLUSTERS. Defaults to "mainnet staging testnet" |
22 | | - --fast-impure Fast, impure, incremental build |
23 | | - --build-id BUILD-NO Identifier of the build; defaults to '0' |
24 | | -
|
25 | | - --nix-path NIX-PATH NIX_PATH value |
26 | | -
|
27 | | - --upload-s3 Upload the installer to S3 |
28 | | - --test-installer Test the installer for installability |
29 | | -
|
30 | | - --verbose Verbose operation |
31 | | - --quiet Disable verbose operation |
32 | | -
|
33 | | -EOF |
34 | | - test -z "$1" || exit 1 |
35 | | -} |
36 | | - |
37 | | -arg2nz() { test $# -ge 2 -a ! -z "$2" || usage "empty value for" "$1"; } |
38 | | -fail() { echo "ERROR: $*" >&2; exit 1; } |
39 | | -retry() { |
40 | | - local tries=$1; arg2nz "iteration count" "$1"; shift |
41 | | - for i in $(seq 1 "${tries}") |
42 | | - do if "$@" |
43 | | - then return 0 |
44 | | - else echo "failed, retry #$i of ${tries}" |
45 | | - fi |
46 | | - sleep 5s |
47 | | - done |
48 | | - fail "persistent failure to exec: $*" |
49 | | -} |
50 | | - |
51 | 12 | ### |
52 | 13 | ### Argument processing |
53 | 14 | ### |
@@ -76,8 +37,8 @@ while test $# -ge 1 |
76 | 37 | do case "$1" in |
77 | 38 | --clusters ) CLUSTERS="$2"; shift;; |
78 | 39 | --fast-impure ) export fast_impure=true;; |
79 | | - --build-id ) arg2nz "build identifier" "$2"; build_id="$2"; shift;; |
80 | | - --nix-path ) arg2nz "NIX_PATH value" "$2"; |
| 40 | + --build-id ) validate_arguments "build identifier" "$2"; build_id="$2"; shift;; |
| 41 | + --nix-path ) validate_arguments "NIX_PATH value" "$2"; |
81 | 42 | export NIX_PATH="$2"; shift;; |
82 | 43 | --test-installer ) test_installer="--test-installer";; |
83 | 44 |
|
@@ -117,11 +78,11 @@ export PATH=$HOME/.local/bin:$PATH |
117 | 78 | if [ -n "${NIX_SSL_CERT_FILE-}" ]; then export SSL_CERT_FILE=$NIX_SSL_CERT_FILE; fi |
118 | 79 |
|
119 | 80 | upload_artifacts() { |
120 | | - buildkite-agent artifact upload "$@" --job "$BUILDKITE_JOB_ID" |
| 81 | + retry 5 buildkite-agent artifact upload "$@" --job "$BUILDKITE_JOB_ID" |
121 | 82 | } |
122 | 83 |
|
123 | 84 | upload_artifacts_public() { |
124 | | - buildkite-agent artifact upload "$@" "${ARTIFACT_BUCKET:-}" --job "$BUILDKITE_JOB_ID" |
| 85 | + retry 5 buildkite-agent artifact upload "$@" "${ARTIFACT_BUCKET:-}" --job "$BUILDKITE_JOB_ID" |
125 | 86 | } |
126 | 87 |
|
127 | 88 | function checkItnCluster() { |
|
0 commit comments