Skip to content

Commit bf9157f

Browse files
committed
tools, build: 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: nodejs#15179 Fixes: nodejs#15012 Refs: nodejs#5656 Refs: nodejs#2571 Refs: nodejs#7097
1 parent a591610 commit bf9157f

12 files changed

Lines changed: 119 additions & 122 deletions

File tree

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ ipch/
6969
/config_fips.gypi
7070
*-nodegyp*
7171
/gyp-mac-tool
72-
/dist-osx
7372
/npm.wxs
7473
/tools/msvs/npm.wixobj
7574
/tools/msvs/genfiles/
76-
/tools/osx-pkg.pmdoc/index.xml
7775
/test/addons/??_*/
7876
email.md
7977
deps/v8-*
@@ -101,6 +99,7 @@ deps/npm/node_modules/.bin/
10199

102100
# build/release artifacts
103101
/*.tar.*
102+
/*.pkg
104103
/SHASUMS*.txt*
105104

106105
# test artifacts

Makefile

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,7 @@ BINARYTAR=$(BINARYNAME).tar
663663
XZ=$(shell which xz > /dev/null 2>&1; echo $$?)
664664
XZ_COMPRESSION ?= 9e
665665
PKG=$(TARNAME).pkg
666-
PACKAGEMAKER ?= /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
667-
PKGDIR=out/dist-osx
666+
MACOSOUTDIR=out/macos
668667

669668
release-only:
670669
@if [ "$(DISTTYPE)" != "nightly" ] && [ "$(DISTTYPE)" != "next-nightly" ] && \
@@ -699,24 +698,54 @@ release-only:
699698
fi
700699

701700
$(PKG): release-only
702-
$(RM) -r $(PKGDIR)
703-
$(RM) -r out/deps out/Release
701+
$(RM) -r $(MACOSOUTDIR)
702+
mkdir -p $(MACOSOUTDIR)/installer/productbuild
703+
cat tools/macos-installer/productbuild/distribution.xml.tmpl \
704+
| sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
705+
| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
706+
>$(MACOSOUTDIR)/installer/productbuild/distribution.xml ; \
707+
708+
@for dirname in tools/macos-installer/productbuild/Resources/*/; do \
709+
lang=$$(basename $$dirname) ; \
710+
mkdir -p $(MACOSOUTDIR)/installer/productbuild/Resources/$$lang ; \
711+
printf "Found localization directory $$dirname\n" ; \
712+
cat $$dirname/welcome.html.tmpl \
713+
| sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
714+
| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
715+
>$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/welcome.html ; \
716+
cat $$dirname/conclusion.html.tmpl \
717+
| sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
718+
| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
719+
>$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/conclusion.html ; \
720+
done
704721
$(PYTHON) ./configure \
705722
--dest-cpu=x64 \
706723
--tag=$(TAG) \
707724
--release-urlbase=$(RELEASE_URLBASE) \
708725
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
709-
$(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
710-
SIGN="$(CODESIGN_CERT)" PKGDIR="$(PKGDIR)/usr/local" bash \
726+
$(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/node
727+
SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/node/usr/local" bash \
711728
tools/osx-codesign.sh
712-
cat tools/osx-pkg.pmdoc/index.xml.tmpl \
713-
| sed -E "s/\\{nodeversion\\}/$(FULLVERSION)/g" \
714-
| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
715-
> tools/osx-pkg.pmdoc/index.xml
716-
$(PACKAGEMAKER) \
717-
--id "org.nodejs.pkg" \
718-
--doc tools/osx-pkg.pmdoc \
719-
--out $(PKG)
729+
mkdir -p $(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules
730+
mkdir -p $(MACOSOUTDIR)/pkgs
731+
mv $(MACOSOUTDIR)/dist/node/usr/local/lib/node_modules/npm \
732+
$(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules
733+
unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npm
734+
unlink $(MACOSOUTDIR)/dist/node/usr/local/bin/npx
735+
$(NODE) tools/license2rtf.js < LICENSE > \
736+
$(MACOSOUTDIR)/installer/productbuild/Resources/license.rtf
737+
cp doc/osx_installer_logo.png $(MACOSOUTDIR)/installer/productbuild/Resources
738+
pkgbuild --version $(FULLVERSION) \
739+
--identifier org.nodejs.node.pkg \
740+
--root $(MACOSOUTDIR)/dist/node $(MACOSOUTDIR)/pkgs/node-$(FULLVERSION).pkg
741+
pkgbuild --version $(NPMVERSION) \
742+
--identifier org.nodejs.npm.pkg \
743+
--root $(MACOSOUTDIR)/dist/npm \
744+
--scripts ./tools/macos-installer/pkgbuild/npm/scripts \
745+
$(MACOSOUTDIR)/pkgs/npm-$(NPMVERSION).pkg
746+
productbuild --distribution $(MACOSOUTDIR)/installer/productbuild/distribution.xml \
747+
--resources $(MACOSOUTDIR)/installer/productbuild/Resources \
748+
--package-path $(MACOSOUTDIR)/pkgs ./$(PKG)
720749
SIGN="$(PRODUCTSIGN_CERT)" PKG="$(PKG)" bash tools/osx-productsign.sh
721750

722751
pkg: $(PKG)
Lines changed: 5 additions & 0 deletions
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
Lines changed: 5 additions & 0 deletions
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
Lines changed: 23 additions & 0 deletions
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>
Lines changed: 19 additions & 0 deletions
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>
Lines changed: 23 additions & 0 deletions
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

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

Lines changed: 0 additions & 25 deletions
This file was deleted.

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

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)