install: Support $(PREFIX) install target directory prefix
This change introduces support for the common PREFIX variable in the Makefile and install.py, instead of having /usr/local hardcoded. This makes it much easier to install node to custom locations e.g. in a user's home directory. The PREFIX variable defaults to /usr/local.
This commit is contained in:
parent
025f9133bb
commit
ddf4d1a32a
17
Makefile
17
Makefile
@ -5,6 +5,7 @@ PYTHON ?= python
|
|||||||
NINJA ?= ninja
|
NINJA ?= ninja
|
||||||
DESTDIR ?=
|
DESTDIR ?=
|
||||||
SIGN ?=
|
SIGN ?=
|
||||||
|
PREFIX ?= /usr/local
|
||||||
|
|
||||||
NODE ?= ./node
|
NODE ?= ./node
|
||||||
|
|
||||||
@ -55,10 +56,10 @@ config.gypi: configure
|
|||||||
$(PYTHON) ./configure
|
$(PYTHON) ./configure
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
$(PYTHON) tools/install.py $@ $(DESTDIR)
|
$(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
$(PYTHON) tools/install.py $@ $(DESTDIR)
|
$(PYTHON) tools/install.py $@ '$(DESTDIR)' '$(PREFIX)'
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -rf out/Makefile node node_g out/$(BUILDTYPE)/node blog.html email.md
|
-rm -rf out/Makefile node node_g out/$(BUILDTYPE)/node blog.html email.md
|
||||||
@ -266,17 +267,17 @@ pkg: $(PKG)
|
|||||||
$(PKG): release-only
|
$(PKG): release-only
|
||||||
rm -rf $(PKGDIR)
|
rm -rf $(PKGDIR)
|
||||||
rm -rf out/deps out/Release
|
rm -rf out/deps out/Release
|
||||||
$(PYTHON) ./configure --prefix=$(PKGDIR)/32/usr/local --without-snapshot --dest-cpu=ia32 --tag=$(TAG)
|
$(PYTHON) ./configure --prefix=$(PKGDIR)/32$(PREFIX) --without-snapshot --dest-cpu=ia32 --tag=$(TAG)
|
||||||
$(MAKE) install V=$(V)
|
$(MAKE) install V=$(V)
|
||||||
rm -rf out/deps out/Release
|
rm -rf out/deps out/Release
|
||||||
$(PYTHON) ./configure --prefix=$(PKGDIR)/usr/local --without-snapshot --dest-cpu=x64 --tag=$(TAG)
|
$(PYTHON) ./configure --prefix=$(PKGDIR)$(PREFIX) --without-snapshot --dest-cpu=x64 --tag=$(TAG)
|
||||||
$(MAKE) install V=$(V)
|
$(MAKE) install V=$(V)
|
||||||
SIGN="$(SIGN)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
|
SIGN="$(SIGN)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
|
||||||
lipo $(PKGDIR)/32/usr/local/bin/node \
|
lipo $(PKGDIR)/32$(PREFIX)/bin/node \
|
||||||
$(PKGDIR)/usr/local/bin/node \
|
$(PKGDIR)$(PREFIX)/bin/node \
|
||||||
-output $(PKGDIR)/usr/local/bin/node-universal \
|
-output $(PKGDIR)$(PREFIX)/bin/node-universal \
|
||||||
-create
|
-create
|
||||||
mv $(PKGDIR)/usr/local/bin/node-universal $(PKGDIR)/usr/local/bin/node
|
mv $(PKGDIR)$(PREFIX)/bin/node-universal $(PKGDIR)$(PREFIX)/bin/node
|
||||||
rm -rf $(PKGDIR)/32
|
rm -rf $(PKGDIR)/32
|
||||||
$(packagemaker) \
|
$(packagemaker) \
|
||||||
--id "org.nodejs.Node" \
|
--id "org.nodejs.Node" \
|
||||||
|
@ -13,8 +13,8 @@ import shutil
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
# set at init time
|
# set at init time
|
||||||
dst_dir = None
|
node_prefix = '/usr/local' # PREFIX variable from Makefile
|
||||||
node_prefix = None # dst_dir without DESTDIR prefix
|
install_path = None # base target directory (DESTDIR + PREFIX from Makefile)
|
||||||
target_defaults = None
|
target_defaults = None
|
||||||
variables = None
|
variables = None
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ def try_mkdir_r(path):
|
|||||||
|
|
||||||
def try_rmdir_r(path):
|
def try_rmdir_r(path):
|
||||||
path = abspath(path)
|
path = abspath(path)
|
||||||
while path.startswith(dst_dir):
|
while path.startswith(install_path):
|
||||||
try:
|
try:
|
||||||
os.rmdir(path)
|
os.rmdir(path)
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
@ -58,9 +58,9 @@ def try_rmdir_r(path):
|
|||||||
|
|
||||||
def mkpaths(path, dst):
|
def mkpaths(path, dst):
|
||||||
if dst.endswith('/'):
|
if dst.endswith('/'):
|
||||||
target_path = abspath(dst_dir, dst, os.path.basename(path))
|
target_path = abspath(install_path, dst, os.path.basename(path))
|
||||||
else:
|
else:
|
||||||
target_path = abspath(dst_dir, dst)
|
target_path = abspath(install_path, dst)
|
||||||
return path, target_path
|
return path, target_path
|
||||||
|
|
||||||
def try_copy(path, dst):
|
def try_copy(path, dst):
|
||||||
@ -90,7 +90,7 @@ def npm_files(action):
|
|||||||
|
|
||||||
# don't install npm if the target path is a symlink, it probably means
|
# don't install npm if the target path is a symlink, it probably means
|
||||||
# that a dev version of npm is installed there
|
# that a dev version of npm is installed there
|
||||||
if os.path.islink(abspath(dst_dir, target_path)): return
|
if os.path.islink(abspath(install_path, target_path)): return
|
||||||
|
|
||||||
# npm has a *lot* of files and it'd be a pain to maintain a fixed list here
|
# npm has a *lot* of files and it'd be a pain to maintain a fixed list here
|
||||||
# so we walk its source directory instead...
|
# so we walk its source directory instead...
|
||||||
@ -100,7 +100,7 @@ def npm_files(action):
|
|||||||
action(paths, target_path + dirname[9:] + '/')
|
action(paths, target_path + dirname[9:] + '/')
|
||||||
|
|
||||||
# create/remove symlink
|
# create/remove symlink
|
||||||
link_path = abspath(dst_dir, 'bin/npm')
|
link_path = abspath(install_path, 'bin/npm')
|
||||||
if action == uninstall:
|
if action == uninstall:
|
||||||
action([link_path], 'bin/npm')
|
action([link_path], 'bin/npm')
|
||||||
elif action == install:
|
elif action == install:
|
||||||
@ -113,7 +113,7 @@ def npm_files(action):
|
|||||||
# precompiled bundle should be able to be extracted anywhere and "just work"
|
# precompiled bundle should be able to be extracted anywhere and "just work"
|
||||||
shebang = '/bin/sh\n// 2>/dev/null; exec "`dirname "$0"`/node" "$0" "$@"'
|
shebang = '/bin/sh\n// 2>/dev/null; exec "`dirname "$0"`/node" "$0" "$@"'
|
||||||
else:
|
else:
|
||||||
shebang = os.path.join(node_prefix, 'bin/node')
|
shebang = os.path.join(node_prefix or '/', 'bin/node')
|
||||||
update_shebang(link_path, shebang)
|
update_shebang(link_path, shebang)
|
||||||
else:
|
else:
|
||||||
assert(0) # unhandled action type
|
assert(0) # unhandled action type
|
||||||
@ -134,7 +134,7 @@ def files(action):
|
|||||||
if 'true' == variables.get('node_install_npm'): npm_files(action)
|
if 'true' == variables.get('node_install_npm'): npm_files(action)
|
||||||
|
|
||||||
def run(args):
|
def run(args):
|
||||||
global dst_dir, node_prefix, target_defaults, variables
|
global node_prefix, install_path, target_defaults, variables
|
||||||
|
|
||||||
# chdir to the project's top-level directory
|
# chdir to the project's top-level directory
|
||||||
os.chdir(abspath(os.path.dirname(__file__), '..'))
|
os.chdir(abspath(os.path.dirname(__file__), '..'))
|
||||||
@ -144,8 +144,15 @@ def run(args):
|
|||||||
target_defaults = conf['target_defaults']
|
target_defaults = conf['target_defaults']
|
||||||
|
|
||||||
# argv[2] is a custom install prefix for packagers (think DESTDIR)
|
# argv[2] is a custom install prefix for packagers (think DESTDIR)
|
||||||
dst_dir = node_prefix = variables.get('node_prefix') or '/usr/local'
|
# argv[3] is a custom install prefix (think PREFIX)
|
||||||
if len(args) > 2: dst_dir = abspath(args[2] + '/' + dst_dir)
|
# Difference is that dst_dir won't be included in shebang lines etc.
|
||||||
|
if len(args) > 2:
|
||||||
|
dst_dir = args[2]
|
||||||
|
if len(args) > 3:
|
||||||
|
node_prefix = args[3]
|
||||||
|
|
||||||
|
# install_path thus becomes the base target directory.
|
||||||
|
install_path = dst_dir + node_prefix + '/'
|
||||||
|
|
||||||
cmd = args[1] if len(args) > 1 else 'install'
|
cmd = args[1] if len(args) > 1 else 'install'
|
||||||
if cmd == 'install': return files(install)
|
if cmd == 'install': return files(install)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user