From 0d095be64f189def9324a1b323f0943d90224eb1 Mon Sep 17 00:00:00 2001
From: John MacFarlane <fiddlosopher@gmail.com>
Date: Fri, 9 Mar 2012 13:07:26 -0800
Subject: [PATCH] OSX package: Check for 64-bit Intel CPU before installing.

---
 make_osx_package.sh                     |  2 ++
 osx-resources/InstallationCheck         | 14 ++++++++++++++
 osx-resources/InstallationCheck.strings |  3 +++
 3 files changed, 19 insertions(+)
 create mode 100755 osx-resources/InstallationCheck
 create mode 100644 osx-resources/InstallationCheck.strings

diff --git a/make_osx_package.sh b/make_osx_package.sh
index cba1bf22c..ad8882bb9 100755
--- a/make_osx_package.sh
+++ b/make_osx_package.sh
@@ -4,6 +4,7 @@ DIST=osx_package
 VERSION=$(grep -e '^Version' pandoc.cabal | awk '{print $2}')
 RESOURCES=$DIST/Resources
 ROOT=$DIST/pandoc
+SCRIPTS=osx-resources
 BASE=pandoc-$VERSION
 ME=jgm
 
@@ -36,6 +37,7 @@ $PACKAGEMAKER \
     --resources $RESOURCES \
     --version $VERSION \
     --no-relocate \
+    --scripts $SCRIPTS \
     --out $BASE.pkg
 
 echo Creating disk image...
diff --git a/osx-resources/InstallationCheck b/osx-resources/InstallationCheck
new file mode 100755
index 000000000..4149b4c31
--- /dev/null
+++ b/osx-resources/InstallationCheck
@@ -0,0 +1,14 @@
+#!/bin/sh
+cputype=`sysctl -n hw.cputype`
+sixtyfourbit=`sysctl -n hw.cpu64bit_capable`
+
+if [ "x$cputype" != "x7" ] # x86
+then
+  exit 112
+fi
+
+if [ "x$sixtyfourbit" != "x1" ] # 64 bit
+then
+  exit 113
+fi
+
diff --git a/osx-resources/InstallationCheck.strings b/osx-resources/InstallationCheck.strings
new file mode 100644
index 000000000..6c8efe0d4
--- /dev/null
+++ b/osx-resources/InstallationCheck.strings
@@ -0,0 +1,3 @@
+"16" = "This installer works only on Intel Macs.";
+"17" = "This installer requires a 64-bit processor.";
+