|
1 | 1 | #!/usr/bin/env bash
|
2 | 2 | set -o errexit # Exit the script with error if any of the commands fail
|
3 | 3 |
|
4 |
| -NODE_LTS_VERSION=${NODE_LTS_VERSION:-14} |
| 4 | +# allowed values: |
| 5 | +## a nodejs major version (i.e., 16) |
| 6 | +## 'latest' |
| 7 | +## a full nodejs version, in the format v<major>.<minor>.patch |
| 8 | +export NODE_LTS_VERSION=${NODE_LTS_VERSION:-14} |
5 | 9 | # npm version can be defined in the environment for cases where we need to install
|
6 | 10 | # a version lower than latest to support EOL Node versions.
|
7 |
| -NPM_VERSION=${NPM_VERSION:-latest} |
| 11 | +export NPM_VERSION=${NPM_VERSION:-latest} |
8 | 12 |
|
9 |
| -source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh" |
10 |
| - |
11 |
| -if [[ -z "${npm_global_prefix}" ]]; then echo "npm_global_prefix is unset" && exit 1; fi |
12 |
| -if [[ -z "${NODE_ARTIFACTS_PATH}" ]]; then echo "NODE_ARTIFACTS_PATH is unset" && exit 1; fi |
13 |
| - |
14 |
| -CURL_FLAGS=( |
15 |
| - --fail # Exit code 1 if request fails |
16 |
| - --compressed # Request a compressed response should keep fetching fast |
17 |
| - --location # Follow a redirect |
18 |
| - --retry 8 # Retry HTTP 408, 429, 500, 502, 503 or 504, 8 times |
19 |
| - --silent # Do not print a progress bar |
20 |
| - --show-error # Despite the silent flag still print out errors |
21 |
| - --max-time 900 # 900 seconds is 15 minutes, evergreen times out at 20 |
22 |
| - --continue-at - # If a download is interrupted it can figure out where to resume |
23 |
| -) |
24 |
| - |
25 |
| -mkdir -p "$NODE_ARTIFACTS_PATH/npm_global" |
26 |
| - |
27 |
| -# Comparisons are all case insensitive |
28 |
| -shopt -s nocasematch |
29 |
| - |
30 |
| -# index.tab is a sorted tab separated values file with the following headers |
31 |
| -# 0 1 2 3 4 5 6 7 8 9 10 |
32 |
| -# version date files npm v8 uv zlib openssl modules lts security |
33 |
| -curl "${CURL_FLAGS[@]}" "https://nodejs.org/dist/index.tab" --output node_index.tab |
34 |
| - |
35 |
| -while IFS=$'\t' read -r -a row; do |
36 |
| - node_index_version="${row[0]}" |
37 |
| - node_index_major_version=$(echo $node_index_version | sed -E 's/^v([0-9]+).*$/\1/') |
38 |
| - node_index_date="${row[1]}" |
39 |
| - node_index_lts="${row[9]}" |
40 |
| - [[ "$node_index_version" = "version" ]] && continue # skip tsv header |
41 |
| - [[ "$NODE_LTS_VERSION" = "latest" ]] && break # first line is latest |
42 |
| - [[ "$NODE_LTS_VERSION" = "$node_index_major_version" ]] && break # case insensitive compare |
43 |
| -done < node_index.tab |
44 |
| - |
45 |
| -if [[ "$OS" = "Windows_NT" ]]; then |
46 |
| - operating_system="win" |
47 |
| -elif [[ $(uname) = "darwin" ]]; then |
48 |
| - operating_system="darwin" |
49 |
| -elif [[ $(uname) = "linux" ]]; then |
50 |
| - operating_system="linux" |
51 |
| -else |
52 |
| - echo "Unable to determine operating system: $operating_system" |
53 |
| - exit 1 |
54 |
| -fi |
55 |
| - |
56 |
| -architecture=$(uname -m) |
57 |
| -if [[ $architecture = "x86_64" ]]; then |
58 |
| - architecture="x64" |
59 |
| -elif [[ $architecture = "arm64" ]]; then |
60 |
| - architecture="arm64" |
61 |
| -elif [[ $architecture = "aarch64" ]]; then |
62 |
| - architecture="arm64" |
63 |
| -elif [[ $architecture == s390* ]]; then |
64 |
| - architecture="s390x" |
65 |
| -elif [[ $architecture == ppc* ]]; then |
66 |
| - architecture="ppc64le" |
67 |
| -else |
68 |
| - echo "Unable to determine operating system: $architecture" |
69 |
| - exit 1 |
70 |
| -fi |
71 |
| - |
72 |
| -file_extension="tar.gz" |
73 |
| -if [[ "$OS" = "Windows_NT" ]]; then file_extension="zip"; fi |
74 |
| - |
75 |
| -node_directory="node-${node_index_version}-${operating_system}-${architecture}" |
76 |
| -node_archive="${node_directory}.${file_extension}" |
77 |
| -node_archive_path="$NODE_ARTIFACTS_PATH/${node_archive}" |
78 |
| -node_download_url="https://nodejs.org/dist/${node_index_version}/${node_archive}" |
79 |
| - |
80 |
| -echo "Node.js ${node_index_version} for ${operating_system}-${architecture} released on ${node_index_date}" |
81 |
| - |
82 |
| -set -o xtrace |
83 |
| - |
84 |
| -curl "${CURL_FLAGS[@]}" "${node_download_url}" --output "$node_archive_path" |
85 |
| - |
86 |
| -if [[ "$file_extension" = "zip" ]]; then |
87 |
| - unzip -q "$node_archive_path" -d "${NODE_ARTIFACTS_PATH}" |
88 |
| - mkdir -p "${NODE_ARTIFACTS_PATH}/nodejs" |
89 |
| - # Windows "bins" are at the top level |
90 |
| - mv "${NODE_ARTIFACTS_PATH}/${node_directory}" "${NODE_ARTIFACTS_PATH}/nodejs/bin" |
91 |
| - # Need to add executable flag ourselves |
92 |
| - chmod +x "${NODE_ARTIFACTS_PATH}/nodejs/bin/node.exe" |
93 |
| - chmod +x "${NODE_ARTIFACTS_PATH}/nodejs/bin/npm" |
94 |
| -else |
95 |
| - tar -xf "$node_archive_path" -C "${NODE_ARTIFACTS_PATH}" |
96 |
| - mv "${NODE_ARTIFACTS_PATH}/${node_directory}" "${NODE_ARTIFACTS_PATH}/nodejs" |
97 |
| -fi |
98 |
| - |
99 |
| -if [[ $operating_system != "win" ]]; then |
100 |
| - npm install --global npm@$NPM_VERSION |
101 |
| - hash -r |
102 |
| -fi |
103 |
| - |
104 |
| -echo "npm location: $(which npm)" |
105 |
| -echo "npm version: $(npm -v)" |
| 13 | +source $DRIVERS_TOOLS/.evergreen/install-node.sh |
106 | 14 |
|
107 | 15 | npm install --build-from-source
|
108 | 16 | ldd build/*/kerberos.node || true
|
0 commit comments