~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/build/package/mac_osx/make-diskimage

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# ***** BEGIN LICENSE BLOCK *****
 
3
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
4
#
 
5
# The contents of this file are subject to the Mozilla Public License Version
 
6
# 1.1 (the "License"); you may not use this file except in compliance with
 
7
# the License. You may obtain a copy of the License at
 
8
# http://www.mozilla.org/MPL/
 
9
#
 
10
# Software distributed under the License is distributed on an "AS IS" basis,
 
11
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
12
# for the specific language governing rights and limitations under the
 
13
# License.
 
14
#
 
15
# The Original Code is the make-diskimage script.
 
16
#
 
17
# The Initial Developer of the Original Code is
 
18
# Netscape Communications Corporation.
 
19
# Portions created by the Initial Developer are Copyright (C) 2002
 
20
# the Initial Developer. All Rights Reserved.
 
21
#
 
22
# Contributor(s):
 
23
#  Brian Ryner <bryner@brianryner.com>
 
24
#  Jean-Jacques Enser <jj@netscape.com>
 
25
#
 
26
# Alternatively, the contents of this file may be used under the terms of
 
27
# either the GNU General Public License Version 2 or later (the "GPL"), or
 
28
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
29
# in which case the provisions of the GPL or the LGPL are applicable instead
 
30
# of those above. If you wish to allow use of your version of this file only
 
31
# under the terms of either the GPL or the LGPL, and not to allow others to
 
32
# use your version of this file under the terms of the MPL, indicate your
 
33
# decision by deleting the provisions above and replace them with the notice
 
34
# and other provisions required by the GPL or the LGPL. If you do not delete
 
35
# the provisions above, a recipient may use your version of this file under
 
36
# the terms of any one of the MPL, the GPL or the LGPL.
 
37
#
 
38
# ***** END LICENSE BLOCK *****
 
39
 
 
40
# Create a read-only disk image of the contents of a folder
 
41
#
 
42
# Usage: make-diskimage <image_file>
 
43
#                       <src_folder>
 
44
#                       <volume_name>
 
45
#                       <eula_resource_file>
 
46
#                       <.dsstore_file>
 
47
#                       <background_image_file>
 
48
#
 
49
# tip: use '-null-' for <eula-resource-file> if you only want to
 
50
# provide <.dsstore_file> and <background_image_file>
 
51
 
 
52
DMG_DIRNAME=`dirname $1`
 
53
DMG_DIR=`cd $DMG_DIRNAME; pwd`
 
54
DMG_NAME=`basename $1`
 
55
DMG_TEMP_NAME=${DMG_DIR}/rw.${DMG_NAME}
 
56
SRC_FOLDER=`cd $2; pwd`
 
57
VOLUME_NAME=$3
 
58
 
 
59
# optional arguments
 
60
EULA_RSRC=$4
 
61
DMG_DSSTORE=$5
 
62
DMG_BKGND_IMG=$6
 
63
 
 
64
# Find the size of the folder contents
 
65
FOLDER_SIZE=`du -s $SRC_FOLDER | sed s/[^0-9].*//`
 
66
 
 
67
# Allow for partition table and other overhead (3%)
 
68
IMAGE_SIZE=$(($FOLDER_SIZE * 103/100))
 
69
# minimum size for an HFS+ partition is 4Mb
 
70
[ $IMAGE_SIZE -lt 8300 ] && IMAGE_SIZE=8300
 
71
 
 
72
# Make sure NEXT_ROOT is not set (if we're building with an SDK)
 
73
unset NEXT_ROOT
 
74
 
 
75
echo FOLDER_SIZE=$FOLDER_SIZE
 
76
echo IMAGE_SIZE=$IMAGE_SIZE
 
77
 
 
78
# Create the image
 
79
echo "creating disk image"
 
80
hdiutil create -sectors $IMAGE_SIZE -fs HFS+ $DMG_TEMP_NAME -volname $VOLUME_NAME
 
81
 
 
82
# mount it
 
83
echo "mounting disk image"
 
84
# `hdid -nomount rw.$DMG_NAME | grep "^/dev/disk.s2" | sed -e "s?^/dev/??" -e "s/[^0-9a-z].*//"`
 
85
DEV_NAME=`hdid $DMG_TEMP_NAME | sed 1q | awk '{print $1}'`
 
86
MOUNT_DIR=`hdid $DMG_TEMP_NAME | grep Apple_HFS | awk '{print $3}'`
 
87
 
 
88
# copy content
 
89
echo "copying content to disk image"
 
90
ditto -rsrcFork $SRC_FOLDER $MOUNT_DIR
 
91
# add optional Finder window layout and background image
 
92
if [ ! -z ${DMG_DSSTORE} ]; then
 
93
        echo "adding .DS_Store"
 
94
        cp -p ${DMG_DSSTORE} ${MOUNT_DIR}/.DS_Store
 
95
fi
 
96
if [ ! -z ${DMG_BKGND_IMG} ]; then
 
97
        echo "adding background image"
 
98
        mkdir ${MOUNT_DIR}/.background
 
99
        cp -p ${DMG_BKGND_IMG} ${MOUNT_DIR}/.background/
 
100
fi
 
101
 
 
102
# make sure it's not world writeable
 
103
echo "fixing permissions"
 
104
chmod -R go-w ${MOUNT_DIR}
 
105
 
 
106
# make the top window open itself on mount:
 
107
if [ -x /usr/local/bin/openUp ]; then
 
108
    /usr/local/bin/openUp ${MOUNT_DIR}
 
109
fi
 
110
 
 
111
# unmnount
 
112
echo "unmounting disk image"
 
113
hdiutil detach $DEV_NAME
 
114
 
 
115
# convert to read-only image
 
116
echo "converting disk image to read-only"
 
117
hdiutil convert $DMG_TEMP_NAME -format UDRO -o ${DMG_DIR}/${DMG_NAME}
 
118
rm -f $DMG_TEMP_NAME
 
119
 
 
120
# adding EULA resources
 
121
if [ ! -z "${EULA_RSRC}" -a "${EULA_RSRC}" != "-null-" ]; then
 
122
        echo "adding EULA resources"
 
123
        hdiutil unflatten ${DMG_DIR}/${DMG_NAME}
 
124
        /Developer/Tools/ResMerger -a ${EULA_RSRC} -o ${DMG_DIR}/${DMG_NAME}
 
125
        hdiutil flatten ${DMG_DIR}/${DMG_NAME}
 
126
fi
 
127
 
 
128
echo "disk image done"