10 if ! [ -d installer-scripts ]
12 die "Doesn't look like you are running this script from the right location"
17 die "Must be given on argument (the bindist)"
22 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/'`
23 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/'`
24 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/'`
25 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/'`
26 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/'`
27 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/'`
29 if [ "$GHC_ARCHITECTURE" == "$BINDIST" ]
31 die "Bindist filename not in expected format"
34 if [ "$(($GHC_VERSION_DIG2 % 2))" -eq 1 ]
36 if [ "$GHC_VERSION_DIG4" == "" ]
38 FRAMEWORK_VERSION="$GHC_VERSION_DIG1.$GHC_VERSION_DIG2.$GHC_VERSION_DIG3-$GHC_ARCHITECTURE"
39 CURRENT_PROJECT_VERSION=`printf "%02d%02d00.%08d\n" "$GHC_VERSION_DIG1" "$GHC_VERSION_DIG2" "$GHC_VERSION_DIG3"`
41 die "Huh? 4 component HEAD version?"
44 if [ "$GHC_VERSION_DIG4" == "" ]
46 FRAMEWORK_VERSION="$GHC_VERSION_DIG1.$GHC_VERSION_DIG2.$GHC_VERSION_DIG3-$GHC_ARCHITECTURE"
47 CURRENT_PROJECT_VERSION=`printf "%02d%02d%02d\n" "$GHC_VERSION_DIG1" "$GHC_VERSION_DIG2" "$GHC_VERSION_DIG3"`
49 FRAMEWORK_VERSION="$GHC_VERSION_DIG1.$GHC_VERSION_DIG2.$GHC_VERSION_DIG3.$GHC_VERSION_DIG4-$GHC_ARCHITECTURE"
50 CURRENT_PROJECT_VERSION=`printf "%02d%02d%02d.%08d\n" "$GHC_VERSION_DIG1" "$GHC_VERSION_DIG2" "$GHC_VERSION_DIG3" "$GHC_VERSION_DIG4"`
54 # The user-visible CFBundleShortVersionString
55 SHORT_VERSION_STRING="$FRAMEWORK_VERSION"
57 # Name of the installer package
58 PACKAGE_NAME="GHC-$FRAMEWORK_VERSION.pkg"
60 # Xcode's installation build product location (this is where the GHC.framework
62 DSTROOT="/tmp/GHC.dst"
64 # Tools directory for a system volume install
65 TOOLS_SYSTEM="$DSTROOT/Library/Frameworks/GHC.framework/Versions/$FRAMEWORK_VERSION/Tools"
68 mkdir -p "$TOOLS_SYSTEM"
69 sed "s/@FRAMEWORK_VERSION@/$FRAMEWORK_VERSION/" \
70 < installer-scripts/Uninstaller.in \
71 > installer-scripts/Uninstaller
72 sed "s/@FRAMEWORK_VERSION@/$FRAMEWORK_VERSION/" \
73 < installer-scripts/create-links.in \
74 > installer-scripts/create-links
75 sed "s/@FRAMEWORK_VERSION@/$FRAMEWORK_VERSION/" \
76 < GHC-system.pmdoc/index.xml.in \
77 > GHC-system.pmdoc/index.xml
78 cp installer-scripts/Uninstaller installer-scripts/create-links "$TOOLS_SYSTEM"
79 xcodebuild -target GHC-systemwide clean build install \
81 GHC_UNPACKS_INTO="$GHC_UNPACKS_INTO" \
82 CURRENT_PROJECT_VERSION="$CURRENT_PROJECT_VERSION" \
83 SHORT_VERSION_STRING="$SHORT_VERSION_STRING" \
84 FRAMEWORK_VERSION="$FRAMEWORK_VERSION" \
85 CURRENT_LIBRARY_VERSION="$FRAMEWORK_VERSION" \
87 rm -f GHC-system.pmdoc/*-contents.xml
89 /Developer/usr/bin/packagemaker \
90 -v --doc GHC-system.pmdoc \
92 -i org.haskell.ghc."$FRAMEWORK_VERSION"
95 xcodebuild -target GHC-systemwide clean \
96 CURRENT_PROJECT_VERSION="$CURRENT_PROJECT_VERSION" \
97 SHORT_VERSION_STRING="$SHORT_VERSION_STRING" \
98 FRAMEWORK_VERSION="$FRAMEWORK_VERSION" \
99 CURRENT_LIBRARY_VERSION="$FRAMEWORK_VERSION" \
100 COMMAND_MODE=unix2003
101 rm -r "$GHC_UNPACKS_INTO"
103 rm installer-scripts/Uninstaller installer-scripts/create-links
104 rm GHC-system.pmdoc/index.xml