build: support make install "DESTDIR=/path"
This commit is contained in:
Родитель
e16021340d
Коммит
ea50ebd36d
3
Makefile
3
Makefile
|
@ -2,6 +2,7 @@
|
|||
|
||||
BUILDTYPE ?= Release
|
||||
PYTHON ?= python
|
||||
DESTDIR ?=
|
||||
|
||||
# BUILDTYPE=Debug builds both release and debug builds. If you want to compile
|
||||
# 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
|
|||
tools/gyp_node -f make
|
||||
|
||||
install: all
|
||||
out/Release/node tools/installer.js install
|
||||
out/Release/node tools/installer.js install $(DESTDIR)
|
||||
|
||||
uninstall:
|
||||
out/Release/node tools/installer.js uninstall
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
exec = require('child_process').exec,
|
||||
cmd = process.argv[2];
|
||||
cmd = process.argv[2],
|
||||
dest_dir = process.argv[3] || '';
|
||||
|
||||
if (cmd !== 'install' && cmd !== 'uninstall') {
|
||||
console.error('Unknown command: ' + cmd);
|
||||
|
@ -26,7 +27,7 @@ function copy(src, dst, callback) {
|
|||
return;
|
||||
}
|
||||
|
||||
dst = path.join(node_prefix, dst);
|
||||
dst = path.join(dest_dir, node_prefix, dst);
|
||||
var dir = dst.replace(/\/[^\/]*$/, '/');
|
||||
|
||||
// Create directory if hasn't done this yet
|
||||
|
@ -42,7 +43,7 @@ function copy(src, dst, callback) {
|
|||
// Remove files
|
||||
function remove(files) {
|
||||
files.forEach(function(file) {
|
||||
file = path.join(node_prefix, file);
|
||||
file = path.join(dest_dir, node_prefix, file);
|
||||
queue.push('rm -rf ' + file);
|
||||
});
|
||||
}
|
||||
|
@ -127,9 +128,10 @@ if (cmd === 'install') {
|
|||
if (variables.node_install_npm) {
|
||||
copy('deps/npm', 'lib/node_modules/npm');
|
||||
queue.push('ln -sf ../lib/node_modules/npm/bin/npm-cli.js ' +
|
||||
path.join(node_prefix, 'bin/npm'));
|
||||
path.join(dest_dir, node_prefix, 'bin/npm'));
|
||||
queue.push([shebang, '#!' + path.join(node_prefix, 'bin/node'),
|
||||
path.join(node_prefix, 'lib/node_modules/npm/bin/npm-cli.js')]);
|
||||
path.join(dest_dir, node_prefix,
|
||||
'lib/node_modules/npm/bin/npm-cli.js')]);
|
||||
}
|
||||
} else {
|
||||
remove([
|
||||
|
|
Загрузка…
Ссылка в новой задаче