Skip to content

Commit ea50ebd

Browse files
skenqbxbnoordhuis
authored andcommitted
build: support make install "DESTDIR=/path"
1 parent e160213 commit ea50ebd

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
BUILDTYPE ?= Release
44
PYTHON ?= python
5+
DESTDIR ?=
56

67
# BUILDTYPE=Debug builds both release and debug builds. If you want to compile
78
# just the debug build, run `make -C out BUILDTYPE=Debug` instead.
@@ -33,7 +34,7 @@ out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp deps/z
3334
tools/gyp_node -f make
3435

3536
install: all
36-
out/Release/node tools/installer.js install
37+
out/Release/node tools/installer.js install $(DESTDIR)
3738

3839
uninstall:
3940
out/Release/node tools/installer.js uninstall

tools/installer.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
var fs = require('fs'),
22
path = require('path'),
33
exec = require('child_process').exec,
4-
cmd = process.argv[2];
4+
cmd = process.argv[2],
5+
dest_dir = process.argv[3] || '';
56

67
if (cmd !== 'install' && cmd !== 'uninstall') {
78
console.error('Unknown command: ' + cmd);
@@ -26,7 +27,7 @@ function copy(src, dst, callback) {
2627
return;
2728
}
2829

29-
dst = path.join(node_prefix, dst);
30+
dst = path.join(dest_dir, node_prefix, dst);
3031
var dir = dst.replace(/\/[^\/]*$/, '/');
3132

3233
// Create directory if hasn't done this yet
@@ -42,7 +43,7 @@ function copy(src, dst, callback) {
4243
// Remove files
4344
function remove(files) {
4445
files.forEach(function(file) {
45-
file = path.join(node_prefix, file);
46+
file = path.join(dest_dir, node_prefix, file);
4647
queue.push('rm -rf ' + file);
4748
});
4849
}
@@ -127,9 +128,10 @@ if (cmd === 'install') {
127128
if (variables.node_install_npm) {
128129
copy('deps/npm', 'lib/node_modules/npm');
129130
queue.push('ln -sf ../lib/node_modules/npm/bin/npm-cli.js ' +
130-
path.join(node_prefix, 'bin/npm'));
131+
path.join(dest_dir, node_prefix, 'bin/npm'));
131132
queue.push([shebang, '#!' + path.join(node_prefix, 'bin/node'),
132-
path.join(node_prefix, 'lib/node_modules/npm/bin/npm-cli.js')]);
133+
path.join(dest_dir, node_prefix,
134+
'lib/node_modules/npm/bin/npm-cli.js')]);
133135
}
134136
} else {
135137
remove([

0 commit comments

Comments
 (0)