pandoc/make_osx_package.sh

65 lines
2 KiB
Bash
Raw Normal View History

#!/bin/bash -e
2011-07-28 20:41:00 +02:00
DIST=`pwd`/osx_package
2013-09-15 02:32:54 +02:00
SANDBOX=`pwd`/.cabal-sandbox
2011-07-28 20:41:00 +02:00
VERSION=$(grep -e '^Version' pandoc.cabal | awk '{print $2}')
RESOURCES=$DIST/Resources
ROOT=$DIST/pandoc
2013-09-21 02:37:19 +02:00
DEST=$ROOT/usr/local
OSX=osx
SCRIPTS=$OSX/osx-resources
2011-07-28 20:41:00 +02:00
BASE=pandoc-$VERSION
ME=$(whoami)
PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
CPPHS=$SANDBOX/bin/cpphs
2011-07-28 20:41:00 +02:00
# echo Removing old files...
2011-07-28 20:41:00 +02:00
rm -rf $DIST
mkdir -p $RESOURCES
cabal sandbox init
echo Updating database
cabal update
2011-07-28 20:41:00 +02:00
echo Building pandoc...
cabal clean
# Use cpphs to avoid problems with clang cpp on ghc 7.8 osx:
cabal install cpphs hsb2hs
cabal install --ghc-options="-optl-mmacosx-version-min=10.6" --reinstall --flags="embed_data_files make-pandoc-man-pages" --ghc-options "-pgmP$CPPHS -optP--cpp" . pandoc-citeproc
2013-09-15 01:02:02 +02:00
# get pandoc-citeproc man page:
PANDOC_CITEPROC_PATH=`cabal unpack -d $DIST pandoc-citeproc | awk '{print $3;}'`
2014-08-15 07:53:30 +02:00
2013-09-21 02:37:19 +02:00
mkdir -p $DEST/bin
mkdir -p $DEST/share/man/man1
mkdir -p $DEST/share/man/man5
2014-08-18 08:24:21 +02:00
for f in pandoc pandoc-citeproc; do
2013-09-21 02:37:19 +02:00
cp $SANDBOX/bin/$f $DEST/bin/;
2013-09-15 01:02:02 +02:00
done
cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/
cp $SANDBOX/share/man/man1/pandoc.1 $DEST/share/man/man1/pandoc.1
2013-09-02 19:41:52 +02:00
chown -R $ME:staff $DIST
2011-07-28 20:41:00 +02:00
echo Copying license...
$SANDBOX/bin/pandoc --data data -t html5 -s COPYING -o $RESOURCES/license.html
2011-07-28 20:41:00 +02:00
echo Signing pandoc executable...
codesign --force --sign "Developer ID Application: John Macfarlane" $DEST/bin/pandoc
# make sure it's valid... returns nonzero exit code if it isn't:
2013-09-21 02:37:19 +02:00
spctl --assess --type execute $DEST/bin/pandoc
2011-07-28 20:41:00 +02:00
echo Creating OSX package...
# remove old package first
rm -rf $BASE.pkg
2013-09-02 19:41:52 +02:00
pkgbuild --root $DIST/pandoc --identifier net.johnmacfarlane.pandoc --version 1.13 --ownership recommended $DIST/pandoc.pkg
productbuild --distribution osx/distribution.xml --resources $DIST/Resources --package-path $DIST --version 1.13 --sign "Developer ID Installer: John Macfarlane" $BASE-osx.pkg
# verify signature
spctl --assess --type install $BASE-osx.pkg
# cleanup
rm -r $DIST