Skip to content

Commit c99c8c8

Browse files
committed
Install system lib in build.sh
1 parent d67774e commit c99c8c8

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

test/build.sh

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ NPD_STAGING_REGISTRY=${NPD_STAGING_REGISTRY:-"gcr.io/node-problem-detector-stagi
2727
PR_ENV_FILENAME=${PR_ENV_FILENAME:-"pr.env"}
2828
CI_ENV_FILENAME=${CI_ENV_FILENAME:-"ci.env"}
2929
ROOT_PATH=$(git rev-parse --show-toplevel)
30+
GCS_URL_PREFIX="https://storage.googleapis.com/"
3031

3132
function print-help() {
3233
echo "Usage: build.sh [args...]"
3334
echo "Available arguments:"
34-
echo " pr [pull_refs]: Build node-problem-detector for presubmit jobs and push to staging."
35-
echo " ci: Build node-problem-detector for CI jobs and push to staging."
36-
echo " get-ci-env: Download environment variable file from staging for CI job."
35+
echo " pr [pull_number]: Build node-problem-detector for presubmit jobs and push to staging."
36+
echo " ci: Build node-problem-detector for CI jobs and push to staging."
37+
echo " get-ci-env: Download environment variable file from staging for CI job."
3738
}
3839

3940
function get-version() {
@@ -44,6 +45,11 @@ function get-version() {
4445
fi
4546
}
4647

48+
function install-lib() {
49+
apt-get update
50+
apt-get install -y libsystemd-dev
51+
}
52+
4753
function write-env-file() {
4854
local -r env_file="${1}"
4955
if [[ -z "${env_file}" ]]; then
@@ -52,20 +58,29 @@ function write-env-file() {
5258
fi
5359

5460
cat > ${ROOT_PATH}/${env_file} <<EOF
55-
export EXTRA_ENVS=NODE_PROBLEM_DETECTOR_IMAGE=${REGISTRY}/node-problem-detector:${TAG}
56-
export NODE_PROBLEM_DETECTOR_RELEASE_PATH=${UPLOAD_PATH}
61+
export KUBE_ENABLE_NODE_PROBLEM_DETECTOR=standalone
62+
export NODE_PROBLEM_DETECTOR_RELEASE_PATH=${UPLOAD_PATH/gs:\/\//${GCS_URL_PREFIX}}
5763
export NODE_PROBLEM_DETECTOR_VERSION=${VERSION}
5864
export NODE_PROBLEM_DETECTOR_TAR_HASH=$(sha1sum ${ROOT_PATH}/node-problem-detector-${VERSION}.tar.gz | cut -d ' ' -f1)
65+
export EXTRA_ENVS=NODE_PROBLEM_DETECTOR_IMAGE=${REGISTRY}/node-problem-detector:${TAG}
5966
EOF
67+
68+
set -x
69+
cat ${ROOT_PATH}/${env_file}
70+
set +x
6071
}
6172

6273
function build-pr() {
63-
local -r PR="${1}"
64-
if [[ -z "${PR}" ]]; then
65-
echo "ERROR: pull_refs is missing."
74+
local -r PR_NUMBER="${1}"
75+
if [[ -z "${PR_NUMBER}" ]]; then
76+
echo "ERROR: pull_number is missing."
6677
print-help
6778
exit 1
6879
fi
80+
# Use the PR number and current time as the name, e.g., pr261-20190314.224907.862195792
81+
local -r PR="pr${PR_NUMBER}-$(date +%Y%m%d.%H%M%S.%N)"
82+
echo "Building for PR ${PR}..."
83+
install-lib
6984

7085
export UPLOAD_PATH="${NPD_STAGING_PATH}/pr/${PR}"
7186
export REGISTRY="${NPD_STAGING_REGISTRY}/pr/${PR}"
@@ -76,6 +91,7 @@ function build-pr() {
7691
}
7792

7893
function build-ci() {
94+
install-lib
7995
export UPLOAD_PATH="${NPD_STAGING_PATH}/ci"
8096
export REGISTRY="${NPD_STAGING_REGISTRY}/ci"
8197
export VERSION=$(get-version)
@@ -101,7 +117,7 @@ COMMAND="${1}"
101117

102118
if [[ "${COMMAND}" == "pr" ]]; then
103119
if [[ "$#" -ne 2 ]]; then
104-
echo "ERROR: pull_refs is missing."
120+
echo "ERROR: pull_number is missing."
105121
print-help
106122
exit 1
107123
fi
@@ -110,9 +126,10 @@ elif [[ "${COMMAND}" == "ci" ]]; then
110126
build-ci
111127
elif [[ "${COMMAND}" == "get-ci-env" ]]; then
112128
get-ci-env
129+
elif [[ "${COMMAND}" == "install-lib" ]]; then
130+
install-lib
113131
else
114132
echo "ERROR: Invalid command."
115133
print-help
116134
exit 1
117135
fi
118-

0 commit comments

Comments
 (0)