summaryrefslogtreecommitdiff
path: root/tools/make-package-macosx
blob: ebdf0eba2c9828b5b0e54576a080d6d80709ec62 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/sh

#########################################################################
#                                                                       #
#                            Objective Caml                             #
#                                                                       #
#          Damien Doligez, projet Moscova, INRIA Rocquencourt           #
#                                                                       #
#   Copyright 2003 Institut National de Recherche en Informatique et    #
#   en Automatique.  All rights reserved.  This file is distributed     #
#   under the terms of the Q Public License version 1.0.                #
#                                                                       #
#########################################################################

# $Id$

cd package-macosx
rm -rf ocaml.pkg ocaml-rw.dmg

VERSION=`sed -e 1q ../VERSION`
VERSION_MAJOR=`sed -n -e '1s/^\([0-9]*\)\..*/\1/p' ../VERSION`
VERSION_MINOR=`sed -n -e '1s/^[0-9]*\.\([0-9]*\)[.+].*/\1/p' ../VERSION`

cat >Description.plist <<EOF
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
            "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
  <dict>
          <key>IFPkgDescriptionDeleteWarning</key>
          <string></string>
          <key>IFPkgDescriptionDescription</key>
          <string>The Objective Caml compiler and tools</string>
          <key>IFPkgDescriptionTitle</key>
          <string>Objective Caml</string>
          <key>IFPkgDescriptionVersion</key>
          <string>${VERSION}</string>
  </dict>
  </plist>
EOF

cat >Info.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
          "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>CFBundleGetInfoString</key>
        <string>Objective Caml ${VERSION}</string>
        <key>CFBundleIdentifier</key>
        <string>fr.inria.ocaml</string>
        <key>CFBundleName</key>
        <string>Objective Caml</string>
        <key>CFBundleShortVersionString</key>
        <string>${VERSION}</string>
        <key>IFMajorVersion</key>
        <integer>${VERSION_MAJOR}</integer>
        <key>IFMinorVersion</key>
        <integer>${VERSION_MINOR}</integer>
        <key>IFPkgFlagAllowBackRev</key>
        <true/>
        <key>IFPkgFlagAuthorizationAction</key>
        <string>AdminAuthorization</string>
        <key>IFPkgFlagDefaultLocation</key>
        <string>/usr/local</string>
        <key>IFPkgFlagInstallFat</key>
        <false/>
        <key>IFPkgFlagIsRequired</key>
        <false/>
        <key>IFPkgFlagRelocatable</key>
        <false/>
        <key>IFPkgFlagRestartAction</key>
        <string>NoRestart</string>
        <key>IFPkgFlagRootVolumeOnly</key>
        <true/>
        <key>IFPkgFlagUpdateInstalledLanguages</key>
        <false/>
        <key>IFPkgFormatVersion</key>
        <real>0.10000000149011612</real>
</dict>
</plist>
EOF

mkdir -p resources

#                                         stop here -> |
cat >resources/ReadMe.txt <<EOF
This package installs Objective Caml version ${VERSION}.
You need Mac OS X 10.5.x (Leopard), with the
XCode tools installed (v3.1.1 or later), and
optionally X11.

Files will be installed in the following directories:

/usr/local/bin - command-line executables
/usr/local/lib/ocaml - library and support files
/usr/local/man - manual pages
EOF

chmod -R g-w root
sudo chown -R root:wheel root

/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker \
  -build -p "`pwd`/ocaml.pkg" -f "`pwd`/root" -i "`pwd`/Info.plist" \
  -d "`pwd`/Description.plist" -r "`pwd`/resources"

size=`du -s ocaml.pkg | cut -f 1`
size=`expr $size + 8192`

hdiutil create -sectors $size ocaml-rw.dmg
name=`hdid -nomount ocaml-rw.dmg | grep Apple_HFS | cut -d ' ' -f 1`
volname="Objective Caml ${VERSION}"
newfs_hfs -v "$volname" $name
hdiutil detach $name

name=`hdid ocaml-rw.dmg | grep Apple_HFS | cut -d ' ' -f 1`
if test -d "/Volumes/$volname"; then
  ditto -rsrcFork ocaml.pkg "/Volumes/$volname/ocaml.pkg"
  cp resources/ReadMe.txt "/Volumes/$volname/"
else
  echo "Unable to mount the disk image as \"/Volumes/$volname\"" >&2
  exit 3
fi
open "/Volumes/$volname"
sleep 2
hdiutil detach $name

rm -rf "ocaml-${VERSION}.dmg"
hdiutil convert ocaml-rw.dmg -format UDZO -o "ocaml-${VERSION}.dmg"