From c96b64e91b54481aa870566dbecae69df711223d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 31 Jan 2017 15:05:05 +0100 Subject: Name change OSX -> MacOS. Add a -MacOS suffix to mac package rather than -OSX. CHanged local names from osx to macos. --- macos/distribution.xml.in | 30 +++++++++++++++++ macos/make_macos_package.sh | 74 ++++++++++++++++++++++++++++++++++++++++++ macos/stack.yaml | 28 ++++++++++++++++ macos/uninstall-pandoc.pl | 79 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 211 insertions(+) create mode 100644 macos/distribution.xml.in create mode 100755 macos/make_macos_package.sh create mode 100644 macos/stack.yaml create mode 100755 macos/uninstall-pandoc.pl (limited to 'macos') 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 @@ + + + pandoc + net.johnmacfarlane.pandoc + + + + + + + + + pandoc.pkg + + + + + + + + + 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 = ; + +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; -- cgit v1.2.3