diff options
author | JP Wesselink <jpwesselink@gmail.com> | 2017-09-04 13:07:56 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2017-09-28 08:05:59 +0300 |
commit | 03954f778ec491fe5a4f8e42996e3edbe35554d9 (patch) | |
tree | 2617567bac0171a93406e70d2ff5f0b0fd3269c1 | |
parent | 6975c490d11d4aa937c9df6835f4e75ac8c72cee (diff) |
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 <lball@redhat.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 57 | ||||
-rwxr-xr-x | tools/macos-installer/pkgbuild/npm/scripts/postinstall | 5 | ||||
-rwxr-xr-x | tools/macos-installer/pkgbuild/npm/scripts/preinstall | 5 | ||||
-rw-r--r-- | tools/macos-installer/productbuild/Resources/en.lproj/conclusion.html.tmpl | 23 | ||||
-rw-r--r-- | tools/macos-installer/productbuild/Resources/en.lproj/welcome.html.tmpl | 19 | ||||
-rw-r--r-- | tools/macos-installer/productbuild/distribution.xml.tmpl | 23 | ||||
-rw-r--r-- | tools/osx-pkg.pmdoc/01local-contents.xml | 1 | ||||
-rw-r--r-- | tools/osx-pkg.pmdoc/01local.xml | 25 | ||||
-rw-r--r-- | tools/osx-pkg.pmdoc/02npm-contents.xml | 1 | ||||
-rw-r--r-- | tools/osx-pkg.pmdoc/02npm.xml | 24 | ||||
-rw-r--r-- | tools/osx-pkg.pmdoc/index.xml.tmpl | 55 |
12 files changed, 119 insertions, 122 deletions
diff --git a/.gitignore b/.gitignore index f6c0377bd29..72ccaddaceb 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 @@ -673,8 +673,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" ] && \ @@ -709,24 +708,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 00000000000..285ce81e58a --- /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 00000000000..848da677b4d --- /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 00000000000..1157d972081 --- /dev/null +++ b/tools/macos-installer/productbuild/Resources/en.lproj/conclusion.html.tmpl @@ -0,0 +1,23 @@ +<html> + <head> + <style> + body { + font-family: Helvetica; + font-size: 14px; + } + li:last-child { + margin-bottom: 16px; + } + </style> + </head> + <body> + <div> + <p>This package has installed:</p> + <ul> + <li>Node.js {nodeversion} to <code>/usr/local/bin/node</code></li> + <li>npm {npmversion} to <code>/usr/local/bin/npm</code></li> + </ul> + <p>Make sure that <code>/usr/local/bin</code> is in your <code>$PATH</code>.</p> + </div> + </body> +</html> 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 00000000000..3790894e397 --- /dev/null +++ b/tools/macos-installer/productbuild/Resources/en.lproj/welcome.html.tmpl @@ -0,0 +1,19 @@ +<html> + <head> + <style> + body { + font-family: Helvetica; + font-size: 14px; + } + </style> + </head> + <body> + <div> + <p>This package will install:</p> + <ul> + <li>Node.js {nodeversion} to <code>/usr/local/bin/node</code></li> + <li>npm {npmversion} to <code>/usr/local/bin/npm</code></li> + </ul> + </div> + </body> +</html> diff --git a/tools/macos-installer/productbuild/distribution.xml.tmpl b/tools/macos-installer/productbuild/distribution.xml.tmpl new file mode 100644 index 00000000000..0b9d84701bb --- /dev/null +++ b/tools/macos-installer/productbuild/distribution.xml.tmpl @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<installer-gui-script minSpecVersion="1"> + <title>Node.js</title> + <welcome file="welcome.html"/> + <conclusion file="conclusion.html"/> + <background alignment="topleft" file="osx_installer_logo.png"/> + <pkg-ref id="org.nodejs.node.pkg" auth="root"/> + <pkg-ref id="org.nodejs.npm.pkg" auth="root"/> + <options customize="allow" require-scripts="false"/> + <license file="license.rtf"/> + <choices-outline> + <line choice="org.nodejs.node.pkg" /> + <line choice="org.nodejs.npm.pkg"/> + </choices-outline> + <choice id="org.nodejs.node.pkg" visible="true" title="Node.js {nodeversion}"> + <pkg-ref id="org.nodejs.node.pkg"/> + </choice> + <pkg-ref id="org.nodejs.node.pkg" version="{nodeversion}" onConclusion="none">node-{nodeversion}.pkg</pkg-ref> + <choice id="org.nodejs.npm.pkg" visible="true" title="npm {npmversion}"> + <pkg-ref id="org.nodejs.npm.pkg"/> + </choice> + <pkg-ref id="org.nodejs.npm.pkg" version="{npmversion}" onConclusion="none">npm-{npmversion}.pkg</pkg-ref> +</installer-gui-script> diff --git a/tools/osx-pkg.pmdoc/01local-contents.xml b/tools/osx-pkg.pmdoc/01local-contents.xml deleted file mode 100644 index ccbb4189961..00000000000 --- a/tools/osx-pkg.pmdoc/01local-contents.xml +++ /dev/null @@ -1 +0,0 @@ -<pkg-contents spec="1.12"/> diff --git a/tools/osx-pkg.pmdoc/01local.xml b/tools/osx-pkg.pmdoc/01local.xml deleted file mode 100644 index 537b35508bb..00000000000 --- a/tools/osx-pkg.pmdoc/01local.xml +++ /dev/null @@ -1,25 +0,0 @@ -<pkgref spec="1.12" uuid="053587FE-BDF3-4EF5-815D-281427431048"> - <config> - <identifier>org.nodejs.node.pkg</identifier> - <version>1.0</version> - <description></description> - <post-install type="none"/> - <requireAuthorization/> - <installFrom relative="true" mod="true">../out/dist-osx/usr/local/</installFrom> - <installTo mod="true" relocatable="true">/usr/local</installTo> - <flags> - <followSymbolicLinks/> - </flags> - <packageStore type="internal"></packageStore> - <mod>installTo.isRelativeType</mod> - <mod>installTo</mod> - <mod>locationType</mod> - <mod>relocatable</mod> - <mod>installFrom.path</mod> - <mod>installTo.isAbsoluteType</mod> - <mod>identifier</mod> - <mod>parent</mod> - <mod>installTo.path</mod> - <mod>installFrom.isRelativeType</mod> - </config> -</pkgref> diff --git a/tools/osx-pkg.pmdoc/02npm-contents.xml b/tools/osx-pkg.pmdoc/02npm-contents.xml deleted file mode 100644 index ccbb4189961..00000000000 --- a/tools/osx-pkg.pmdoc/02npm-contents.xml +++ /dev/null @@ -1 +0,0 @@ -<pkg-contents spec="1.12"/> diff --git a/tools/osx-pkg.pmdoc/02npm.xml b/tools/osx-pkg.pmdoc/02npm.xml deleted file mode 100644 index fca97e5c27d..00000000000 --- a/tools/osx-pkg.pmdoc/02npm.xml +++ /dev/null @@ -1,24 +0,0 @@ -<pkgref spec="1.12" uuid="DF0233A3-6B5D-4FBF-8048-8FC57F42278F"> - <config> - <identifier>org.nodejs.npm.pkg</identifier> - <version>1.0</version> - <description></description> - <post-install type="none"/> - <requireAuthorization/> - <installFrom relative="true">../deps/npm</installFrom> - <installTo mod="true">/usr/local/lib/node_modules/npm</installTo> - <flags> - <followSymbolicLinks/> - </flags> - <packageStore type="internal"></packageStore> - <mod>installTo.path</mod> - <mod>installFrom.isRelativeType</mod> - <mod>installTo</mod> - <mod>scripts.postinstall.isRelativeType</mod> - <mod>parent</mod> - <mod>installTo.isAbsoluteType</mod> - </config> - <scripts> - <postinstall relative="true" mod="true">osx-pkg-postinstall.sh</postinstall> - </scripts> -</pkgref> diff --git a/tools/osx-pkg.pmdoc/index.xml.tmpl b/tools/osx-pkg.pmdoc/index.xml.tmpl deleted file mode 100644 index e3b14b2112d..00000000000 --- a/tools/osx-pkg.pmdoc/index.xml.tmpl +++ /dev/null @@ -1,55 +0,0 @@ -<pkmkdoc spec="1.12"> - <properties> - <title>Node.js</title> - <build>/Users/nodejs/Desktop/node.pkg</build> - <organization>org.nodejs</organization> - <userSees ui="both"/> - <min-target os="3"/> - <domain system="true"/> - </properties> - <distribution> - <versions min-spec="1.000000"/> - <scripts></scripts> - </distribution> - <contents> - <choice title="Node.js" id="choice1" starts_selected="true" starts_enabled="true" starts_hidden="false"> - <pkgref id="org.nodejs.node.pkg"/> - </choice> - <choice title="npm" id="choice2" starts_selected="true" starts_enabled="true" starts_hidden="false"> - <pkgref id="org.nodejs.npm.pkg"/> - </choice> - </contents> - <resources bg-scale="none" bg-align="topleft"> - <locale lang="en"> - <resource relative="true" mod="true" type="background">../doc/osx_installer_logo.png</resource> - <resource relative="true" mod="true" type="license">../LICENSE</resource> - <resource mime-type="text/rtf" kind="embedded" type="welcome"><![CDATA[{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360 -{\fonttbl\f0\fnil\fcharset0 LucidaGrande;} -{\colortbl;\red255\green255\blue255;} -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural - -\f0\fs26 \cf0 This package will install Node.js {nodeversion} and npm {npmversion} into /usr/local/.}]]></resource> - <resource mime-type="text/rtf" kind="embedded" type="conclusion"><![CDATA[{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360 -{\fonttbl\f0\fnil\fcharset0 LucidaGrande;} -{\colortbl;\red255\green255\blue255;} -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural - -\f0\fs26 \cf0 Node.js was installed at\ -\ - /usr/local/bin/node\ -\ -npm was installed at\ -\ - /usr/local/bin/npm\ -\ -Make sure that /usr/local/bin is in your $PATH.}]]></resource> - </locale> - </resources> - <flags/> - <item type="file">01local.xml</item> - <item type="file">02npm.xml</item> - <mod>properties.title</mod> - <mod>properties.userDomain</mod> - <mod>properties.anywhereDomain</mod> - <mod>properties.systemDomain</mod> -</pkmkdoc> |