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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
#!/bin/bash
set -e
die () {
echo "Error: $1" >&2
exit 1
}
if ! [ -d installer-scripts ]
then
die "Doesn't look like you are running this script from the right location"
fi
if [ "$#" -ne 1 ]
then
die "Must be given one argument (the bindist)"
fi
BINDIST="$1"
GHC_UNPACKS_INTO=`echo "$BINDIST" | sed 's/^\(.*\/\)\{0,1\}\(ghc-\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\(\.\([0-9]\{1,\}\)\)\{0,1\}\)-\([a-z0-9_]\{1,\}\)-apple-darwin\.tar\.bz2$/\2/'`
GHC_VERSION_DIG1=`echo "$BINDIST" | sed 's/^\(.*\/\)\{0,1\}\(ghc-\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\(\.\([0-9]\{1,\}\)\)\{0,1\}\)-\([a-z0-9_]\{1,\}\)-apple-darwin\.tar\.bz2$/\3/'`
GHC_VERSION_DIG2=`echo "$BINDIST" | sed 's/^\(.*\/\)\{0,1\}\(ghc-\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\(\.\([0-9]\{1,\}\)\)\{0,1\}\)-\([a-z0-9_]\{1,\}\)-apple-darwin\.tar\.bz2$/\4/'`
GHC_VERSION_DIG3=`echo "$BINDIST" | sed 's/^\(.*\/\)\{0,1\}\(ghc-\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\(\.\([0-9]\{1,\}\)\)\{0,1\}\)-\([a-z0-9_]\{1,\}\)-apple-darwin\.tar\.bz2$/\5/'`
GHC_VERSION_DIG4=`echo "$BINDIST" | sed 's/^\(.*\/\)\{0,1\}\(ghc-\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\(\.\([0-9]\{1,\}\)\)\{0,1\}\)-\([a-z0-9_]\{1,\}\)-apple-darwin\.tar\.bz2$/\7/'`
GHC_ARCHITECTURE=`echo "$BINDIST" | sed 's/^\(.*\/\)\{0,1\}\(ghc-\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\(\.\([0-9]\{1,\}\)\)\{0,1\}\)-\([a-z0-9_]\{1,\}\)-apple-darwin\.tar\.bz2$/\8/'`
if [ "$GHC_ARCHITECTURE" == "$BINDIST" ]
then
die "Bindist filename not in expected format"
fi
if [ "$(($GHC_VERSION_DIG2 % 2))" -eq 1 ]
then
if [ "$GHC_VERSION_DIG4" == "" ]
then
FRAMEWORK_VERSION="$GHC_VERSION_DIG1.$GHC_VERSION_DIG2.$GHC_VERSION_DIG3-$GHC_ARCHITECTURE"
CURRENT_PROJECT_VERSION=`printf "%02d%02d00.%08d\n" "$GHC_VERSION_DIG1" "$GHC_VERSION_DIG2" "$GHC_VERSION_DIG3"`
else
die "Huh? 4 component HEAD version?"
fi
else
if [ "$GHC_VERSION_DIG4" == "" ]
then
FRAMEWORK_VERSION="$GHC_VERSION_DIG1.$GHC_VERSION_DIG2.$GHC_VERSION_DIG3-$GHC_ARCHITECTURE"
CURRENT_PROJECT_VERSION=`printf "%02d%02d%02d\n" "$GHC_VERSION_DIG1" "$GHC_VERSION_DIG2" "$GHC_VERSION_DIG3"`
else
FRAMEWORK_VERSION="$GHC_VERSION_DIG1.$GHC_VERSION_DIG2.$GHC_VERSION_DIG3.$GHC_VERSION_DIG4-$GHC_ARCHITECTURE"
CURRENT_PROJECT_VERSION=`printf "%02d%02d%02d.%08d\n" "$GHC_VERSION_DIG1" "$GHC_VERSION_DIG2" "$GHC_VERSION_DIG3" "$GHC_VERSION_DIG4"`
fi
fi
# The user-visible CFBundleShortVersionString
SHORT_VERSION_STRING="$FRAMEWORK_VERSION"
# Name of the installer package
PACKAGE_NAME="GHC-$FRAMEWORK_VERSION.pkg"
# Xcode's installation build product location (this is where the GHC.framework
# is assembled)
DSTROOT="/tmp/GHC.dst"
# Tools directory for a system volume install
TOOLS_SYSTEM="$DSTROOT/Library/Frameworks/GHC.framework/Versions/$FRAMEWORK_VERSION/Tools"
rm -rf "$DSTROOT"
mkdir -p "$TOOLS_SYSTEM"
sed "s/@FRAMEWORK_VERSION@/$FRAMEWORK_VERSION/" \
< installer-scripts/Uninstaller.in \
> installer-scripts/Uninstaller
sed "s/@FRAMEWORK_VERSION@/$FRAMEWORK_VERSION/" \
< installer-scripts/create-links.in \
> installer-scripts/create-links
sed "s/@FRAMEWORK_VERSION@/$FRAMEWORK_VERSION/" \
< GHC-system.pmdoc/index.xml.in \
> GHC-system.pmdoc/index.xml
cp installer-scripts/Uninstaller installer-scripts/create-links "$TOOLS_SYSTEM"
xcodebuild -target GHC-systemwide clean build install \
BINDIST="$BINDIST" \
GHC_UNPACKS_INTO="$GHC_UNPACKS_INTO" \
CURRENT_PROJECT_VERSION="$CURRENT_PROJECT_VERSION" \
SHORT_VERSION_STRING="$SHORT_VERSION_STRING" \
FRAMEWORK_VERSION="$FRAMEWORK_VERSION" \
CURRENT_LIBRARY_VERSION="$FRAMEWORK_VERSION" \
COMMAND_MODE=unix2003
rm -f GHC-system.pmdoc/*-contents.xml
/Developer/usr/bin/packagemaker \
-v --doc GHC-system.pmdoc \
-o $PACKAGE_NAME \
-i org.haskell.ghc."$FRAMEWORK_VERSION"
# Clean up
xcodebuild -target GHC-systemwide clean \
CURRENT_PROJECT_VERSION="$CURRENT_PROJECT_VERSION" \
SHORT_VERSION_STRING="$SHORT_VERSION_STRING" \
FRAMEWORK_VERSION="$FRAMEWORK_VERSION" \
CURRENT_LIBRARY_VERSION="$FRAMEWORK_VERSION" \
COMMAND_MODE=unix2003
rm -r "$GHC_UNPACKS_INTO"
rm -r "$DSTROOT"
rm installer-scripts/Uninstaller installer-scripts/create-links
rm GHC-system.pmdoc/index.xml
|