This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plan.sh
55 lines (49 loc) · 1.74 KB
/
plan.sh
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
pkg_name=node8
pkg_origin=core
pkg_version=8.17.0
pkg_description="Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine."
pkg_upstream_url=https://nodejs.org/
pkg_license=('MIT')
pkg_maintainer="The Habitat Maintainers <[email protected]>"
pkg_source="https://nodejs.org/dist/v${pkg_version}/node-v${pkg_version}.tar.gz"
pkg_shasum=aa583f19065545fa4c9b480ba13cf94f29350415ca5a853a5afde3c9b6982c4b
pkg_deps=(
core/glibc
core/gcc-libs
core/python2
core/bash
)
pkg_build_deps=(
core/gcc
core/grep
core/make
)
pkg_bin_dirs=(bin)
pkg_include_dirs=(include)
pkg_interpreters=(bin/node)
pkg_lib_dirs=(lib)
pkg_dirname="node-v${pkg_version}"
do_prepare() {
# ./configure has a shebang of #!/usr/bin/env python2. Fix it.
sed -e "s#/usr/bin/env python#$(pkg_path_for python2)/bin/python2#" -i configure
}
do_build() {
./configure \
--prefix "${pkg_prefix}" \
--dest-cpu "x64" \
--dest-os "linux"
make -j"$(nproc)"
}
do_install() {
do_default_install
# Node produces a lot of scripts that hardcode `/usr/bin/env`, so we need to
# fix that everywhere to point directly at the env binary in core/coreutils.
grep -nrlI '^\#\!/usr/bin/env' "$pkg_prefix" | while read -r target; do
sed -e "s#\#\!/usr/bin/env node#\#\!${pkg_prefix}/bin/node#" -i "$target"
sed -e "s#\#\!/usr/bin/env sh#\#\!$(pkg_path_for bash)/bin/sh#" -i "$target"
sed -e "s#\#\!/usr/bin/env bash#\#\!$(pkg_path_for bash)/bin/bash#" -i "$target"
sed -e "s#\#\!/usr/bin/env python#\#\!$(pkg_path_for python2)/bin/python2#" -i "$target"
done
# This script has a hardcoded bare `node` command
sed -e "s#^\([[:space:]]\)\+node\([[:space:]]\)#\1${pkg_prefix}/bin/node\2#" -i "${pkg_prefix}/lib/node_modules/npm/bin/node-gyp-bin/node-gyp"
}