diff --git a/.gitignore b/.gitignore index f6c0377bd29d3f..72ccaddaceb4f5 100644 --- a/.gitignore +++ b/.gitignore @@ -69,11 +69,9 @@ ipch/ /config_fips.gypi *-nodegyp* /gyp-mac-tool -/dist-osx /npm.wxs /tools/msvs/npm.wixobj /tools/msvs/genfiles/ -/tools/osx-pkg.pmdoc/index.xml /test/addons/??_*/ email.md deps/v8-* @@ -101,6 +99,7 @@ deps/npm/node_modules/.bin/ # build/release artifacts /*.tar.* +/*.pkg /SHASUMS*.txt* # test artifacts diff --git a/Makefile b/Makefile index e9c5a2e6bbcf17..a2d19af03a6ff6 100644 --- a/Makefile +++ b/Makefile @@ -663,8 +663,7 @@ BINARYTAR=$(BINARYNAME).tar XZ=$(shell which xz > /dev/null 2>&1; echo $$?) XZ_COMPRESSION ?= 9e PKG=$(TARNAME).pkg -PACKAGEMAKER ?= /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker -PKGDIR=out/dist-osx +MACOSOUTDIR=out/macos release-only: @if [ "$(DISTTYPE)" != "nightly" ] && [ "$(DISTTYPE)" != "next-nightly" ] && \ @@ -699,24 +698,54 @@ release-only: fi $(PKG): release-only - $(RM) -r $(PKGDIR) - $(RM) -r out/deps out/Release + $(RM) -r $(MACOSOUTDIR) + mkdir -p $(MACOSOUTDIR)/installer/productbuild + cat tools/macos-installer/productbuild/distribution.xml.tmpl \ + | sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \ + | sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \ + >$(MACOSOUTDIR)/installer/productbuild/distribution.xml ; \ + + @for dirname in tools/macos-installer/productbuild/Resources/*/; do \ + lang=$$(basename $$dirname) ; \ + mkdir -p $(MACOSOUTDIR)/installer/productbuild/Resources/$$lang ; \ + printf "Found localization directory $$dirname\n" ; \ + cat $$dirname/welcome.html.tmpl \ + | sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \ + | sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \ + >$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/welcome.html ; \ + cat $$dirname/conclusion.html.tmpl \ + | sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \ + | sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \ + >$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/conclusion.html ; \ + done $(PYTHON) ./configure \ --dest-cpu=x64 \ --tag=$(TAG) \ --release-urlbase=$(RELEASE_URLBASE) \ $(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS) - $(MAKE) install V=$(V) DESTDIR=$(PKGDIR) - SIGN="$(CODESIGN_CERT)" PKGDIR="$(PKGDIR)/usr/local" bash \ + $(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/node + SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/node/usr/local" bash \ tools/osx-codesign.sh - cat tools/osx-pkg.pmdoc/index.xml.tmpl \ - | sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \ - | sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \ - > tools/osx-pkg.pmdoc/index.xml - $(PACKAGEMAKER) \ - --id "org.nodejs.pkg" \ - --doc tools/osx-pkg.pmdoc \ - --out $(PKG) + mkdir -p $(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules + mkdir -p $(MACOSOUTDIR)/pkgs + mv $(MACOSOUTDIR)/dist/node/usr/local/lib/node_modules/npm \ + $(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules + unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npm + unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npx + $(NODE) tools/license2rtf.js < LICENSE > \ + $(MACOSOUTDIR)/installer/productbuild/Resources/license.rtf + cp doc/osx_installer_logo.png $(MACOSOUTDIR)/installer/productbuild/Resources + pkgbuild --version $(FULLVERSION) \ + --identifier org.nodejs.node.pkg \ + --root $(MACOSOUTDIR)/dist/node $(MACOSOUTDIR)/pkgs/node-$(FULLVERSION).pkg + pkgbuild --version $(NPMVERSION) \ + --identifier org.nodejs.npm.pkg \ + --root $(MACOSOUTDIR)/dist/npm \ + --scripts ./tools/macos-installer/pkgbuild/npm/scripts \ + $(MACOSOUTDIR)/pkgs/npm-$(NPMVERSION).pkg + productbuild --distribution $(MACOSOUTDIR)/installer/productbuild/distribution.xml \ + --resources $(MACOSOUTDIR)/installer/productbuild/Resources \ + --package-path $(MACOSOUTDIR)/pkgs ./$(PKG) SIGN="$(PRODUCTSIGN_CERT)" PKG="$(PKG)" bash tools/osx-productsign.sh pkg: $(PKG) diff --git a/tools/macos-installer/pkgbuild/npm/scripts/postinstall b/tools/macos-installer/pkgbuild/npm/scripts/postinstall new file mode 100755 index 00000000000000..285ce81e58a34e --- /dev/null +++ b/tools/macos-installer/pkgbuild/npm/scripts/postinstall @@ -0,0 +1,5 @@ +#!/bin/sh + +cd /usr/local/bin || exit 1 +ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm +ln -sf ../lib/node_modules/npm/bin/npx-cli.js npx diff --git a/tools/macos-installer/pkgbuild/npm/scripts/preinstall b/tools/macos-installer/pkgbuild/npm/scripts/preinstall new file mode 100755 index 00000000000000..848da677b4d825 --- /dev/null +++ b/tools/macos-installer/pkgbuild/npm/scripts/preinstall @@ -0,0 +1,5 @@ +#!/bin/sh + +[[ -d /usr/local/lib/node_modules/npm ]] \ + && rm -rf /usr/local/lib/node_modules/npm +exit 0 diff --git a/tools/macos-installer/productbuild/Resources/en.lproj/conclusion.html.tmpl b/tools/macos-installer/productbuild/Resources/en.lproj/conclusion.html.tmpl new file mode 100644 index 00000000000000..1157d9720816fe --- /dev/null +++ b/tools/macos-installer/productbuild/Resources/en.lproj/conclusion.html.tmpl @@ -0,0 +1,23 @@ + +
+ + + +This package has installed:
+/usr/local/bin/node
/usr/local/bin/npm
Make sure that /usr/local/bin
is in your $PATH
.
This package will install:
+/usr/local/bin/node
/usr/local/bin/npm