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