git.iko.soy/typeable/pandoc
on 4eff607 help sign in
typeable/pandoc/make_osx_package.sh
76 lines 2.5 kB history raw
1#!/bin/bash -e
3LOCALBIN=$HOME/.local/bin
4DIST=`pwd`/osx_package
5OSX=`pwd`/osx
6VERSION=$(grep -e '^Version' pandoc.cabal | awk '{print $2}')
7RESOURCES=$DIST/Resources
8ROOT=$DIST/pandoc
9DEST=$ROOT/usr/local
10SCRIPTS=$OSX/osx-resources
11BASE=pandoc-$VERSION
12ME=$(whoami)
13PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
14DEVELOPER_ID_APPLICATION=${DEVELOPER_ID_APPLICATION:-Developer ID Application: John Macfarlane}
15DEVELOPER_ID_INSTALLER=${DEVELOPER_ID_INSTALLER:-Developer ID Installer: John Macfarlane}
17# We need this for hsb2hs:
18PATH=$LOCALBIN:$PATH
19export MACOSX_DEPLOYMENT_TARGET=10.7
21# echo Removing old files...
22rm -rf $DIST
23mkdir -p $DIST
24mkdir -p $RESOURCES
25stack setup
26which hsb2hs || stack install hsb2hs
28echo Building pandoc...
29stack clean
30stack install --stack-yaml=$OSX/stack.yaml --local-bin-path . pandoc pandoc-citeproc
32echo Getting man pages...
33make man/pandoc.1
35# get pandoc-citeproc man page:
36PANDOC_CITEPROC_VERSION=`pandoc-citeproc --version | awk '{print $2;}'`
37PANDOC_CITEPROC_TARBALL=https://hackage.haskell.org/package/pandoc-citeproc-${PANDOC_CITEPROC_VERSION}/pandoc-citeproc-${PANDOC_CITEPROC_VERSION}.tar.gz
38curl ${PANDOC_CITEPROC_TARBALL} | tar xzC $DIST
39PANDOC_CITEPROC_PATH=$DIST/pandoc-citeproc-${PANDOC_CITEPROC_VERSION}
41mkdir -p $DEST/bin
42mkdir -p $DEST/share/man/man1
43for f in pandoc pandoc-citeproc; do
44 cp $OSX/$f $DEST/bin/;
45done
46cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/
47cp man/pandoc.1 $DEST/share/man/man1/
49chown -R $ME:staff $DIST
51echo Copying license...
52$OSX/pandoc --data data -t html5 -s COPYING -o $RESOURCES/license.html
54# Removing executable signing because of a problem that arose in El Capitan
55# "source=obsolete resource envelope"
57#echo Signing pandoc executable...
59#codesign --force --sign "${DEVELOPER_ID_APPLICATION}" $DEST/bin/pandoc
60# make sure it's valid... returns nonzero exit code if it isn't:
61#spctl --assess --type execute $DEST/bin/pandoc
63echo Creating OSX package...
64# remove old package first
65rm -rf $BASE.pkg
67sed -e "s/PANDOCVERSION/$VERSION/" $OSX/distribution.xml.in > $OSX/distribution.xml
69pkgbuild --root $DIST/pandoc --identifier net.johnmacfarlane.pandoc --version 1.13 --ownership recommended $DIST/pandoc.pkg
70productbuild --distribution $OSX/distribution.xml --resources $DIST/Resources --package-path $DIST --version $VERSION --sign "${DEVELOPER_ID_INSTALLER}" $BASE-osx.pkg
72# verify signature
73spctl --assess --type install $BASE-osx.pkg
75# cleanup
76rm -r $DIST $OSX/pandoc $OSX/pandoc-citeproc