Skip to content

Commit 18803bc

Browse files
jpwesselinkMylesBorins
authored andcommitted
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: #15179 Fixes: #15012 Refs: #5656 Refs: #2571 Refs: #7097 Reviewed-By: Lance Ball <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent 365dba2 commit 18803bc

File tree

12 files changed

+118
-122
lines changed

12 files changed

+118
-122
lines changed

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ ipch/
6868
/config_fips.gypi
6969
*-nodegyp*
7070
/gyp-mac-tool
71-
/dist-osx
7271
/npm.wxs
7372
/tools/msvs/npm.wixobj
7473
/tools/msvs/genfiles/
75-
/tools/osx-pkg.pmdoc/index.xml
7674
/test/addons/??_*/
7775
email.md
7876
deps/v8-*
@@ -100,6 +98,7 @@ deps/npm/node_modules/.bin/
10098

10199
# build/release artifacts
102100
/*.tar.*
101+
/*.pkg
103102
/SHASUMS*.txt*
104103

105104
# test artifacts

Makefile

+42-14
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,7 @@ BINARYTAR=$(BINARYNAME).tar
530530
XZ=$(shell which xz > /dev/null 2>&1; echo $$?)
531531
XZ_COMPRESSION ?= 9e
532532
PKG=$(TARNAME).pkg
533-
PACKAGEMAKER ?= /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
534-
PKGDIR=out/dist-osx
533+
MACOSOUTDIR=out/macos
535534

536535
release-only:
537536
@if [ "$(DISTTYPE)" != "nightly" ] && [ "$(DISTTYPE)" != "next-nightly" ] && \
@@ -561,24 +560,53 @@ release-only:
561560
fi
562561

563562
$(PKG): release-only
564-
$(RM) -r $(PKGDIR)
565-
$(RM) -r out/deps out/Release
563+
$(RM) -r $(MACOSOUTDIR)
564+
mkdir -p $(MACOSOUTDIR)/installer/productbuild
565+
cat tools/macos-installer/productbuild/distribution.xml.tmpl \
566+
| sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
567+
| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
568+
>$(MACOSOUTDIR)/installer/productbuild/distribution.xml ; \
569+
570+
@for dirname in tools/macos-installer/productbuild/Resources/*/; do \
571+
lang=$$(basename $$dirname) ; \
572+
mkdir -p $(MACOSOUTDIR)/installer/productbuild/Resources/$$lang ; \
573+
printf "Found localization directory $$dirname\n" ; \
574+
cat $$dirname/welcome.html.tmpl \
575+
| sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
576+
| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
577+
>$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/welcome.html ; \
578+
cat $$dirname/conclusion.html.tmpl \
579+
| sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
580+
| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
581+
>$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/conclusion.html ; \
582+
done
566583
$(PYTHON) ./configure \
567584
--dest-cpu=x64 \
568585
--tag=$(TAG) \
569586
--release-urlbase=$(RELEASE_URLBASE) \
570587
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
571-
$(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
572-
SIGN="$(CODESIGN_CERT)" PKGDIR="$(PKGDIR)/usr/local" bash \
588+
$(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/node
589+
SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/node/usr/local" bash \
573590
tools/osx-codesign.sh
574-
cat tools/osx-pkg.pmdoc/index.xml.tmpl \
575-
| sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
576-
| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
577-
> tools/osx-pkg.pmdoc/index.xml
578-
$(PACKAGEMAKER) \
579-
--id "org.nodejs.pkg" \
580-
--doc tools/osx-pkg.pmdoc \
581-
--out $(PKG)
591+
mkdir -p $(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules
592+
mkdir -p $(MACOSOUTDIR)/pkgs
593+
mv $(MACOSOUTDIR)/dist/node/usr/local/lib/node_modules/npm \
594+
$(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules
595+
unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npm
596+
$(NODE) tools/license2rtf.js < LICENSE > \
597+
$(MACOSOUTDIR)/installer/productbuild/Resources/license.rtf
598+
cp doc/osx_installer_logo.png $(MACOSOUTDIR)/installer/productbuild/Resources
599+
pkgbuild --version $(FULLVERSION) \
600+
--identifier org.nodejs.node.pkg \
601+
--root $(MACOSOUTDIR)/dist/node $(MACOSOUTDIR)/pkgs/node-$(FULLVERSION).pkg
602+
pkgbuild --version $(NPMVERSION) \
603+
--identifier org.nodejs.npm.pkg \
604+
--root $(MACOSOUTDIR)/dist/npm \
605+
--scripts ./tools/macos-installer/pkgbuild/npm/scripts \
606+
$(MACOSOUTDIR)/pkgs/npm-$(NPMVERSION).pkg
607+
productbuild --distribution $(MACOSOUTDIR)/installer/productbuild/distribution.xml \
608+
--resources $(MACOSOUTDIR)/installer/productbuild/Resources \
609+
--package-path $(MACOSOUTDIR)/pkgs ./$(PKG)
582610
SIGN="$(PRODUCTSIGN_CERT)" PKG="$(PKG)" bash tools/osx-productsign.sh
583611

584612
pkg: $(PKG)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
cd /usr/local/bin || exit 1
4+
ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm
5+
ln -sf ../lib/node_modules/npm/bin/npx-cli.js npx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
[[ -d /usr/local/lib/node_modules/npm ]] \
4+
&& rm -rf /usr/local/lib/node_modules/npm
5+
exit 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<html>
2+
<head>
3+
<style>
4+
body {
5+
font-family: Helvetica;
6+
font-size: 14px;
7+
}
8+
li:last-child {
9+
margin-bottom: 16px;
10+
}
11+
</style>
12+
</head>
13+
<body>
14+
<div>
15+
<p>This package has installed:</p>
16+
<ul>
17+
<li>Node.js {nodeversion} to <code>/usr/local/bin/node</code></li>
18+
<li>npm {npmversion} to <code>/usr/local/bin/npm</code></li>
19+
</ul>
20+
<p>Make sure that <code>/usr/local/bin</code> is in your <code>$PATH</code>.</p>
21+
</div>
22+
</body>
23+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<html>
2+
<head>
3+
<style>
4+
body {
5+
font-family: Helvetica;
6+
font-size: 14px;
7+
}
8+
</style>
9+
</head>
10+
<body>
11+
<div>
12+
<p>This package will install:</p>
13+
<ul>
14+
<li>Node.js {nodeversion} to <code>/usr/local/bin/node</code></li>
15+
<li>npm {npmversion} to <code>/usr/local/bin/npm</code></li>
16+
</ul>
17+
</div>
18+
</body>
19+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<installer-gui-script minSpecVersion="1">
3+
<title>Node.js</title>
4+
<welcome file="welcome.html"/>
5+
<conclusion file="conclusion.html"/>
6+
<background alignment="topleft" file="osx_installer_logo.png"/>
7+
<pkg-ref id="org.nodejs.node.pkg" auth="root"/>
8+
<pkg-ref id="org.nodejs.npm.pkg" auth="root"/>
9+
<options customize="allow" require-scripts="false"/>
10+
<license file="license.rtf"/>
11+
<choices-outline>
12+
<line choice="org.nodejs.node.pkg" />
13+
<line choice="org.nodejs.npm.pkg"/>
14+
</choices-outline>
15+
<choice id="org.nodejs.node.pkg" visible="true" title="Node.js {nodeversion}">
16+
<pkg-ref id="org.nodejs.node.pkg"/>
17+
</choice>
18+
<pkg-ref id="org.nodejs.node.pkg" version="{nodeversion}" onConclusion="none">node-{nodeversion}.pkg</pkg-ref>
19+
<choice id="org.nodejs.npm.pkg" visible="true" title="npm {npmversion}">
20+
<pkg-ref id="org.nodejs.npm.pkg"/>
21+
</choice>
22+
<pkg-ref id="org.nodejs.npm.pkg" version="{npmversion}" onConclusion="none">npm-{npmversion}.pkg</pkg-ref>
23+
</installer-gui-script>

tools/osx-pkg.pmdoc/01local-contents.xml

-1
This file was deleted.

tools/osx-pkg.pmdoc/01local.xml

-25
This file was deleted.

tools/osx-pkg.pmdoc/02npm-contents.xml

-1
This file was deleted.

tools/osx-pkg.pmdoc/02npm.xml

-24
This file was deleted.

tools/osx-pkg.pmdoc/index.xml.tmpl

-55
This file was deleted.

0 commit comments

Comments
 (0)