git.iko.soy/typeable/pandoc
on 1.12.4.1 help sign in
typeable/pandoc/make_osx_package.sh
88 lines 2.4 kB history raw
1#!/bin/bash -e
3DIST=`pwd`/osx_package
4SANDBOX=`pwd`/.cabal-sandbox
5VERSION=$(grep -e '^Version' pandoc.cabal | awk '{print $2}')
6RESOURCES=$DIST/Resources
7ROOT=$DIST/pandoc
8DEST=$ROOT/usr/local
9OSX=osx
10SCRIPTS=$OSX/osx-resources
11BASE=pandoc-$VERSION
12ME=$(whoami)
13CODESIGNID="Developer ID Application: John Macfarlane"
14PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
15EXES="pandoc pandoc-citeproc"
17read -s -p "sudo password: " PASSWORD
18echo $PASSWORD | sudo -S echo "Password valid, continuing."
20echo Removing old files...
21rm -rf $DIST
22mkdir -p $RESOURCES
24cabal sandbox init
25echo Updating database
26cabal update
28echo Building pandoc...
29cabal clean
30# Use cpphs to avoid problems with clang cpp on ghc 7.8 osx:
31cabal install cpphs alex happy hsb2hs
32cabal install --reinstall --flags="embed_data_files" --ghc-options '-pgmPcpphs -optP--cpp'
33cabal install --reinstall --flags="embed_data_files" pandoc-citeproc --ghc-options '-pgmPcpphs -optP--cpp'
35mkdir -p $DEST/bin
36mkdir -p $DEST/share/man/man1
37mkdir -p $DEST/share/man/man5
38for f in $EXES; do
39 cp $SANDBOX/bin/$f $DEST/bin/;
40 cp $SANDBOX/share/man/man1/$f.1 $DEST/share/man/man1/
41done
42cp $SANDBOX/share/man/man5/pandoc_markdown.5 $DEST/share/man/man5/
43cp $OSX/uninstall-pandoc.pl $DEST/bin/
45chown -R $ME:staff $DIST
46# gzip $DEST/share/man/man?/*.*
47# cabal gives man pages the wrong permissions
48chmod +r $DEST/share/man/man?/*.*
50echo Copying license...
51$SANDBOX/bin/pandoc --data data -t rtf -s COPYING -o $RESOURCES/License.rtf
53echo Signing pandoc executable...
55codesign --force --sign "$CODESIGNID" $DEST/bin/pandoc
56# make sure it's valid... returns nonzero exit code if it isn't:
57spctl --assess --type execute $DEST/bin/pandoc
59echo Creating OSX package...
60# remove old package first
61echo $PASSWORD | sudo -S rm -rf $BASE.pkg $BASE.dmg
63sudo $PACKAGEMAKER \
64 --root $ROOT \
65 --id net.johnmacfarlane.pandoc \
66 --resources $RESOURCES \
67 --version $VERSION \
68 --scripts $SCRIPTS \
69 --out $BASE.pkg
71 # --no-relocate
73echo Signing package...
75sudo codesign --force --sign "$CODESIGNID" $BASE.pkg
76# make sure it's valid...
77spctl --assess --type install $BASE.pkg
79echo Creating zip...
80zip -9 -r $BASE.pkg.zip $BASE.pkg
82# echo Creating disk image...
83# sudo hdiutil create "$BASE.dmg" \
84# -format UDZO -ov \
85# -volname "pandoc $VERSION" \
86# -srcfolder $BASE.pkg
87# sudo hdiutil internet-enable "$BASE.dmg"