pandoc/macos/make_macos_package.sh

87 lines
2.6 KiB
Bash
Raw Normal View History

#!/bin/bash -e
2011-07-28 20:41:00 +02:00
LOCALBIN=$HOME/.local/bin
2017-11-21 18:35:59 +01:00
BASEDIR=`pwd`
DIST=`pwd`/macos_package
MACOS=`pwd`/macos
2011-07-28 20:41:00 +02:00
RESOURCES=$DIST/Resources
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
SCRIPTS=$MACOS/macos-resources
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}
2011-07-28 20:41:00 +02:00
export MACMACOS_DEPLOYMENT_TARGET=10.7
# echo Removing old files...
2011-07-28 20:41:00 +02:00
rm -rf $DIST
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
stack setup
2011-07-28 20:41:00 +02:00
echo Building pandoc...
stack clean
stack install --ghc-options="-O2" --stack-yaml=stack.pkg.yaml --local-bin-path $DEST/bin/ pandoc pandoc-citeproc
strip $DEST/bin/pandoc
strip $DEST/bin/pandoc-citeproc
echo Getting man pages...
make man/pandoc.1
# get pandoc-citeproc man page:
PANDOC_CITEPROC_VERSION=`$DEST/bin/pandoc-citeproc --version | awk '{print $2;exit;}'`
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
cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/
cp man/pandoc.1 $DEST/share/man/man1/
2013-09-02 19:41:52 +02:00
chown -R $ME:staff $DIST
2011-07-28 20:41:00 +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
# 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
2011-07-28 20:41:00 +02:00
echo Creating macOS package...
2013-09-02 19:41:52 +02:00
VERSION=`$DEST/bin/pandoc --version | awk '{print $2;exit;}'`
BASE=pandoc-$VERSION
sed -e "s/PANDOCVERSION/$VERSION/" $MACOS/distribution.xml.in > $MACOS/distribution.xml
2017-06-04 21:02:11 +02:00
pkgbuild --root $ROOT --identifier net.johnmacfarlane.pandoc --version $VERSION --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
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"
# cleanup
2017-06-04 21:02:11 +02:00
rm -r $DIST