2013-12-08 10:30:14 -08:00
|
|
|
#!/bin/bash -e
|
2011-07-28 11:41:00 -07:00
|
|
|
|
2015-10-16 08:03:59 -07:00
|
|
|
LOCALBIN=$HOME/.local/bin
|
2013-09-02 09:09:27 -07:00
|
|
|
DIST=`pwd`/osx_package
|
2011-07-28 11:41:00 -07:00
|
|
|
VERSION=$(grep -e '^Version' pandoc.cabal | awk '{print $2}')
|
|
|
|
RESOURCES=$DIST/Resources
|
2011-07-28 16:38:56 -07:00
|
|
|
ROOT=$DIST/pandoc
|
2013-09-20 17:37:19 -07:00
|
|
|
DEST=$ROOT/usr/local
|
2014-05-12 20:05:16 -07:00
|
|
|
OSX=osx
|
|
|
|
SCRIPTS=$OSX/osx-resources
|
2011-07-28 11:41:00 -07:00
|
|
|
BASE=pandoc-$VERSION
|
2014-01-04 11:43:47 -08:00
|
|
|
ME=$(whoami)
|
2013-09-02 09:09:27 -07:00
|
|
|
PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
|
2011-07-28 11:41:00 -07:00
|
|
|
|
2015-10-24 21:23:40 -07:00
|
|
|
# We need this for hsb2hs:
|
|
|
|
PATH=$LOCALBIN:$PATH
|
2015-11-15 12:48:54 -08:00
|
|
|
export MACOSX_DEPLOYMENT_TARGET=10.7
|
2015-10-24 21:23:40 -07:00
|
|
|
|
2014-08-15 00:46:01 -07:00
|
|
|
# echo Removing old files...
|
2011-07-28 11:41:00 -07:00
|
|
|
rm -rf $DIST
|
2015-10-24 22:00:44 -07:00
|
|
|
mkdir -p $DIST
|
2011-07-28 11:41:00 -07:00
|
|
|
mkdir -p $RESOURCES
|
2015-10-24 21:12:43 -07:00
|
|
|
stack setup
|
2015-11-15 13:39:29 -08:00
|
|
|
which hsb2hs || stack install --stack-yaml=stack.hsb2hs.yaml
|
2011-07-28 11:41:00 -07:00
|
|
|
|
|
|
|
echo Building pandoc...
|
2015-10-24 21:12:43 -07:00
|
|
|
stack clean
|
|
|
|
stack install --stack-yaml=osx/stack.yaml
|
2015-10-16 09:32:11 -07:00
|
|
|
|
|
|
|
echo Getting man pages...
|
2015-10-16 08:03:59 -07:00
|
|
|
make man/pandoc.1
|
2015-10-24 22:00:44 -07:00
|
|
|
|
|
|
|
# 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
|
2015-10-24 22:18:13 -07:00
|
|
|
PANDOC_CITEPROC_PATH=$DIST/pandoc-citeproc-${PANDOC_CITEPROC_VERSION}
|
2014-08-14 22:53:30 -07:00
|
|
|
|
2013-09-20 17:37:19 -07:00
|
|
|
mkdir -p $DEST/bin
|
|
|
|
mkdir -p $DEST/share/man/man1
|
2014-08-17 23:24:21 -07:00
|
|
|
for f in pandoc pandoc-citeproc; do
|
2015-10-16 08:03:59 -07:00
|
|
|
cp $LOCALBIN/$f $DEST/bin/;
|
2013-09-14 16:02:02 -07:00
|
|
|
done
|
2015-10-16 09:32:11 -07:00
|
|
|
cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/
|
2015-10-16 08:03:59 -07:00
|
|
|
cp man/pandoc.1 $DEST/share/man/man1/
|
2011-10-26 18:28:15 -07:00
|
|
|
|
2013-09-02 10:41:52 -07:00
|
|
|
chown -R $ME:staff $DIST
|
2011-07-28 11:41:00 -07:00
|
|
|
|
2011-07-28 16:38:56 -07:00
|
|
|
echo Copying license...
|
2015-10-16 08:03:59 -07:00
|
|
|
$LOCALBIN/pandoc --data data -t html5 -s COPYING -o $RESOURCES/license.html
|
2011-07-28 11:41:00 -07:00
|
|
|
|
2013-02-09 13:44:44 -08:00
|
|
|
echo Signing pandoc executable...
|
|
|
|
|
2014-08-15 00:46:01 -07:00
|
|
|
codesign --force --sign "Developer ID Application: John Macfarlane" $DEST/bin/pandoc
|
2013-02-09 19:35:12 -08:00
|
|
|
# make sure it's valid... returns nonzero exit code if it isn't:
|
2013-09-20 17:37:19 -07:00
|
|
|
spctl --assess --type execute $DEST/bin/pandoc
|
2011-07-28 11:41:00 -07:00
|
|
|
|
|
|
|
echo Creating OSX package...
|
2013-12-08 10:30:14 -08:00
|
|
|
# remove old package first
|
2014-08-15 00:46:01 -07:00
|
|
|
rm -rf $BASE.pkg
|
2013-09-02 10:41:52 -07:00
|
|
|
|
2014-08-15 00:46:01 -07:00
|
|
|
pkgbuild --root $DIST/pandoc --identifier net.johnmacfarlane.pandoc --version 1.13 --ownership recommended $DIST/pandoc.pkg
|
2014-08-15 09:51:59 -07:00
|
|
|
productbuild --distribution osx/distribution.xml --resources $DIST/Resources --package-path $DIST --version 1.13 --sign "Developer ID Installer: John Macfarlane" $BASE-osx.pkg
|
2013-02-09 13:44:44 -08:00
|
|
|
|
2014-08-15 00:46:01 -07:00
|
|
|
# verify signature
|
2014-08-15 09:51:59 -07:00
|
|
|
spctl --assess --type install $BASE-osx.pkg
|
2013-02-09 13:44:44 -08:00
|
|
|
|
2014-08-15 00:46:01 -07:00
|
|
|
# cleanup
|
|
|
|
rm -r $DIST
|