diff --git a/.gitignore b/.gitignore
index c7361af80c79dc..2f622a091347b9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,6 +54,10 @@ ipch/
/tools/msvs/npm.wixobj
/tools/msvs/genfiles/
/tools/osx-pkg.pmdoc/index.xml
+/tools/osx-pkg/resources/welcome.rtf
+/tools/osx-pkg/resources/LICENSE
+/tools/osx-pkg/resources/**/welcome.rtf
+*node*.pkg
/test/addons/??_*/
email.md
deps/v8-*
diff --git a/Makefile b/Makefile
index 9a5bbf2f79c497..36087cc67237ce 100644
--- a/Makefile
+++ b/Makefile
@@ -469,14 +469,31 @@ $(PKG): release-only
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
$(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
SIGN="$(CODESIGN_CERT)" PKGDIR="$(PKGDIR)" 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)
+ FULLVERSION="$(FULLVERSION)" NPMVERSION="$(NPMVERSION)" tools/osx-pkg/copy_langs.sh
+
+ cp LICENSE tools/osx-pkg/resources/LICENSE
+
+ pkgbuild \
+ --root $(PKGDIR) \
+ --identifier org.nodejs.node.pkg \
+ --version 1 \
+ --install-location / \
+ org.nodejs.node.pkg
+
+ pkgbuild \
+ --root deps/npm \
+ --identifier org.nodejs.npm.pkg \
+ --version 1 \
+ --install-location / \
+ --scripts tools/osx-pkg/scripts \
+ org.nodejs.npm.pkg
+
+ productbuild \
+ --distribution tools/osx-pkg/node.xml \
+ --resources tools/osx-pkg/resources \
+ --package-path tools/osx-pkg \
+ $(PKG)
+
SIGN="$(PRODUCTSIGN_CERT)" PKG="$(PKG)" bash tools/osx-productsign.sh
pkg: $(PKG)
diff --git a/tools/osx-pkg-postinstall.sh b/tools/osx-pkg-postinstall.sh
deleted file mode 100644
index c4c872fc785493..00000000000000
--- a/tools/osx-pkg-postinstall.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-# TODO Can this be done inside the .pmdoc?
-# TODO Can we extract $PREFIX from the installer?
-cd /usr/local/bin
-ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm
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
-
diff --git a/tools/osx-pkg/copy_langs.sh b/tools/osx-pkg/copy_langs.sh
new file mode 100755
index 00000000000000..c6c1f1d4fc6553
--- /dev/null
+++ b/tools/osx-pkg/copy_langs.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+set -e
+set -x
+
+FULLVERSION="$FULLVERSION"
+NPMVERSION="$NPMVERSION"
+
+for dir in tools/osx-pkg/languages/*; do
+ if [[ -d "$dir" ]]; then
+ d=$(basename "$dir")
+ mkdir -p tools/osx-pkg/resources/"$d"
+ cat "$dir/welcome.rtf.tmpl" \
+ | sed -E "s/\\{nodeversion\\}/$FULLVERSION/g" \
+ | sed -E "s/\\{npmversion\\}/$NPMVERSION/g" \
+ > tools/osx-pkg/resources/"$d"/welcome.rtf
+ fi
+done
diff --git a/tools/osx-pkg/languages/en.lproj/welcome.rtf.tmpl b/tools/osx-pkg/languages/en.lproj/welcome.rtf.tmpl
new file mode 100644
index 00000000000000..16e80091460785
--- /dev/null
+++ b/tools/osx-pkg/languages/en.lproj/welcome.rtf.tmpl
@@ -0,0 +1,6 @@
+{\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/.}
diff --git a/tools/osx-pkg/node.xml b/tools/osx-pkg/node.xml
new file mode 100644
index 00000000000000..1b0ad74c174e66
--- /dev/null
+++ b/tools/osx-pkg/node.xml
@@ -0,0 +1,26 @@
+
+
+
+
+ Node.js
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.nodejs.node.pkg
+
+
+
+ org.nodejs.npm.pkg
+
diff --git a/tools/osx-pkg/resources/conclusion.rtf b/tools/osx-pkg/resources/conclusion.rtf
new file mode 100644
index 00000000000000..0547516065d38f
--- /dev/null
+++ b/tools/osx-pkg/resources/conclusion.rtf
@@ -0,0 +1,14 @@
+{\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.}
diff --git a/tools/osx-pkg/resources/osx_installer_logo.png b/tools/osx-pkg/resources/osx_installer_logo.png
new file mode 100644
index 00000000000000..765a2193d26f1b
Binary files /dev/null and b/tools/osx-pkg/resources/osx_installer_logo.png differ
diff --git a/tools/osx-pkg/scripts/postinstall b/tools/osx-pkg/scripts/postinstall
new file mode 100755
index 00000000000000..65a9dfd0b49614
--- /dev/null
+++ b/tools/osx-pkg/scripts/postinstall
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd /usr/local/bin
+ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm
diff --git a/tools/osx-pkg/scripts/preflight b/tools/osx-pkg/scripts/preflight
new file mode 100755
index 00000000000000..baf0287fd00407
--- /dev/null
+++ b/tools/osx-pkg/scripts/preflight
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+[[ -d /usr/local/lib/node_modules/npm ]] \
+ && rm -rf /usr/local/lib/node_modules/npm