#!/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: make-package-macosx,v 1.4 2003/03/27 16:28:12 doligez Exp $

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

cat >ocaml.info <<EOF
  Title Objective Caml
  Version 3.06
  Description This package installs Objective Caml version 3.06
  DefaultLocation /
  Relocatable no
  NeedsAuthorization yes
  Application no
  InstallOnly no
  DisableStop no
EOF

package root ocaml.info

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`
newfs_hfs -v 'Objective Caml' $name
hdiutil detach $name

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

hdiutil convert ocaml-rw.dmg -format UDZO -o ocaml.dmg
