Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools, build: macOS installer improvements #15179

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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-*
Expand Down Expand Up @@ -101,6 +99,7 @@ deps/npm/node_modules/.bin/

# build/release artifacts
/*.tar.*
/*.pkg
/SHASUMS*.txt*

# test artifacts
Expand Down
57 changes: 43 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ] && \
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions tools/macos-installer/pkgbuild/npm/scripts/postinstall
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions tools/macos-installer/pkgbuild/npm/scripts/preinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

[[ -d /usr/local/lib/node_modules/npm ]] \
&& rm -rf /usr/local/lib/node_modules/npm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script needs to return an exit code 0 to work (see docosx). Otherwise it will abort (showing "The installation failed" if there isn't a /usr/local/lib/node_modules/npm ). Can you add

exit 0

to the end of this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure can

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't rm -f return 0 even when there was no file to remove? And when it failed to remove npm then we have an unexpected failure anyway.

exit 0
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>
23 changes: 23 additions & 0 deletions tools/macos-installer/productbuild/distribution.xml.tmpl
Original file line number Diff line number Diff line change
@@ -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>
1 change: 0 additions & 1 deletion tools/osx-pkg.pmdoc/01local-contents.xml

This file was deleted.

25 changes: 0 additions & 25 deletions tools/osx-pkg.pmdoc/01local.xml

This file was deleted.

1 change: 0 additions & 1 deletion tools/osx-pkg.pmdoc/02npm-contents.xml

This file was deleted.

24 changes: 0 additions & 24 deletions tools/osx-pkg.pmdoc/02npm.xml

This file was deleted.

55 changes: 0 additions & 55 deletions tools/osx-pkg.pmdoc/index.xml.tmpl

This file was deleted.