diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-01-31 15:05:05 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-01-31 15:06:58 +0100 |
commit | c96b64e91b54481aa870566dbecae69df711223d (patch) | |
tree | 45557c3df8e5f94bc9218f37384db19bf8a88c1f /macos | |
parent | 99c2a31749bb409e4026907f011bb307b2096e8b (diff) | |
download | pandoc-c96b64e91b54481aa870566dbecae69df711223d.tar.gz |
Name change OSX -> MacOS.
Add a -MacOS suffix to mac package rather than -OSX.
CHanged local names from osx to macos.
Diffstat (limited to 'macos')
-rw-r--r-- | macos/distribution.xml.in | 30 | ||||
-rwxr-xr-x | macos/make_macos_package.sh | 74 | ||||
-rw-r--r-- | macos/stack.yaml | 28 | ||||
-rwxr-xr-x | macos/uninstall-pandoc.pl | 79 |
4 files changed, 211 insertions, 0 deletions
diff --git a/macos/distribution.xml.in b/macos/distribution.xml.in new file mode 100644 index 000000000..145fc0f21 --- /dev/null +++ b/macos/distribution.xml.in @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8" standalone="no"?> +<installer-gui-script minSpecVersion="1"> + <title>pandoc</title> + <organization>net.johnmacfarlane.pandoc</organization> + <domains enable_localSystem="true" enable_anywhere="true" /> + <options customize="allow" require-scripts="false" rootVolumeOnly="false" /> + <!-- Define documents displayed at various steps --> + <!-- <welcome file="welcome.html" mime-type="text/html" /> --> + <license file="license.html" mime-type="text/html" /> + <!-- <conclusion file="conclusion.html" mime-type="text/html" /> --> + <options hostArchitectures="x86_64" /> + <!-- List all component packages --> + <pkg-ref id="net.johnmacfarlane.pandoc" + version="PANDOCVERSION" + auth="root">pandoc.pkg</pkg-ref> + <!-- List them again here. They can now be organized + as a hierarchy if you want. --> + <choices-outline> + <line choice="net.johnmacfarlane.pandoc"/> + </choices-outline> + <!-- Define each choice above --> + <choice + id="net.johnmacfarlane.pandoc" + visible="false" + title="pandoc" + description="pandoc - universal text converter" + start_selected="true"> + <pkg-ref id="net.johnmacfarlane.pandoc"/> + </choice> +</installer-gui-script> diff --git a/macos/make_macos_package.sh b/macos/make_macos_package.sh new file mode 100755 index 000000000..d2c4d205b --- /dev/null +++ b/macos/make_macos_package.sh @@ -0,0 +1,74 @@ +#!/bin/bash -e + +LOCALBIN=$HOME/.local/bin +DIST=`pwd`/macos_package +MACOS=`pwd`/macos +VERSION=$(grep -e '^Version' pandoc.cabal | awk '{print $2}') +RESOURCES=$DIST/Resources +ROOT=$DIST/pandoc +DEST=$ROOT/usr/local +SCRIPTS=$MACOS/macos-resources +BASE=pandoc-$VERSION +ME=$(whoami) +PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker +DEVELOPER_ID_APPLICATION=${DEVELOPER_ID_APPLICATION:-Developer ID Application: John Macfarlane} +DEVELOPER_ID_INSTALLER=${DEVELOPER_ID_INSTALLER:-Developer ID Installer: John Macfarlane} + +# We need this for hsb2hs: +PATH=$LOCALBIN:$PATH +export MACMACOS_DEPLOYMENT_TARGET=10.7 + +# echo Removing old files... +rm -rf $DIST +mkdir -p $DIST +mkdir -p $RESOURCES +stack setup +which hsb2hs || stack install hsb2hs + +echo Building pandoc... +stack clean +stack install --stack-yaml=$MACOS/stack.yaml --local-bin-path . pandoc pandoc-citeproc + +echo Getting man pages... +make man/pandoc.1 + +# get pandoc-citeproc man page: +PANDOC_CITEPROC_VERSION=`pandoc-citeproc --version | awk '{print $2;}'` +PANDOC_CITEPROC_TARBALL=https://hackage.haskell.org/package/pandoc-citeproc-${PANDOC_CITEPROC_VERSION}/pandoc-citeproc-${PANDOC_CITEPROC_VERSION}.tar.gz +curl ${PANDOC_CITEPROC_TARBALL} | tar xzC $DIST +PANDOC_CITEPROC_PATH=$DIST/pandoc-citeproc-${PANDOC_CITEPROC_VERSION} + +mkdir -p $DEST/bin +mkdir -p $DEST/share/man/man1 +for f in pandoc pandoc-citeproc; do + cp $MACOS/$f $DEST/bin/; +done +cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/ +cp man/pandoc.1 $DEST/share/man/man1/ + +chown -R $ME:staff $DIST + +echo Copying license... +$MACOS/pandoc --data data -t html5 -s COPYING.md -o $RESOURCES/license.html + +# Removing executable signing because of a problem that arose in El Capitan +# "source=obsolete resource envelope" + +#echo Signing pandoc executable... + +#codesign --force --sign "${DEVELOPER_ID_APPLICATION}" $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 MacOS package... + +sed -e "s/PANDOCVERSION/$VERSION/" $MACOS/distribution.xml.in > $MACOS/distribution.xml + +pkgbuild --root $DIST/pandoc --identifier net.johnmacfarlane.pandoc --version 1.13 --ownership recommended $DIST/pandoc.pkg +productbuild --distribution $MACOS/distribution.xml --resources $DIST/Resources --package-path $DIST --version $VERSION --sign "${DEVELOPER_ID_INSTALLER}" $BASE-MacOS.pkg + +# verify signature +spctl --assess --type install $BASE-MacOS.pkg + +# cleanup +rm -r $DIST $MACOS/pandoc $MACOS/pandoc-citeproc diff --git a/macos/stack.yaml b/macos/stack.yaml new file mode 100644 index 000000000..c2062eff8 --- /dev/null +++ b/macos/stack.yaml @@ -0,0 +1,28 @@ +flags: + pandoc: + trypandoc: false + https: true + embed_data_files: true + old-locale: false + network-uri: true + pandoc-citeproc: + bibutils: true + embed_data_files: true + unicode_collation: false + test_citeproc: false + debug: false +ghc-options: + pandoc-citeproc: '-pgmP cpphs -optP--cpp' + highlighting-kate: '-pgmP cpphs -optP--cpp' +packages: +- '..' +- location: + git: https://github.com/jgm/pandoc-citeproc.git + commit: 9c8e86cf16fc3188836a15ee76d5b70c5315bdb8 + extra-dep: true +extra-deps: +- texmath-0.9 +- doctemplates-0.1.0.2 +- pandoc-types-1.17.0.4 +- skylighting-0.1.1.2 +resolver: lts-7.14 diff --git a/macos/uninstall-pandoc.pl b/macos/uninstall-pandoc.pl new file mode 100755 index 000000000..a5194d9bd --- /dev/null +++ b/macos/uninstall-pandoc.pl @@ -0,0 +1,79 @@ +#!/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'; + +# 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) ); + +# Get the list of files to remove. +my @pkg_files = `pkgutil --volume '$volume' --only-files --files '$pkg_id'`; +@pkg_files = map { chomp; File::Spec->rel2abs($_, $volume) } @pkg_files; + +# Confirm uninistall with the user. +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 my $file (@pkg_files) { + if ( -e $file ) { + if ( system( 'sudo', 'rm', $file ) == 0 ) { + warn "Deleted $file\n"; + } else { + warn "Unable to delete $file: $?\n"; + die "Aborting Uninstall.\n"; + } + } else { + warn "File $file does not exist. Skipping.\n"; + } + } + + # Clean up the install. + if (system('sudo', 'pkgutil', '--forget', $pkg_id, '--volume', $volume) != 0) { + die "Unable to clean up install: $?\n"; + } + +} else { + + print "OK, aborting uninstall.\n"; + exit; +} + +print "Pandoc has been successfully uninstalled.\n"; +exit; |