2013-12-08 19:30:14 +01:00
|
|
|
#!/bin/bash -e
|
2011-07-28 20:41:00 +02:00
|
|
|
|
2013-09-02 18:09:27 +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
|
2011-07-29 01:38:56 +02:00
|
|
|
ROOT=$DIST/pandoc
|
2013-09-21 02:37:19 +02:00
|
|
|
DEST=$ROOT/usr/local
|
2012-03-09 22:07:26 +01:00
|
|
|
SCRIPTS=osx-resources
|
2011-07-28 20:41:00 +02:00
|
|
|
BASE=pandoc-$VERSION
|
2014-01-04 20:43:47 +01:00
|
|
|
ME=$(whoami)
|
2013-02-09 22:44:44 +01:00
|
|
|
CODESIGNID="Developer ID Application: John Macfarlane"
|
2013-09-02 18:09:27 +02:00
|
|
|
PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
|
2014-01-06 08:18:14 +01:00
|
|
|
EXES="pandoc pandoc-citeproc"
|
2011-07-28 20:41:00 +02:00
|
|
|
|
2013-12-08 19:30:14 +01:00
|
|
|
read -s -p "sudo password: " PASSWORD
|
|
|
|
echo $PASSWORD | sudo -S echo "Password valid, continuing."
|
|
|
|
|
2011-07-28 20:41:00 +02:00
|
|
|
echo Removing old files...
|
|
|
|
rm -rf $DIST
|
|
|
|
mkdir -p $RESOURCES
|
|
|
|
|
2014-05-08 05:12:46 +02:00
|
|
|
cabal sandbox init
|
2013-09-15 01:02:02 +02:00
|
|
|
echo Updating database
|
|
|
|
cabal update
|
2013-09-02 18:09:27 +02:00
|
|
|
|
2011-07-28 20:41:00 +02:00
|
|
|
echo Building pandoc...
|
2013-10-21 19:39:37 +02:00
|
|
|
cabal clean
|
2014-05-05 03:48:38 +02:00
|
|
|
# Use cpphs to avoid problems with clang cpp on ghc 7.8 osx:
|
2014-05-06 16:25:05 +02:00
|
|
|
cabal install cpphs alex happy hsb2hs
|
2014-05-05 03:48:38 +02:00
|
|
|
cabal install --reinstall --flags="embed_data_files" --ghc-options '-pgmPcpphs -optP--cpp'
|
|
|
|
cabal install --reinstall --flags="embed_data_files" pandoc-citeproc --ghc-options '-pgmPcpphs -optP--cpp'
|
2013-09-15 01:02:02 +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
|
2013-09-15 01:02:02 +02:00
|
|
|
for f in $EXES; do
|
2013-09-21 02:37:19 +02:00
|
|
|
cp $SANDBOX/bin/$f $DEST/bin/;
|
|
|
|
cp $SANDBOX/share/man/man1/$f.1 $DEST/share/man/man1/
|
2013-09-15 01:02:02 +02:00
|
|
|
done
|
2013-09-21 02:37:19 +02:00
|
|
|
cp $SANDBOX/share/man/man5/pandoc_markdown.5 $DEST/share/man/man5/
|
2014-05-13 04:59:44 +02:00
|
|
|
cp $SCRIPTS/uninstall-pandoc.pl $DEST/bin/
|
2011-10-27 03:28:15 +02:00
|
|
|
|
2013-09-02 19:41:52 +02:00
|
|
|
chown -R $ME:staff $DIST
|
2013-09-21 02:37:19 +02:00
|
|
|
# gzip $DEST/share/man/man?/*.*
|
2011-10-27 03:28:15 +02:00
|
|
|
# cabal gives man pages the wrong permissions
|
2013-09-21 02:37:19 +02:00
|
|
|
chmod +r $DEST/share/man/man?/*.*
|
2011-07-28 20:41:00 +02:00
|
|
|
|
2011-07-29 01:38:56 +02:00
|
|
|
echo Copying license...
|
2013-09-15 02:32:54 +02:00
|
|
|
$SANDBOX/bin/pandoc --data data -t rtf -s COPYING -o $RESOURCES/License.rtf
|
2011-07-28 20:41:00 +02:00
|
|
|
|
2013-02-09 22:44:44 +01:00
|
|
|
echo Signing pandoc executable...
|
|
|
|
|
2013-09-21 02:37:19 +02:00
|
|
|
codesign --force --sign "$CODESIGNID" $DEST/bin/pandoc
|
2013-02-10 04:35:12 +01:00
|
|
|
# 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...
|
2013-12-08 19:30:14 +01:00
|
|
|
# remove old package first
|
|
|
|
echo $PASSWORD | sudo -S rm -rf $BASE.pkg $BASE.dmg
|
2011-07-28 20:41:00 +02:00
|
|
|
|
2013-01-19 20:11:34 +01:00
|
|
|
sudo $PACKAGEMAKER \
|
2011-07-29 01:38:56 +02:00
|
|
|
--root $ROOT \
|
|
|
|
--id net.johnmacfarlane.pandoc \
|
|
|
|
--resources $RESOURCES \
|
|
|
|
--version $VERSION \
|
2012-03-09 22:07:26 +01:00
|
|
|
--scripts $SCRIPTS \
|
2011-07-28 20:41:00 +02:00
|
|
|
--out $BASE.pkg
|
|
|
|
|
2013-09-02 19:41:52 +02:00
|
|
|
# --no-relocate
|
|
|
|
|
2013-02-09 22:44:44 +01:00
|
|
|
echo Signing package...
|
|
|
|
|
2013-02-10 04:22:58 +01:00
|
|
|
sudo codesign --force --sign "$CODESIGNID" $BASE.pkg
|
2013-02-10 04:35:12 +01:00
|
|
|
# make sure it's valid...
|
|
|
|
spctl --assess --type install $BASE.pkg
|
2013-02-09 22:44:44 +01:00
|
|
|
|
2013-12-08 19:30:14 +01:00
|
|
|
echo Creating zip...
|
|
|
|
zip -9 -r $BASE.pkg.zip $BASE.pkg
|
2011-07-28 20:41:00 +02:00
|
|
|
|
2013-12-08 19:30:14 +01:00
|
|
|
# echo Creating disk image...
|
|
|
|
# sudo hdiutil create "$BASE.dmg" \
|
|
|
|
# -format UDZO -ov \
|
|
|
|
# -volname "pandoc $VERSION" \
|
|
|
|
# -srcfolder $BASE.pkg
|
|
|
|
# sudo hdiutil internet-enable "$BASE.dmg"
|
2011-07-28 20:41:00 +02:00
|
|
|
|