2013-12-08 19:30:14 +01:00
|
|
|
#!/bin/bash -e
|
2011-07-28 20:41:00 +02:00
|
|
|
|
2015-10-16 17:03:59 +02:00
|
|
|
LOCALBIN=$HOME/.local/bin
|
2017-11-21 18:35:59 +01:00
|
|
|
BASEDIR=`pwd`
|
2017-01-31 15:05:05 +01:00
|
|
|
DIST=`pwd`/macos_package
|
|
|
|
MACOS=`pwd`/macos
|
2011-07-28 20:41:00 +02:00
|
|
|
RESOURCES=$DIST/Resources
|
2011-07-29 01:38:56 +02:00
|
|
|
ROOT=$DIST/pandoc
|
2013-09-21 02:37:19 +02:00
|
|
|
DEST=$ROOT/usr/local
|
2017-06-04 21:02:11 +02:00
|
|
|
PANDOC=$DEST/bin/pandoc
|
2017-01-31 15:05:05 +01:00
|
|
|
SCRIPTS=$MACOS/macos-resources
|
2014-01-04 20:43:47 +01:00
|
|
|
ME=$(whoami)
|
2013-09-02 18:09:27 +02:00
|
|
|
PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
|
2016-01-14 18:20:52 +01:00
|
|
|
DEVELOPER_ID_APPLICATION=${DEVELOPER_ID_APPLICATION:-Developer ID Application: John Macfarlane}
|
|
|
|
DEVELOPER_ID_INSTALLER=${DEVELOPER_ID_INSTALLER:-Developer ID Installer: John Macfarlane}
|
2011-07-28 20:41:00 +02:00
|
|
|
|
2017-01-31 15:05:05 +01:00
|
|
|
export MACMACOS_DEPLOYMENT_TARGET=10.7
|
2015-10-25 05:23:40 +01:00
|
|
|
|
2014-08-15 09:46:01 +02:00
|
|
|
# echo Removing old files...
|
2011-07-28 20:41:00 +02:00
|
|
|
rm -rf $DIST
|
2015-10-25 06:00:44 +01:00
|
|
|
mkdir -p $DIST
|
2011-07-28 20:41:00 +02:00
|
|
|
mkdir -p $RESOURCES
|
2017-06-04 21:02:11 +02:00
|
|
|
mkdir -p $DEST/bin
|
|
|
|
mkdir -p $DEST/share/man/man1
|
|
|
|
|
2015-10-25 05:12:43 +01:00
|
|
|
stack setup
|
2011-07-28 20:41:00 +02:00
|
|
|
|
|
|
|
echo Building pandoc...
|
2015-10-25 05:12:43 +01:00
|
|
|
stack clean
|
2017-11-04 23:57:21 +01:00
|
|
|
stack install --ghc-options="-O2" --stack-yaml=stack.pkg.yaml --local-bin-path $DEST/bin/ pandoc pandoc-citeproc
|
2015-10-16 18:32:11 +02:00
|
|
|
|
2017-08-18 23:34:46 +02:00
|
|
|
strip $DEST/bin/pandoc
|
|
|
|
strip $DEST/bin/pandoc-citeproc
|
|
|
|
|
2015-10-16 18:32:11 +02:00
|
|
|
echo Getting man pages...
|
2015-10-16 17:03:59 +02:00
|
|
|
make man/pandoc.1
|
2015-10-25 06:00:44 +01:00
|
|
|
|
|
|
|
# get pandoc-citeproc man page:
|
2017-10-22 23:22:53 +02:00
|
|
|
PANDOC_CITEPROC_VERSION=`$DEST/bin/pandoc-citeproc --version | awk '{print $2;exit;}'`
|
2015-10-25 06:00:44 +01:00
|
|
|
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-25 06:18:13 +01:00
|
|
|
PANDOC_CITEPROC_PATH=$DIST/pandoc-citeproc-${PANDOC_CITEPROC_VERSION}
|
2014-08-15 07:53:30 +02:00
|
|
|
|
2015-10-16 18:32:11 +02:00
|
|
|
cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/
|
2015-10-16 17:03:59 +02:00
|
|
|
cp man/pandoc.1 $DEST/share/man/man1/
|
2011-10-27 03:28:15 +02:00
|
|
|
|
2013-09-02 19:41:52 +02:00
|
|
|
chown -R $ME:staff $DIST
|
2011-07-28 20:41:00 +02:00
|
|
|
|
2011-07-29 01:38:56 +02:00
|
|
|
echo Copying license...
|
2017-06-04 21:02:11 +02:00
|
|
|
$PANDOC --data data -t html5 -s COPYING.md -Vpagetitle="License" -o $RESOURCES/license.html
|
2011-07-28 20:41:00 +02:00
|
|
|
|
2016-06-04 23:01:40 +02:00
|
|
|
# Removing executable signing because of a problem that arose in El Capitan
|
|
|
|
# "source=obsolete resource envelope"
|
2013-02-09 22:44:44 +01:00
|
|
|
|
2016-06-04 23:01:40 +02:00
|
|
|
#echo Signing pandoc executable...
|
|
|
|
|
|
|
|
#codesign --force --sign "${DEVELOPER_ID_APPLICATION}" $DEST/bin/pandoc
|
2013-02-10 04:35:12 +01:00
|
|
|
# make sure it's valid... returns nonzero exit code if it isn't:
|
2016-06-04 23:01:40 +02:00
|
|
|
#spctl --assess --type execute $DEST/bin/pandoc
|
2011-07-28 20:41:00 +02:00
|
|
|
|
2017-08-23 22:48:10 +02:00
|
|
|
echo Creating macOS package...
|
2013-09-02 19:41:52 +02:00
|
|
|
|
2017-10-22 23:22:53 +02:00
|
|
|
VERSION=`$DEST/bin/pandoc --version | awk '{print $2;exit;}'`
|
|
|
|
BASE=pandoc-$VERSION
|
|
|
|
|
2017-01-31 15:05:05 +01:00
|
|
|
sed -e "s/PANDOCVERSION/$VERSION/" $MACOS/distribution.xml.in > $MACOS/distribution.xml
|
2016-03-20 02:53:43 +01:00
|
|
|
|
2017-06-04 21:02:11 +02:00
|
|
|
pkgbuild --root $ROOT --identifier net.johnmacfarlane.pandoc --version $VERSION --ownership recommended $DIST/pandoc.pkg
|
2017-08-23 22:48:10 +02:00
|
|
|
productbuild --distribution $MACOS/distribution.xml --resources $DIST/Resources --package-path $DIST --version $VERSION --sign "${DEVELOPER_ID_INSTALLER}" $BASE-macOS.pkg
|
2013-02-09 22:44:44 +01:00
|
|
|
|
2014-08-15 09:46:01 +02:00
|
|
|
# verify signature
|
2017-08-23 22:48:10 +02:00
|
|
|
spctl --assess --type install $BASE-macOS.pkg
|
2013-02-09 22:44:44 +01:00
|
|
|
|
2017-11-21 18:35:59 +01:00
|
|
|
echo "Created $BASE-macOS.pkg"
|
|
|
|
|
|
|
|
# create zip
|
|
|
|
cd $DEST
|
|
|
|
cd ..
|
|
|
|
mv local $BASE
|
|
|
|
zip -r $BASEDIR/$BASE-macOS.zip $BASE
|
|
|
|
cd $BASEDIR
|
|
|
|
|
|
|
|
echo "Created $BASE-macOS.zip"
|
|
|
|
|
2014-08-15 09:46:01 +02:00
|
|
|
# cleanup
|
2017-06-04 21:02:11 +02:00
|
|
|
rm -r $DIST
|