aboutsummaryrefslogtreecommitdiff
path: root/osx
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2014-05-12 19:59:44 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2014-05-12 19:59:44 -0700
commit1e8cd2c27755bac4086489e9a6eed19bf4d72d45 (patch)
treebcd1f56a06213753d5855cf4c591bd80001c27a8 /osx
parent77b2589d3f10f988ddf6804dee401112057f5a17 (diff)
downloadpandoc-1e8cd2c27755bac4086489e9a6eed19bf4d72d45.tar.gz
Moved osx package stuff to osx directory; added uninstall script.
Thanks to Daniel T. Staal for an uninstall script from which this one is modified.
Diffstat (limited to 'osx')
-rwxr-xr-xosx/make_osx_package.sh87
-rwxr-xr-xosx/osx-resources/InstallationCheck14
-rw-r--r--osx/osx-resources/InstallationCheck.strings3
-rwxr-xr-xosx/uninstall-pandoc.pl81
4 files changed, 185 insertions, 0 deletions
diff --git a/osx/make_osx_package.sh b/osx/make_osx_package.sh
new file mode 100755
index 000000000..c28f8fe5f
--- /dev/null
+++ b/osx/make_osx_package.sh
@@ -0,0 +1,87 @@
+#!/bin/bash -e
+
+DIST=`pwd`/osx_package
+SANDBOX=`pwd`/.cabal-sandbox
+VERSION=$(grep -e '^Version' pandoc.cabal | awk '{print $2}')
+RESOURCES=$DIST/Resources
+ROOT=$DIST/pandoc
+DEST=$ROOT/usr/local
+SCRIPTS=osx-resources
+BASE=pandoc-$VERSION
+ME=$(whoami)
+CODESIGNID="Developer ID Application: John Macfarlane"
+PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
+EXES="pandoc pandoc-citeproc"
+
+read -s -p "sudo password: " PASSWORD
+echo $PASSWORD | sudo -S echo "Password valid, continuing."
+
+echo Removing old files...
+rm -rf $DIST
+mkdir -p $RESOURCES
+
+cabal sandbox init
+echo Updating database
+cabal update
+
+echo Building pandoc...
+cabal clean
+# Use cpphs to avoid problems with clang cpp on ghc 7.8 osx:
+cabal install cpphs alex happy hsb2hs
+cabal install --reinstall --flags="embed_data_files" --ghc-options '-pgmPcpphs -optP--cpp'
+cabal install --reinstall --flags="embed_data_files" pandoc-citeproc --ghc-options '-pgmPcpphs -optP--cpp'
+
+mkdir -p $DEST/bin
+mkdir -p $DEST/share/man/man1
+mkdir -p $DEST/share/man/man5
+for f in $EXES; do
+ cp $SANDBOX/bin/$f $DEST/bin/;
+ cp $SANDBOX/share/man/man1/$f.1 $DEST/share/man/man1/
+done
+cp $SANDBOX/share/man/man5/pandoc_markdown.5 $DEST/share/man/man5/
+cp $SCRIPTS/uninstall-pandoc.pl $DEST/bin/
+
+chown -R $ME:staff $DIST
+# gzip $DEST/share/man/man?/*.*
+# cabal gives man pages the wrong permissions
+chmod +r $DEST/share/man/man?/*.*
+
+echo Copying license...
+$SANDBOX/bin/pandoc --data data -t rtf -s COPYING -o $RESOURCES/License.rtf
+
+echo Signing pandoc executable...
+
+codesign --force --sign "$CODESIGNID" $DEST/bin/pandoc
+# make sure it's valid... returns nonzero exit code if it isn't:
+spctl --assess --type execute $DEST/bin/pandoc
+
+echo Creating OSX package...
+# remove old package first
+echo $PASSWORD | sudo -S rm -rf $BASE.pkg $BASE.dmg
+
+sudo $PACKAGEMAKER \
+ --root $ROOT \
+ --id net.johnmacfarlane.pandoc \
+ --resources $RESOURCES \
+ --version $VERSION \
+ --scripts $SCRIPTS \
+ --out $BASE.pkg
+
+ # --no-relocate
+
+echo Signing package...
+
+sudo codesign --force --sign "$CODESIGNID" $BASE.pkg
+# make sure it's valid...
+spctl --assess --type install $BASE.pkg
+
+echo Creating zip...
+zip -9 -r $BASE.pkg.zip $BASE.pkg
+
+# echo Creating disk image...
+# sudo hdiutil create "$BASE.dmg" \
+# -format UDZO -ov \
+# -volname "pandoc $VERSION" \
+# -srcfolder $BASE.pkg
+# sudo hdiutil internet-enable "$BASE.dmg"
+
diff --git a/osx/osx-resources/InstallationCheck b/osx/osx-resources/InstallationCheck
new file mode 100755
index 000000000..2bd691f5c
--- /dev/null
+++ b/osx/osx-resources/InstallationCheck
@@ -0,0 +1,14 @@
+#!/bin/sh
+cputype=`/usr/sbin/sysctl -n hw.cputype`
+sixtyfourbit=`/usr/sbin/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/osx-resources/InstallationCheck.strings b/osx/osx-resources/InstallationCheck.strings
new file mode 100644
index 000000000..6c8efe0d4
--- /dev/null
+++ b/osx/osx-resources/InstallationCheck.strings
@@ -0,0 +1,3 @@
+"16" = "This installer works only on Intel Macs.";
+"17" = "This installer requires a 64-bit processor.";
+
diff --git a/osx/uninstall-pandoc.pl b/osx/uninstall-pandoc.pl
new file mode 100755
index 000000000..292bcfd96
--- /dev/null
+++ b/osx/uninstall-pandoc.pl
@@ -0,0 +1,81 @@
+#!/usr/bin/perl
+
+# Script to remove all files installed by the OSX pandoc installer
+# and unregister the package. Modified from a script contributed
+# by Daniel T. Staal.
+
+use warnings;
+use strict;
+
+use File::Spec;
+
+# The main info: this is the list of files to remove and the pkg_id.
+my $pkg_id = 'net.johnmacfarlane.pandoc';
+
+my @pkg_info;
+
+# Find which, if any, volume Pandoc is installed on.
+my $volume;
+
+# First check /, then other volumes on the box.
+my $cur_test = `pkgutil --pkgs=$pkg_id`;
+if ( $cur_test =~ m/$pkg_id/ ) {
+ $volume = '/';
+} else {
+ opendir( my $dh, '/Volumes' ) or die "Can't list Volumes: $!\n";
+ foreach my $dir ( readdir($dh) ) {
+ next if $dir =~ m/^\./; # Skip dotfiles.
+
+ my $path = File::Spec->rel2abs( $dir, '/Volumes' );
+ next if !( -d $path ); # Skip anything that isn't a directory.
+
+ my $cur_test = `pkgutil --pkgs=$pkg_id --volume '$path'`;
+ if ( $cur_test =~ m/$pkg_id/ ) {
+ $volume = $path;
+ last;
+ }
+ }
+}
+
+die "Pandoc not installed.\n" if !( defined($volume) );
+
+my @pkg_files = ();
+my $f;
+for $f (split '\n', `pkgutil --volume '$volume' --only-files --files $pkg_id`) {
+ push @pkg_files, File::Spec->rel2abs($f, $volume);
+};
+
+print "The following files will be deleted:\n\n";
+print join("\n", @pkg_files);
+print "\n\n";
+print "Do you want to proceed and uninstall pandoc (Y/N)?";
+my $input = <STDIN>;
+
+if ($input =~ m/^[Yy]/) {
+
+ # Actually remove the files.
+ foreach $f (@pkg_files) {
+ if (system("sudo rm $f") == 0) {
+ warn "Deleted $f\n";
+ } else {
+ warn "Unable to delete $f: $!\n";
+ warn "Aborting uninstall.\n";
+ exit 1;
+ }
+ }
+
+ # Clean up the install.
+ if (system("sudo pkgutil --forget $pkg_id --volume '$volume'") != 0) {
+ warn "Unable to clean up install: $!\n";
+ exit 1;
+ }
+
+} else {
+
+ print "OK, aborting uninstall.\n";
+ exit 0;
+
+}
+
+print "Pandoc has been successfully uninstalled.\n";
+exit 0;