@nodenv/node-build 5.2.0 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,11 +13,9 @@ https://github.com/nodenv/node-build/releases/latest)
13
13
  https://img.shields.io/npm/v/@nodenv/node-build?logo=npm&logoColor=white)](
14
14
  https://www.npmjs.com/package/@nodenv/node-build/v/latest)
15
15
 
16
- node-build is a command-line utility that makes it easy to install virtually any
17
- version of Node, from source or precompiled binary.
16
+ node-build is a command-line tool that simplifies installation of any Node version from source or precompiled binary on Unix-like systems.
18
17
 
19
- It is available as a plugin for [nodenv][] that
20
- provides the `nodenv install` command, or as a standalone program.
18
+ It is available as a plugin for [nodenv][] as the `nodenv install` command, or as a standalone program as the `node-build` command.
21
19
 
22
20
  <!-- toc -->
23
21
 
@@ -42,41 +40,34 @@ provides the `nodenv install` command, or as a standalone program.
42
40
 
43
41
  ## Installation
44
42
 
43
+ ### Homebrew package manager
45
44
  ```sh
46
- # Using Homebrew on macOS
47
- $ brew install node-build
48
-
49
- # As a nodenv plugin
50
- $ mkdir -p "$(nodenv root)"/plugins
51
- $ git clone https://github.com/nodenv/node-build.git "$(nodenv root)"/plugins/node-build
52
-
53
- # As a standalone program
54
- $ git clone https://github.com/nodenv/node-build.git
55
- $ PREFIX=/usr/local ./node-build/install.sh
45
+ brew install node-build
56
46
  ```
57
47
 
58
- ### Upgrading
59
-
48
+ Upgrade with:
60
49
  ```sh
61
- # Via Homebrew
62
- $ brew update && brew upgrade node-build
50
+ brew upgrade node-build
51
+ ```
63
52
 
64
- # As a nodenv plugin
65
- $ git -C "$(nodenv root)"/plugins/node-build pull
53
+ ### Clone as nodenv plugin using git
54
+ ```sh
55
+ git clone https://github.com/nodenv/node-build.git "$(nodenv root)"/plugins/node-build
66
56
  ```
67
57
 
68
- #### Updating available build versions
58
+ Upgrade with:
59
+ ```sh
60
+ git -C "$(nodenv root)"/plugins/node-build pull
61
+ ```
69
62
 
70
- To grab the latest versions from nodejs.org and generate definition files for
71
- node-build to use, check out the [node-build-update-defs][] plugin.
72
- Once installed:
63
+ ### Install manually as a standalone program
73
64
 
74
- ``` shell
75
- nodenv update-version-defs
65
+ First, download a tarball from https://github.com/nodenv/node-build/releases/latest. Then:
66
+ ```sh
67
+ tar -xzf node-build-*.tar.gz
68
+ PREFIX=/usr/local ./node-build-*/install.sh
76
69
  ```
77
70
 
78
- No need to wait for node-build to provide the latest definitions!
79
-
80
71
  ## Usage
81
72
 
82
73
  ### Basic Usage
@@ -91,9 +82,17 @@ $ node-build --definitions # lists all available versions of Nod
91
82
  $ node-build 10.13.0 ~/local/node-10.13.0 # installs Node 10.13.0 to ~/local/node-10.13.0
92
83
  ```
93
84
 
94
- node-build does not check for system dependencies before downloading and
95
- attempting to compile the Node source. Please ensure that [all requisite
96
- libraries][build-env] are available on your system.
85
+ > **Warning**
86
+ > node-build mostly does not verify that system dependencies are present before downloading and attempting to compile Node from source. Please ensure that [all requisite libraries][build-env] such as build tools and development headers are already present on your system.
87
+
88
+ Firstly, if a precompiled binary exists for your platform, node-build downloads and installs it.
89
+ Otherwise it will build node from source.
90
+ Basically, what node-build does when installing a Node version is this:
91
+ - Downloads an official tarball of Node source code;
92
+ - Extracts the archive into a temporary directory on your system;
93
+ - Executes `./configure --prefix=/path/to/destination` in the source code;
94
+ - Runs `make install` to compile Node;
95
+ - Verifies that the installed Node is functional.
97
96
 
98
97
  ### Advanced Usage
99
98
 
@@ -106,12 +105,20 @@ instead of compiling from source. To force compilation, pass the `-c` or
106
105
 
107
106
  #### Custom Build Definitions
108
107
 
109
- If you wish to develop and install a version of Node that is not yet supported
110
- by node-build, you may specify the path to a custom “build definition file” in
111
- place of a Node version number.
108
+ To install a version of Node that is not recognized by node-build, you can specify the path to a custom build definition file in place of a Node version number.
109
+
110
+ Check out [default build definitions][definitions] as examples on how to write definition files.
112
111
 
113
- Use the [default build definitions][definitions] as a template for your custom
114
- definitions.
112
+ ##### Generating Latest-Release Build Definitions
113
+
114
+ Additionally, check out the [node-build-update-defs][] plugin.
115
+ It generates the standard build definitions for releases available from nodejs.org.
116
+ This allows you to install node versions as soon as they are available from nodejs.org,
117
+ without waiting for node-build itself to provide them. Once installed:
118
+
119
+ ``` shell
120
+ nodenv update-version-defs
121
+ ```
115
122
 
116
123
  #### Custom Build Configuration
117
124
 
@@ -144,9 +151,7 @@ The build process may be configured through the following environment variables:
144
151
 
145
152
  #### Applying Patches
146
153
 
147
- Both `nodenv install` and `node-build` support the `--patch` (`-p`) flag to apply
148
- a patch to the Node (/iojs/chakracore) source code before building.
149
- Patches are read from `STDIN`:
154
+ Both `nodenv install` and `node-build` commands support the `-p/--patch` flag to apply a patch to the Node source code before building. Patches are read from standard input:
150
155
 
