From 3a12b469d76b33820d5991ffe6908f60a0934c9e Mon Sep 17 00:00:00 2001 From: JP Wesselink Date: Mon, 4 Sep 2017 12:07:56 +0200 Subject: [PATCH] tools, build: refactor macOS installer Creates macOS pkg installer by using `pkgbuild` and `productbuild`. Removes previous npm installation before installing npm. Packages carry correct version attributes. Support for intl installer features, defaults to `en`. Fancy formatted license. Renamed `osx` references to `macOS`. Optional installation of npm. PR-URL: https://github.com/nodejs/node/pull/15179 Fixes: https://github.com/nodejs/node/issues/15012 Refs: https://github.com/nodejs/node/pull/5656 Refs: https://github.com/nodejs/node/pull/2571 Refs: https://github.com/nodejs/node/pull/7097 Reviewed-By: Lance Ball Reviewed-By: Daijiro Wachi Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- .gitignore | 3 +- Makefile | 56 ++++++++++++++----- .../pkgbuild/npm/scripts/postinstall | 5 ++ .../pkgbuild/npm/scripts/preinstall | 5 ++ .../Resources/en.lproj/conclusion.html.tmpl | 23 ++++++++ .../Resources/en.lproj/welcome.html.tmpl | 19 +++++++ .../productbuild/distribution.xml.tmpl | 23 ++++++++ tools/osx-pkg.pmdoc/01local-contents.xml | 1 - tools/osx-pkg.pmdoc/01local.xml | 25 --------- tools/osx-pkg.pmdoc/02npm-contents.xml | 1 - tools/osx-pkg.pmdoc/02npm.xml | 24 -------- tools/osx-pkg.pmdoc/index.xml.tmpl | 55 ------------------ 12 files changed, 118 insertions(+), 122 deletions(-) create mode 100755 tools/macos-installer/pkgbuild/npm/scripts/postinstall create mode 100755 tools/macos-installer/pkgbuild/npm/scripts/preinstall create mode 100644 tools/macos-installer/productbuild/Resources/en.lproj/conclusion.html.tmpl create mode 100644 tools/macos-installer/productbuild/Resources/en.lproj/welcome.html.tmpl create mode 100644 tools/macos-installer/productbuild/distribution.xml.tmpl delete mode 100644 tools/osx-pkg.pmdoc/01local-contents.xml delete mode 100644 tools/osx-pkg.pmdoc/01local.xml delete mode 100644 tools/osx-pkg.pmdoc/02npm-contents.xml delete mode 100644 tools/osx-pkg.pmdoc/02npm.xml delete mode 100644 tools/osx-pkg.pmdoc/index.xml.tmpl diff --git a/.gitignore b/.gitignore index dea969504a90f1..181e4e5d3b4b62 100644 --- a/.gitignore +++ b/.gitignore @@ -68,11 +68,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-* @@ -100,6 +98,7 @@ deps/npm/node_modules/.bin/ # build/release artifacts /*.tar.* +/*.pkg /SHASUMS*.txt* # test artifacts diff --git a/Makefile b/Makefile index c9fed0c03b32f4..c947a2a4367d05 100644 --- a/Makefile +++ b/Makefile @@ -530,8 +530,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" ] && \ @@ -561,24 +560,53 @@ 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 + $(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:

+
    +
  • Node.js {nodeversion} to /usr/local/bin/node
  • +
  • npm {npmversion} to /usr/local/bin/npm
  • +
+

Make sure that /usr/local/bin is in your $PATH.

+
+ + diff --git a/tools/macos-installer/productbuild/Resources/en.lproj/welcome.html.tmpl b/tools/macos-installer/productbuild/Resources/en.lproj/welcome.html.tmpl new file mode 100644 index 00000000000000..3790894e39727d --- /dev/null +++ b/tools/macos-installer/productbuild/Resources/en.lproj/welcome.html.tmpl @@ -0,0 +1,19 @@ + + + + + +
+

This package will install:

+
    +
  • Node.js {nodeversion} to /usr/local/bin/node
  • +
  • npm {npmversion} to /usr/local/bin/npm
  • +
+
+ + diff --git a/tools/macos-installer/productbuild/distribution.xml.tmpl b/tools/macos-installer/productbuild/distribution.xml.tmpl new file mode 100644 index 00000000000000..0b9d84701bb01a --- /dev/null +++ b/tools/macos-installer/productbuild/distribution.xml.tmpl @@ -0,0 +1,23 @@ + + + Node.js + + + + + + + + + + + + + + + node-{nodeversion}.pkg + + + + npm-{npmversion}.pkg + diff --git a/tools/osx-pkg.pmdoc/01local-contents.xml b/tools/osx-pkg.pmdoc/01local-contents.xml deleted file mode 100644 index ccbb4189961b0a..00000000000000 --- a/tools/osx-pkg.pmdoc/01local-contents.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tools/osx-pkg.pmdoc/01local.xml b/tools/osx-pkg.pmdoc/01local.xml deleted file mode 100644 index 537b35508bb714..00000000000000 --- a/tools/osx-pkg.pmdoc/01local.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - org.nodejs.node.pkg - 1.0 - - - - ../out/dist-osx/usr/local/ - /usr/local - - - - - installTo.isRelativeType - installTo - locationType - relocatable - installFrom.path - installTo.isAbsoluteType - identifier - parent - installTo.path - installFrom.isRelativeType - - diff --git a/tools/osx-pkg.pmdoc/02npm-contents.xml b/tools/osx-pkg.pmdoc/02npm-contents.xml deleted file mode 100644 index ccbb4189961b0a..00000000000000 --- a/tools/osx-pkg.pmdoc/02npm-contents.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tools/osx-pkg.pmdoc/02npm.xml b/tools/osx-pkg.pmdoc/02npm.xml deleted file mode 100644 index fca97e5c27dd11..00000000000000 --- a/tools/osx-pkg.pmdoc/02npm.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - org.nodejs.npm.pkg - 1.0 - - - - ../deps/npm - /usr/local/lib/node_modules/npm - - - - - installTo.path - installFrom.isRelativeType - installTo - scripts.postinstall.isRelativeType - parent - installTo.isAbsoluteType - - - osx-pkg-postinstall.sh - - diff --git a/tools/osx-pkg.pmdoc/index.xml.tmpl b/tools/osx-pkg.pmdoc/index.xml.tmpl deleted file mode 100644 index e3b14b2112d694..00000000000000 --- a/tools/osx-pkg.pmdoc/index.xml.tmpl +++ /dev/null @@ -1,55 +0,0 @@ - - - Node.js - /Users/nodejs/Desktop/node.pkg - org.nodejs - - - - - - - - - - - - - - - - - - - ../doc/osx_installer_logo.png - ../LICENSE - - - - - - 01local.xml - 02npm.xml - properties.title - properties.userDomain - properties.anywhereDomain - properties.systemDomain -