151
156
  ```sh
152
157
  # applying a single patch
@@ -161,12 +166,9 @@ $ cat fix1.patch fix2.patch | nodenv install --patch 11.1.0
161
166
 
162
167
  #### Checksum Verification
163
168
 
164
- If you have the `shasum`, `openssl`, or `sha256sum` tool installed, node-build will
165
- automatically verify the SHA2 checksum of each downloaded package before
166
- installing it.
169
+ All Node definition files bundled with node-build include checksums for packages, meaning that all externally downloaded packages are automatically checked for integrity after fetching.
167
170
 
168
- Checksums are optional and specified as anchors on the package URL in each
169
- definition. All definitions bundled with node-build include checksums.
171
+ See the next section for more information on how to author checksums.
170
172
 
171
173
  #### Package Mirrors
172
174
 
@@ -232,13 +234,13 @@ Be sure to include the full build log for build failures.
232
234
  Forked from [Sam Stephenson][]'s [ruby-build][] by [Will McKenzie][]
233
235
  and modified for node.
234
236
 
235
- [nodenv]: https://github.com/nodenv/nodenv
236
- [ruby-build]: https://github.com/rbenv/ruby-build
237
- [definitions]: https://github.com/nodenv/node-build/tree/main/share/node-build
238
- [wiki]: https://github.com/nodenv/node-build/wiki
239
- [ruby-build wiki]: https://github.com/rbenv/ruby-build/wiki
240
- [build-env]: https://github.com/nodenv/node-build/wiki#suggested-build-environment
241
- [issue tracker]: https://github.com/nodenv/node-build/issues
242
- [node-build-update-defs]: https://github.com/nodenv/node-build-update-defs
243
- [Sam Stephenson]: https://github.com/sstephenson
244
- [Will McKenzie]: https://github.com/oinutter
237
+ [nodenv]: https://github.com/nodenv/nodenv#readme
238
+ [definitions]: https://github.com/nodenv/node-build/tree/main/share/node-build
239
+ [wiki]: https://github.com/nodenv/node-build/wiki
240
+ [build-env]: https://github.com/nodenv/node-build/wiki#suggested-build-environment
241
+ [issue tracker]: https://github.com/nodenv/node-build/issues
242
+ [node-build-update-defs]: https://github.com/nodenv/node-build-update-defs
243
+ [Sam Stephenson]: https://github.com/sstephenson
244
+ [Will McKenzie]: https://github.com/oinutter
245
+ [ruby-build]: https://github.com/rbenv/ruby-build
246
+ [ruby-build wiki]: https://github.com/rbenv/ruby-build/wiki
package/bin/node-build CHANGED
@@ -15,7 +15,7 @@
15
15
  # --version Show version of node-build
16
16
  #
17
17
 
18
- NODE_BUILD_VERSION=5.2.0
18
+ NODE_BUILD_VERSION=5.3.1
19
19
 
20
20
  OLDIFS="$IFS"
21
21
 
@@ -27,10 +27,15 @@ lib() {
27
27
  parse_options() {
28
28
  OPTIONS=()
29
29
  ARGUMENTS=()
30
+ EXTRA_ARGUMENTS=()
30
31
  local arg option index
31
32
 
32
- for arg in "$@"; do
33
- if [ "${arg:0:1}" = "-" ]; then
33
+ while [ $# -gt 0 ]; do
34
+ arg="$1"
35
+ if [ "$arg" == "--" ]; then
36
+ shift 1
37
+ break
38
+ elif [ "${arg:0:1}" = "-" ]; then
34
39
  if [ "${arg:1:1}" = "-" ]; then
35
40
  OPTIONS[${#OPTIONS[*]}]="${arg:2}"
36
41
  else
@@ -41,15 +46,19 @@ lib() {
41
46
  index=$((index+1))
42
47
  done
43
48
  fi
49
+ shift 1
44
50
  else
45
51
  ARGUMENTS[${#ARGUMENTS[*]}]="$arg"
52
+ shift 1
46
53
  fi
47
54
  done
55
+
56
+ EXTRA_ARGUMENTS=("$@")
48
57
  }
49
58
 
50
- if [ "$1" == "--$FUNCNAME" ]; then
51
- declare -f "$FUNCNAME"
52
- echo "$FUNCNAME \"\$1\";"
59
+ if [ "$1" == "--${FUNCNAME[0]}" ]; then
60
+ declare -f "${FUNCNAME[0]}"
61
+ echo "${FUNCNAME[0]} \"\$1\";"
53
62
  exit
54
63
  fi
55
64
  }
@@ -63,20 +72,21 @@ resolve_link() {
63
72
  abs_dirname() {
64
73
  local path="$1"
65
74
  local cwd
66
- cwd="$(pwd)"
75
+ cwd="$(pwd || true)"
67
76
 
68
77
  while [ -n "$path" ]; do
69
- cd "${path%/*}"
78
+ cd "${path%/*}" || return 1
70
79
  local name="${path##*/}"
71
80
  path="$(resolve_link "$name" || true)"
72
81
  done
73
82
 
74
83
  pwd
75
- cd "$cwd"
84
+ cd "$cwd" || return 1
76
85
  }
77
86
 
78
87
  capitalize() {
79
- printf "%s" "$1" | tr '[:lower:]' '[:upper:]'
88
+ # shellcheck disable=SC2018,SC2019
89
+ printf "%s" "$1" | tr 'a-z' 'A-Z'
80
90
  }
81
91
 
82
92
  sanitize() {
@@ -84,7 +94,7 @@ sanitize() {
84
94
  }
85
95
 
86
96
  colorize() {
87
- if [ -t 1 ]; then printf "\\e[%sm%s\\e[m" "$1" "$2"
97
+ if [ -t 1 ]; then printf "\e[%sm%s\e[m" "$1" "$2"
88
98
  else echo -n "$2"
89
99
  fi
90
100
  }
@@ -95,7 +105,9 @@ os_information() {
95
105
  elif type -p sw_vers >/dev/null; then
96
106
  echo "$(sw_vers -productName) $(sw_vers -productVersion)"
97
107
  elif [ -r /etc/os-release ]; then
108
+ # shellcheck disable=SC1091
98
109
  source /etc/os-release
110
+ # shellcheck disable=SC2153
99
111
  echo "$NAME $VERSION_ID"
100
112
  else
101
113
  local os
@@ -106,17 +118,26 @@ os_information() {
106
118
 
107
119
  is_mac() {
108
120
  [ "$(uname -s)" = "Darwin" ] || return 1
109
- [ $# -eq 0 ] || test "$(osx_version)" "$@"
121
+ [ $# -eq 0 ] || [ "$(osx_version)" -ge "$1" ]
122
+ }
123
+
124
+ is_freebsd() {
125
+ [ "$(uname -s)" = "FreeBSD" ]
126
+ }
127
+
128
+ freebsd_package_prefix() {
129
+ local package="$1"
130
+ pkg info --prefix "$package" 2>/dev/null | cut -wf2
110
131
  }
111
132
 
112
133
  # 9.1 -> 901
113
134
  # 10.9 -> 1009
114
135
  # 10.10 -> 1010
115
136
  osx_version() {
116
- local -a ver
117
- IFS=. ver=( $(sw_vers -productVersion) )
137
+ local ver
138
+ IFS=. read -d "" -r -a ver <<<"$(sw_vers -productVersion)" || true
118
139
  IFS="$OLDIFS"
119
- echo $(( ${ver[0]}*100 + ${ver[1]} ))
140
+ echo $(( ver[0]*100 + ver[1] ))
120
141
  }
121
142
 
122
143
  build_failed() {
@@ -132,9 +153,9 @@ build_failed() {
132
153
  if ! rmdir "${BUILD_PATH}" 2>/dev/null; then
133
154
  echo "Inspect or clean up the working tree at ${BUILD_PATH}"
134
155
 
135
- if file_is_not_empty "$LOG_PATH"; then
156
+ if [ -n "$(head -1 "$LOG_PATH" 2>/dev/null)" ]; then
136
157
  colorize 33 "Results logged to ${LOG_PATH}"
137
- printf "\\n\\n"
158
+ printf "\n\n"
138
159
  echo "Last 10 log lines:"
139
160
  tail -n 10 "$LOG_PATH"
140
161
  fi
@@ -143,18 +164,6 @@ build_failed() {
143
164
  exit 1
144
165
  }
145
166
 
146
- file_is_not_empty() {
147
- local filename="$1"
148
- local line_count="$(wc -l "$filename" 2>/dev/null || true)"
149
-
150
- if [ -n "$line_count" ]; then
151
- words=( $line_count )
152
- [ "${words[0]}" -gt 0 ]
153
- else
154
- return 1
155
- fi
156
- }
157
-
158
167
  num_cpu_cores() {
159
168
  local num
160
169
  case "$(uname -s)" in
@@ -237,18 +246,6 @@ binary() {
237
246
  fi
238
247
  }
239
248
 
240
- install_package() {
241
- install_package_using "tarball" 1 "$@"
242
- }
243
-
244
- install_git() {
245
- install_package_using "git" 2 "$@"
246
- }
247
-
248
- install_svn() {
249
- install_package_using "svn" 2 "$@"
250
- }
251
-
252
249
  install_binary() {
253
250
  local url name
254
251
 
@@ -260,6 +257,14 @@ install_binary() {
260
257
  install_package "$name" "$url" copy "${@:2}"
261
258
  }
262
259
 
260
+ install_package() {
261
+ install_package_using "tarball" 1 "$@"
262
+ }
263
+
264
+ install_git() {
265
+ install_package_using "git" 2 "$@"
266
+ }
267
+
263
268
  install_package_using() {
264
269
  local package_type="$1"
265
270
  local package_type_nargs="$2"
@@ -270,7 +275,7 @@ install_package_using() {
270
275
  local make_args=( "$package_name" )
271
276
  local arg last_arg
272
277
 
273
- for arg in "${@:$(( $package_type_nargs + 1 ))}"; do
278
+ for arg in "${@:$(( package_type_nargs + 1 ))}"; do
274
279
  if [ "$last_arg" = "--if" ]; then
275
280
  "$arg" || return 0
276
281
  elif [ "$arg" != "--if" ]; then
@@ -287,9 +292,11 @@ install_package_using() {
287
292
  return 0
288
293
  fi
289
294
 
295
+ # shellcheck disable=SC2164
290
296
  pushd "$BUILD_PATH" >&4
291
297
  "fetch_${package_type}" "${fetch_args[@]}"
292
298
  make_package "${make_args[@]}"
299
+ # shellcheck disable=SC2164
293
300
  popd >&4
294
301
 
295
302
  { echo "Installed ${package_name} to ${PREFIX_PATH}"
@@ -301,10 +308,12 @@ make_package() {
301
308
  local package_name="$1"
302
309
  shift
303
310
 
311
+ # shellcheck disable=SC2164
304
312
  pushd "$package_name" >&4
305
313
  before_install_package "$package_name"
306
314
  build_package "$package_name" "$@"
307
315
  after_install_package "$package_name"
316
+ # shellcheck disable=SC2164
308
317
  popd >&4
309
318
  }
310
319
 
@@ -361,7 +370,11 @@ has_checksum_support() {
361
370
  local has_checksum_var="HAS_CHECKSUM_SUPPORT_${checksum_command}"
362
371
 
363
372
  if [ -z "${!has_checksum_var+defined}" ]; then
364
- printf -v "$has_checksum_var" "$(echo test | "$checksum_command" >/dev/null; echo $?)"
373
+ if "$checksum_command" <<<"test" >/dev/null; then
374
+ printf -v "$has_checksum_var" 0 # success
375
+ else
376
+ printf -v "$has_checksum_var" 1 # error
377
+ fi
365
378
  fi
366
379
  return "${!has_checksum_var}"
367
380
  }
@@ -370,7 +383,7 @@ verify_checksum() {
370
383
  local checksum_command
371
384
  local filename="$1"
372
385
  local expected_checksum
373
- expected_checksum="$(echo "$2" | tr '[:upper:]' '[:lower:]')"
386
+ expected_checksum="$(tr 'A-F' 'a-f' <<<"$2")"
374
387
 
375
388
  # If the specified filename doesn't exist, return success
376
389
  [ -e "$filename" ] || return 0
@@ -394,7 +407,7 @@ verify_checksum() {
394
407
 
395
408
  # If the computed checksum is empty, return failure
396
409
  local computed_checksum
397
- computed_checksum=$($checksum_command < "$filename" | tr '[:upper:]' '[:lower:]')
410
+ computed_checksum="$("$checksum_command" < "$filename" | tr 'A-F' 'a-f')"
398
411
  [ -n "$computed_checksum" ] || return 1
399
412
 
400
413
  if [ "$expected_checksum" != "$computed_checksum" ]; then
@@ -431,11 +444,13 @@ detect_http_client() {
431
444
  }
432
445
 
433
446
  http_head_aria2c() {
447
+ # shellcheck disable=SC2086
434
448
  aria2c --dry-run --no-conf=true ${ARIA2_OPTS} "$1" >&4 2>&1
435
449
  }
436
450
 
437
451
  http_get_aria2c() {
438
452
  local out="${2:-$(mktemp "out.XXXXXX")}"
453
+ # shellcheck disable=SC2086
439
454
  if aria2c --allow-overwrite=true --no-conf=true -o "${out}" ${ARIA2_OPTS} "$1" >&4; then
440
455
  [ -n "$2" ] || cat "${out}"
441
456
  else
@@ -444,18 +459,22 @@ http_get_aria2c() {
444
459
  }
445
460
 
446
461
  http_head_curl() {
462
+ # shellcheck disable=SC2086
447
463
  curl -qsILf ${CURL_OPTS} "$1" >&4 2>&1
448
464
  }
449
465
 
450
466
  http_get_curl() {
467
+ # shellcheck disable=SC2086
451
468
  curl -q -o "${2:--}" -sSLf ${CURL_OPTS} "$1"
452
469
  }
453
470
 
454
471
  http_head_wget() {
472
+ # shellcheck disable=SC2086
455
473
  wget -q --spider ${WGET_OPTS} "$1" >&4 2>&1
456
474
  }
457
475
 
458
476
  http_get_wget() {
477
+ # shellcheck disable=SC2086
459
478
  wget -nv ${WGET_OPTS} -O "${2:--}" "$1"
460
479
  }
461
480
 
@@ -476,7 +495,7 @@ fetch_tarball() {
476
495
  package_url="${package_url%%#*}"
477
496
 
478
497
  if [ -z "$NODE_BUILD_SKIP_MIRROR" ]; then
479
- mirror_url="$("${NODE_BUILD_MIRROR_CMD:=mirror}" $package_url $checksum 2>&4)" || unset mirror_url
498
+ mirror_url="$("${NODE_BUILD_MIRROR_CMD:-mirror}" $package_url $checksum 2>&4)" || unset mirror_url
480
499
  fi
481
500
  fi
482
501
 
@@ -501,11 +520,13 @@ fetch_tarball() {
501
520
  local tarball_filename
502
521
  tarball_filename="$(basename "$package_url")"
503
522
  echo "Downloading ${tarball_filename}..." >&2
523
+ # shellcheck disable=SC2015
524
+ http head "$mirror_url" &&
504
525
  download_tarball "$mirror_url" "$package_filename" "$checksum" ||
505
526
  download_tarball "$package_url" "$package_filename" "$checksum"
506
527
  fi
507
528
 
508
- { if $tar $tar_args "$package_filename"; then
529
+ { if $tar "$tar_args" "$package_filename"; then
509
530
  if [ ! -d "$package_name" ]; then
510
531
  extracted_dir="$(find_extracted_directory)"
511
532
  mv "$extracted_dir" "$package_name"
@@ -582,22 +603,26 @@ fetch_git() {
582
603
 
583
604
  if type git &>/dev/null; then
584
605
  if [ -n "$NODE_BUILD_CACHE_PATH" ]; then
606
+ # shellcheck disable=SC2164
585
607
  pushd "$NODE_BUILD_CACHE_PATH" >&4
586
608
  local clone_name
587
609
  clone_name="$(sanitize "$git_url")"
588
- if [ -e "${clone_name}" ]; then
589
- { cd "${clone_name}"
610
+ if [ -e "$clone_name" ]; then
611
+ { # shellcheck disable=SC2164
612
+ cd "$clone_name"
590
613
  git fetch --force "$git_url" "+${git_ref}:${git_ref}"
591
614
  } >&4 2>&1
592
615
  else
593
616
  git clone --bare --branch "$git_ref" "$git_url" "${clone_name}" >&4 2>&1
594
617
  fi
595
618
  git_url="$NODE_BUILD_CACHE_PATH/${clone_name}"
619
+ # shellcheck disable=SC2164
596
620
  popd >&4
597
621
  fi
598
622
 
599
623
  if [ -e "${package_name}" ]; then
600
- ( cd "${package_name}"
624
+ ( # shellcheck disable=SC2164
625
+ cd "${package_name}"
601
626
  git fetch --depth 1 origin "+${git_ref}"
602
627
  git checkout -q -B "$git_ref" "origin/${git_ref}"
603
628
  ) >&4 2>&1
@@ -610,23 +635,6 @@ fetch_git() {
610
635
  fi
611
636
  }
612
637
 
613
- fetch_svn() {
614
- local package_name="$1"
615
- local svn_url="$2"
616
- local svn_rev="$3"
617
-
618
- echo "Checking out ${svn_url}..." >&2
619
-
620
- if type svn &>/dev/null; then
621
- svn co -r "$svn_rev" "$svn_url" "${package_name}" >&4 2>&1
622
- elif type svnlite &>/dev/null; then
623
- svnlite co -r "$svn_rev" "$svn_url" "${package_name}" >&4 2>&1
624
- else
625
- echo "error: please install Subversion and try again" >&2
626
- exit 1
627
- fi
628
- }
629
-
630
638
  build_package() {
631
639
  local package_name="$1"
632
640
  shift
@@ -649,9 +657,12 @@ build_package() {
649
657
  package_option() {
650
658
  local package_name="$1"
651
659
  local command_name="$2"
652
- local variable="$(capitalize "${package_name}_${command_name}")_OPTS_ARRAY"
653
- local array="${variable[@]}"
660
+ local variable
661
+ # e.g. NODE_CONFIGURE_OPTS_ARRAY, OPENSSL_MAKE_OPTS_ARRAY
662
+ variable="$(capitalize "${package_name}_${command_name}")_OPTS_ARRAY"
663
+ local array="${variable}[@]"
654
664
  shift 2
665
+ # shellcheck disable=SC2034
655
666
  local value=( "${!array}" "$@" )
656
667
  eval "$variable=( \"\${value[@]}\" )"
657
668
  }
@@ -699,13 +710,15 @@ build_package_standard_build() {
699
710
  ( if [ "${CFLAGS+defined}" ] || [ "${!PACKAGE_CFLAGS+defined}" ]; then
700
711
  export CFLAGS="$CFLAGS ${!PACKAGE_CFLAGS}"
701
712
  fi
702
- if [ -z "$CC" ] && is_mac -ge 1010; then
713
+ if [ -z "$CC" ] && is_mac 1010; then
703
714
  export CC=clang
704
715
  fi
716
+ # shellcheck disable=SC2086,SC2153
705
717
  ${!PACKAGE_CONFIGURE:-./configure} --prefix="${!PACKAGE_PREFIX_PATH:-$PREFIX_PATH}" \
706
718
  "${!PACKAGE_CONFIGURE_OPTS_ARRAY}" $CONFIGURE_OPTS ${!PACKAGE_CONFIGURE_OPTS} || return 1
707
719
  ) >&4 2>&1
708
720
 
721
+ # shellcheck disable=SC2086
709
722
  { "$MAKE" "${!PACKAGE_MAKE_OPTS_ARRAY}" $MAKE_OPTS ${!PACKAGE_MAKE_OPTS}
710
723
  } >&4 2>&1
711
724
  }
@@ -718,6 +731,7 @@ build_package_standard_install() {
718
731
  local PACKAGE_MAKE_INSTALL_OPTS="${package_var_name}_MAKE_INSTALL_OPTS"
719
732
  local PACKAGE_MAKE_INSTALL_OPTS_ARRAY="${package_var_name}_MAKE_INSTALL_OPTS_ARRAY[@]"
720
733
 
734
+ # shellcheck disable=SC2086
721
735
  { "$MAKE" ${MAKE_INSTALL_TARGET:-install} "${!PACKAGE_MAKE_INSTALL_OPTS_ARRAY}" $MAKE_INSTALL_OPTS ${!PACKAGE_MAKE_INSTALL_OPTS}
722
736
  } >&4 2>&1
723
737
  }
@@ -799,18 +813,35 @@ fix_jxcore_directory_structure() {
799
813
  } >&4
800
814
  }
801
815
 
816
+ # Kept for backward compatibility
817
+ require_java7() {
818
+ require_java 7
819
+ }
820
+
821
+ # Kept for backward compatibility
822
+ require_gcc() {
823
+ :
824
+ }
825
+
826
+ # Kept for backward compatibility
827
+ require_llvm() {
828
+ :
829
+ }
830
+
802
831
  # Ensure that directories listed in LDFLAGS exist
803
832
  build_package_ldflags_dirs() {
804
- local arg dir
805
- set - $LDFLAGS
806
- while [ $# -gt 0 ]; do
833
+ local ldflags
834
+ read -d '' -r -a ldflags <<<"$LDFLAGS" || true
835
+ local index=0
836
+ local dir
837
+ while [ "$index" -lt "${#ldflags[@]}" ]; do
807
838
  dir=""
808
- case "$1" in
809
- -L ) dir="$2" ;;
810
- -L* ) dir="${1#-L}" ;;
839
+ case "${ldflags[index]}" in
840
+ -L ) dir="${ldflags[index+1]}" ;;
841
+ -L* ) dir="${ldflags[index]#-L}" ;;
811
842
  esac
812
843
  [ -z "$dir" ] || mkdir -p "$dir"
813
- shift 1
844
+ index=$((index+1))
814
845
  done
815
846
  }
816
847
 
@@ -892,9 +923,11 @@ unset KEEP_BUILD_PATH
892
923
  unset HAS_PATCH
893
924
  unset IPV4
894
925
  unset IPV6
926
+ unset EARLY_EXIT
895
927
 
896
928
  NODE_BUILD_INSTALL_PREFIX="$(abs_dirname "$0")/.."
897
929
 
930
+ # shellcheck disable=SC2206
898
931
  IFS=: NODE_BUILD_DEFINITIONS=($NODE_BUILD_DEFINITIONS ${NODE_BUILD_ROOT:-$NODE_BUILD_INSTALL_PREFIX}/share/node-build)
899
932
  IFS="$OLDIFS"
900
933
 
@@ -903,20 +936,16 @@ parse_options "$@"
903
936
  for option in "${OPTIONS[@]}"; do
904
937
  case "$option" in
905
938
  "h" | "help" )
906
- version
907
- echo
908
- usage 0
939
+ EARLY_EXIT=help
909
940
  ;;
910
941
  "definitions" )
911
- list_definitions
912
- exit 0
942
+ EARLY_EXIT=list_definitions
913
943
  ;;
914
944
  "c" | "compile" )
915
945
  SKIP_BINARY=true
916
946
  ;;
917
947
  "l" | "list")
918
- list_maintained_versions
919
- exit 0
948
+ EARLY_EXIT=list_maintained_versions
920
949
  ;;
921
950
  "k" | "keep" )
922
951
  KEEP_BUILD_PATH=true
@@ -934,18 +963,61 @@ for option in "${OPTIONS[@]}"; do
934
963
  IPV6=true
935
964
  ;;
936
965
  "version" )
937
- version
938
- exit 0
966
+ EARLY_EXIT=version
967
+ ;;
968
+ * )
969
+ printf "node-build: invalid flag '%s'\n" "$option" >&2
970
+ EARLY_EXIT=usage_error
939
971
  ;;
940
972
  esac
941
973
  done
942
974
 
943
- [ "${#ARGUMENTS[@]}" -eq 2 ] || usage 1 >&2
944
-
945
975
  DEFINITION_PATH="${ARGUMENTS[0]}"
946
- if [ -z "$DEFINITION_PATH" ]; then
976
+ PREFIX_PATH="${ARGUMENTS[1]}"
977
+
978
+ if [ -z "$EARLY_EXIT" ] && [ -z "$DEFINITION_PATH" ]; then
979
+ echo "node-build: missing definition argument" >&2
980
+ EARLY_EXIT=usage_error
981
+ fi
982
+
983
+ if [ -z "$EARLY_EXIT" ] && [ -z "$PREFIX_PATH" ]; then
984
+ echo "node-build: missing prefix argument" >&2
985
+ EARLY_EXIT=usage_error
986
+ fi
987
+
988
+ if [ "${#ARGUMENTS[@]}" -gt 2 ]; then
989
+ echo "node-build: expected at most 2 arguments, got [${ARGUMENTS[*]}]" >&2
990
+ EARLY_EXIT=usage_error
991
+ fi
992
+
993
+ if [ "${#EXTRA_ARGUMENTS[@]}" -gt 0 ]; then
994
+ NODE_CONFIGURE_OPTS_ARRAY=("${EXTRA_ARGUMENTS[@]}")
995
+ fi
996
+
997
+ case "$EARLY_EXIT" in
998
+ help )
999
+ version
1000
+ echo
1001
+ usage 0
1002
+ ;;
1003
+ version | list_definitions | list_maintained_versions )
1004
+ "$EARLY_EXIT"
1005
+ exit 0
1006
+ ;;
1007
+ usage_error )
1008
+ echo >&2
947
1009
  usage 1 >&2
948
- elif [ ! -f "$DEFINITION_PATH" ]; then
1010
+ ;;
1011
+ '' )
1012
+ ;;
1013
+ * )
1014
+ echo "unimplemented EARLY_EXIT: $EARLY_EXIT" >&2
1015
+ exit 1
1016
+ ;;
1017
+ esac
1018
+
1019
+ # expand the <definition> argument to full path of the definition file
1020
+ if [ ! -f "$DEFINITION_PATH" ]; then
949
1021
  for DEFINITION_DIR in "${NODE_BUILD_DEFINITIONS[@]}"; do
950
1022
  if [ -f "${DEFINITION_DIR}/${DEFINITION_PATH}" ]; then
951
1023
  DEFINITION_PATH="${DEFINITION_DIR}/${DEFINITION_PATH}"
@@ -959,10 +1031,8 @@ elif [ ! -f "$DEFINITION_PATH" ]; then
959
1031
  fi
960
1032
  fi
961
1033
 
962
- PREFIX_PATH="${ARGUMENTS[1]}"
963
- if [ -z "$PREFIX_PATH" ]; then
964
- usage 1 >&2
965
- elif [ "${PREFIX_PATH#/}" = "$PREFIX_PATH" ]; then
1034
+ # normalize the <prefix> argument
1035
+ if [ "${PREFIX_PATH#/}" = "$PREFIX_PATH" ]; then
966
1036
  PREFIX_PATH="${PWD}/${PREFIX_PATH}"
967
1037
  fi
968
1038
 
@@ -993,7 +1063,7 @@ if [ -n "$noexec" ]; then
993
1063
  fi
994
1064
 
995
1065
  if [ -z "$MAKE" ]; then
996
- if [ "FreeBSD" = "$(uname -s)" ]; then
1066
+ if is_freebsd; then
997
1067
  # node needs gmake on FreeBSD : https://github.com/nodejs/node/blob/0229e378e80948428cf7baa7b176939e879497cc/BSDmakefile#L7
998
1068
  export MAKE="gmake"
999
1069
  else
@@ -1007,21 +1077,20 @@ else
1007
1077
  unset NODE_BUILD_CACHE_PATH
1008
1078
  fi
1009
1079
 
1010
- ARIA2_OPTS="${NODE_BUILD_ARIA2_OPTS} ${IPV4+--disable-ipv6=true} ${IPV6+--disable-ipv6=false}"
1011
- CURL_OPTS="${NODE_BUILD_CURL_OPTS} ${IPV4+--ipv4} ${IPV6+--ipv6}"
1012
- WGET_OPTS="${NODE_BUILD_WGET_OPTS} ${IPV4+--inet4-only} ${IPV6+--inet6-only}"
1013
-
1014
1080
  NODE_BUILD_MIRROR_URL="${NODE_BUILD_MIRROR_URL%/}"
1015
1081
 
1016
1082
  if ! has_checksum_support compute_sha2 ||
1017
- [ -z "$NODE_BUILD_MIRROR_URL" -a -z "$NODE_BUILD_MIRROR_CMD" -a -z "$NODE_BUILD_MIRROR_PACKAGE_URL" ]; then
1083
+ [ -z "${NODE_BUILD_MIRROR_URL}${NODE_BUILD_MIRROR_CMD}${NODE_BUILD_MIRROR_PACKAGE_URL}" ]; then
1018
1084
  NODE_BUILD_SKIP_MIRROR=true
1019
1085
  fi
1020
1086
 
1087
+ ARIA2_OPTS="${NODE_BUILD_ARIA2_OPTS} ${IPV4+--disable-ipv6=true} ${IPV6+--disable-ipv6=false}"
1088
+ CURL_OPTS="${NODE_BUILD_CURL_OPTS} ${IPV4+--ipv4} ${IPV6+--ipv6}"
1089
+ WGET_OPTS="${NODE_BUILD_WGET_OPTS} ${IPV4+--inet4-only} ${IPV6+--inet6-only}"
1090
+
1021
1091
  SEED="$(date "+%Y%m%d%H%M%S").$$"
1022
1092
  LOG_PATH="${TMP}/node-build.${SEED}.log"
1023
1093
  NODE_BIN="${PREFIX_PATH}/bin/node"
1024
- CWD="$(pwd)"
1025
1094
 
1026
1095
  if [ -z "$NODE_BUILD_BUILD_PATH" ]; then
1027
1096
  BUILD_PATH="$(mktemp -d "${LOG_PATH%.log}.XXXXXX")"
@@ -1033,7 +1102,7 @@ exec 4<> "$LOG_PATH" # open the log file at fd 4
1033
1102
  if [ -n "$VERBOSE" ]; then
1034
1103
  tail -f "$LOG_PATH" &
1035
1104
  TAIL_PID=$!
1036
- trap "kill $TAIL_PID" SIGINT SIGTERM EXIT
1105
+ trap 'kill $TAIL_PID' SIGINT SIGTERM EXIT
1037
1106
  else
1038
1107
  if [ -z "$NODE_BUILD_TESTING" ]; then
1039
1108
  echo "To follow progress, use 'tail -f $LOG_PATH' or pass --verbose" >&2
@@ -1048,6 +1117,7 @@ unset NODELIB
1048
1117
 
1049
1118
  trap build_failed ERR
1050
1119
  mkdir -p "$BUILD_PATH"
1120
+ # shellcheck disable=SC1090
1051
1121
  source "$DEFINITION_PATH"
1052
1122
  [ -z "${KEEP_BUILD_PATH}" ] && rm -fr "$BUILD_PATH"
1053
1123
  trap - ERR
@@ -64,6 +64,23 @@ definitions() {
64
64
  node-build --definitions | $(type -p ggrep grep | head -1) -F "$query" || true
65
65
  }
66
66
 
67
+ suggest_selecting_global() {
68
+ local version_file
69
+ version_file="$(nodenv-version-file)"
70
+ [[ "$version_file" != "$NODENV_ROOT"/version || -e "$version_file" ]] && return 0
71
+ echo
72
+ colorize 1 "NOTE:"
73
+ echo -n " to activate this Node version as the new default, run: "
74
+ colorize 33 "nodenv global $VERSION_NAME"
75
+ echo
76
+ }
77
+
78
+ colorize() {
79
+ if [ -t 1 ]; then printf "\e[%sm%s\e[m" "$1" "$2"
80
+ else printf "%s" "$2"
81
+ fi
82
+ }
83
+
67
84
  indent() {
68
85
  sed 's/^/ /'
69
86
  }
@@ -86,7 +103,7 @@ for option in "${OPTIONS[@]}"; do
86
103
  ;;
87
104
  "l" | "list" )
88
105
  node-build --list
89
- {
106
+ [ ! -t 1 ] || {
90
107
  echo
91
108
  echo "Only latest stable releases for each Node implementation are shown."
92
109
  echo "Use 'nodenv install --list-all / -L' to show all local versions."
@@ -138,20 +155,19 @@ DEFINITION="${ARGUMENTS[0]}"
138
155
  # after the installation process.
139
156
  declare -a before_hooks after_hooks
140
157
 
158
+ # shellcheck disable=SC2317
141
159
  before_install() {
142
160
  local hook="$1"
143
161
  before_hooks["${#before_hooks[@]}"]="$hook"
144
162
  }
145
163
 
164
+ # shellcheck disable=SC2317
146
165
  after_install() {
147
166
  local hook="$1"
148
167
  after_hooks["${#after_hooks[@]}"]="$hook"
149
168
  }
150
169
 
151
- while IFS=$'\n' read -r script; do
152
- scripts+=("$script")
153
- done < <(nodenv-hooks install)
154
-
170
+ IFS=$'\n' read -d '' -r -a scripts <<<"$(nodenv-hooks install)" || true
155
171
  # shellcheck disable=SC1090
156
172
  for script in "${scripts[@]}"; do source "$script"; done
157
173
 
@@ -208,9 +224,12 @@ cleanup() {
208
224
 
209
225
  trap cleanup SIGINT
210
226
 
227
+ build_args=(${KEEP:+--keep} ${VERBOSE:+--verbose} ${HAS_PATCH:+--patch} ${SKIP_BINARY:+--compile} "$DEFINITION" "$PREFIX")
228
+ [ ${#EXTRA_ARGUMENTS[@]} -eq 0 ] || build_args+=(-- "${EXTRA_ARGUMENTS[@]}")
229
+
211
230
  # Invoke `node-build` and record the exit status in $STATUS.
212
231
  STATUS=0
213
- node-build $KEEP $VERBOSE $HAS_PATCH $SKIP_BINARY "$DEFINITION" "$PREFIX" || STATUS="$?"
232
+ node-build "${build_args[@]}" || STATUS="$?"
214
233
 
215
234
  # Display a more helpful message if the definition wasn't found.
216
235
  if [ "$STATUS" == "2" ]; then
@@ -225,14 +244,14 @@ if [ "$STATUS" == "2" ]; then
225
244
  echo "See all available versions with \`nodenv install --list'."
226
245
  echo
227
246
  echo -n "If the version you need is missing, try upgrading node-build"
228
- if [ "$here" != "${here#$(brew --prefix 2>/dev/null)}" ]; then
229
- printf ":\\n\\n"
230
- echo " brew update && brew upgrade node-build"
247
+ if [ "$here" != "${here#"$(brew --prefix 2>/dev/null)"}" ]; then
248
+ printf ":\n\n"
249
+ echo " brew upgrade node-build"
231
250
  elif [ -d "${here}/.git" ]; then
232
- printf ":\\n\\n"
251
+ printf ":\n\n"
233
252
  echo " git -C ${here} pull"
234
253
  else
235
- printf ".\\n"
254
+ printf ".\n"
236
255
  fi
237
256
  } >&2
238
257
  fi
@@ -243,6 +262,7 @@ for hook in "${after_hooks[@]}"; do eval "$hook"; done
243
262
  # Run `nodenv-rehash` after a successful installation.
244
263
  if [ "$STATUS" == "0" ]; then
245
264
  nodenv-rehash
265
+ suggest_selecting_global
246
266
  else
247
267
  cleanup
248
268
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodenv/node-build",
3
- "version": "5.2.0",
3
+ "version": "5.3.1",
4
4
  "description": "Install NodeJS versions",
5
5
  "homepage": "https://github.com/nodenv/node-build#readme",
6
6
  "license": "MIT",
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "https://github.com/nodenv/node-build.git"
14
+ "url": "git+https://github.com/nodenv/node-build.git"
15
15
  },
16
16
  "bugs": {
17
17
  "url": "https://github.com/nodenv/node-build/issues"
@@ -46,8 +46,8 @@
46
46
  "devDependencies": {
47
47
  "@nodenv/node-build-update-defs": "^2.11.1",
48
48
  "bats": "^1.11.0",
49
- "bats-assert": "jasonkarns/bats-assert-1",
49
+ "bats-assert": "github:jasonkarns/bats-assert-1",
50
50
  "bats-mock": "^1",
51
- "bats-support": "jasonkarns/bats-support"
51
+ "bats-support": "github:jasonkarns/bats-support"
52
52
  }
53
53
  }
@@ -0,0 +1,10 @@
1
+ binary aix-ppc64 "https://nodejs.org/dist/v22.3.0/node-v22.3.0-aix-ppc64.tar.gz#8c349a9164f25d8a1de886a47db045b50ae11aba4c4c1e1a4d1ac34a1e5d20e3"
2
+ binary darwin-arm64 "https://nodejs.org/dist/v22.3.0/node-v22.3.0-darwin-arm64.tar.gz#b6723f1e4972af1ca8a7ef9ec63305ee8cd4380fce3071e0e1630dfe055d77e3"
3
+ binary darwin-x64 "https://nodejs.org/dist/v22.3.0/node-v22.3.0-darwin-x64.tar.gz#7fe139f9d769d65c27212f8be8f858e1ee522edf3a66eed1d08d42ba102995f8"
4
+ binary linux-arm64 "https://nodejs.org/dist/v22.3.0/node-v22.3.0-linux-arm64.tar.gz#0e25b9a4bc78080de826a90dff82743bec6d9c5085186e75521dc195c8be9ce3"
5
+ binary linux-armv7l "https://nodejs.org/dist/v22.3.0/node-v22.3.0-linux-armv7l.tar.gz#46b640d23708f899689059cc2a8431842c2e3ad50a9144828ddabea5e1a7c3ae"
6
+ binary linux-ppc64le "https://nodejs.org/dist/v22.3.0/node-v22.3.0-linux-ppc64le.tar.gz#a01c2263a01efa7c6efa3607d202487127e268d73b68b6cce9c44a481412ece0"
7
+ binary linux-s390x "https://nodejs.org/dist/v22.3.0/node-v22.3.0-linux-s390x.tar.gz#3aa6a22f525a6f8ddb0fd2ce3646414c316a41cab6bdaac812276196607bc187"
8
+ binary linux-x64 "https://nodejs.org/dist/v22.3.0/node-v22.3.0-linux-x64.tar.gz#a6d4fbf4306a883b8e1d235a8a890be84b9d95d2d39b929520bed64da41ce540"
9
+
10
+ install_package "node-v22.3.0" "https://nodejs.org/dist/v22.3.0/node-v22.3.0.tar.gz#6326484853093ab6b8f361a267445f4a5bff469042cda11a3585497b13136b55"