]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/distrib/mac/makepkg
call wxApp::OnExit() when wxExit() is called and don't do wxLogError from it (replace...
[wxWidgets.git] / wxPython / distrib / mac / makepkg
... / ...
CommitLineData
1#! /bin/csh -ef
2#
3# original script by Chris Roberts (The OS X Package Manager)
4# slightly modified by Frank Vercruesse (mainly fixed quoting issues)
5
6set prog = `/usr/bin/basename $0`
7set usage = "Usage: $prog [-f] root-dir info-file [tiff-file] [-d dest-dir] [-r resource-dir] [-traditional | -gnutar]"
8set noglob
9
10if (-x /usr/bin/mkbom) then
11 set mkbom=/usr/bin/mkbom
12 set lsbom=/usr/bin/lsbom
13else
14 set mkbom=/usr/etc/mkbom
15 set lsbom=/usr/etc/lsbom
16endif
17
18if (-x /usr/bin/awk) then
19 set awk=/usr/bin/awk
20else
21 set awk=/bin/awk
22endif
23
24set gnutar=/usr/bin/gnutar
25set tar=/usr/bin/tar
26set pax=/bin/pax
27
28# gather parameters
29if ($#argv == 0) then
30 echo $usage
31 exit(1)
32endif
33
34while ( $#argv > 0 )
35 switch ( "$argv[1]" )
36 case -d:
37 if ( $?destDir ) then
38 echo ${prog}: dest-dir parameter already set to ${destDir}.
39 echo $usage
40 exit(1)
41 else if ( $#argv < 2 ) then
42 echo ${prog}: -d option requires destination directory.
43 echo $usage
44 exit(1)
45 else
46 set destDir = "$argv[2]"
47 shift; shift
48 breaksw
49 endif
50 case -f:
51 if ( $?rootDir ) then
52 echo ${prog}: root-dir parameter already set to ${rootDir}.
53 echo $usage
54 exit(1)
55 else if ( $#argv < 2 ) then
56 echo ${prog}: -f option requires package root directory.
57 echo $usage
58 exit(1)
59 else
60 set rootDir = "$argv[2]"
61 set fflag
62 shift; shift
63 breaksw
64 endif
65 case -r:
66 if ( $?resDir ) then
67 echo ${prog}: resource-dir parameter already set to ${resDir}.
68 echo $usage
69 exit(1)
70 else if ( $#argv < 2 ) then
71 echo ${prog}: -r option requires package resource directory.
72 echo $usage
73 exit(1)
74 else
75 set resDir = "$argv[2]"
76 shift; shift
77 breaksw
78 endif
79 case -traditional:
80 set usetar
81 unset usegnutar
82 unset usepax
83 shift
84 breaksw
85 case -gnutar:
86 set usegnutar
87 unset usepax
88 unset usetar
89 shift
90 breaksw
91 case -B:
92 # We got long file names, better use bigtar instead
93 #set archiver = /NextAdmin/Installer.app/Resources/installer_bigtar
94 #echo 2>&1 ${prog}: -B flag is longer relevant.
95 shift
96 breaksw
97 case -*:
98 echo ${prog}: Unknown option: $argv[1]
99 echo $usage
100 exit(1)
101 case *.info:
102 if ( $?info ) then
103 echo ${prog}: info-file parameter already set to ${info}.
104 echo $usage
105 exit(1)
106 else
107 set info = "$argv[1]"
108 shift
109 breaksw
110 endif
111 case *.tiff:
112 if ( $?tiff ) then
113 echo ${prog}: tiff-file parameter already set to ${tiff}.
114 echo $usage
115 exit(1)
116 else
117 set tiff = "$argv[1]"
118 shift
119 breaksw
120 endif
121 default:
122 if ( $?rootDir ) then
123 echo ${prog}: unrecognized parameter: $argv[1]
124 echo $usage
125 exit(1)
126 else
127 set rootDir = "$argv[1]"
128 shift
129 breaksw
130 endif
131 endsw
132end
133
134# check for mandatory parameters
135if ( ! $?rootDir ) then
136 echo ${prog}: missing root-dir parameter.
137 echo $usage
138 exit(1)
139else if ( ! $?info) then
140 echo ${prog}: missing info-file parameter.
141 echo $usage
142 exit(1)
143endif
144
145# destDir gets default value if unset on command line
146if ( $?destDir ) then
147 /bin/mkdir -p "$destDir"
148else
149 set destDir = .
150endif
151
152# derive the root name for the package from the root name of the info file
153set root = `/usr/bin/basename $info .info`
154
155# create package directory
156set pkg = "${destDir}/${root}.pkg"
157echo Generating Installer package $pkg ...
158if ( -e "$pkg" ) /bin/rm -rf "$pkg"
159/bin/mkdir -p -m 755 "$pkg"
160/bin/mkdir -p -m 755 "$pkg/Contents"
161/bin/mkdir -p -m 755 "$pkg/Contents/Resources"
162/bin/mkdir -p -m 755 "$pkg/Contents/Resources/English.lproj/"
163echo -n "pmkrpkg1" >"$pkg/Contents/PkgInfo"
164chmod 755 "$pkg/Contents/PkgInfo"
165# (gnu)tar/pax and compress root directory to package archive
166echo -n " creating package archive ... "
167if ( $?fflag ) then
168 set pkgTop = "${rootDir:t}"
169 set parent = "${rootDir:h}"
170 if ( "$parent" == "$pkgTop" ) set parent = "."
171else
172 set parent = "$rootDir"
173 set pkgTop = .
174endif
175if ( $?usetar ) then
176 set pkgArchive = "$pkg/Contents/Resources/$root.tar.Z"
177 (cd "$parent"; $tar -w "$pkgTop") | /usr/bin/tar -f -c > "$pkgArchive"
178else if ( $?usegnutar ) then
179 set pkgArchive = "$pkg/Contents/Resources/$root.tar.gz"
180 (cd "$parent"; $gnutar zcf "$pkgArchive" "$pkgTop")
181else
182 set pkgArchive = "$pkg/Contents/Resources/$root.pax.gz"
183 (cd "$parent"; $pax -w -z -x cpio "$pkgTop") > "$pkgArchive"
184endif
185/bin/chmod 755 "$pkgArchive"
186echo done.
187
188# copy info file to package
189set pkgInfo = "$pkg/Contents/Resources/English.lproj/$root.info"
190echo -n " copying ${info:t} ... "
191/bin/cp $info "$pkgInfo"
192/bin/chmod 755 "$pkgInfo"
193echo done.
194
195# copy tiff file to package
196if ( $?tiff ) then
197 set pkgTiff = "$pkg/$root.tiff"
198 echo -n " copying ${tiff:t} ... "
199 /bin/cp $tiff "$pkgTiff"
200 /bin/chmod 444 "$pkgTiff"
201 echo done.
202endif
203
204# copy resources to package
205if ( $?resDir ) then
206 echo -n " copying ${resDir:t} ... "
207
208 # don't want to see push/pop output
209 pushd "$resDir" > /dev/null
210 # get lists of resources. We'll want to change
211 # permissions on just these things later.
212 set directoriesInResDir = `find . -type d`
213 set filesInResDir = `find . -type f`
214 popd > /dev/null
215
216 # copy the resource directory contents into the package directory
217 foreach resFile (`ls "$resDir"`)
218 cp -r "$resDir/$resFile" "$pkg/Contents/Resources"
219 end
220
221 pushd "$pkg/Contents/Resources" > /dev/null
222 # Change all directories to +r+x, except the package
223 # directory itself
224 foreach resFileItem ($directoriesInResDir)
225 if ( "$resFileItem" != "." ) then
226 chmod 755 $resFileItem
227 endif
228 end
229 # change all flat files to read only
230 foreach resFileItem ($filesInResDir)
231 if ( "$resFileItem" != "./.DS_Store" ) then
232 chmod 755 $resFileItem
233 endif
234 end
235 popd > /dev/null
236
237 echo done.
238endif
239
240# generate bom file
241set pkgBom = "$pkg/Contents/Resources/$root.bom"
242echo -n " generating bom file ... "
243/bin/rm -f "$pkgBom"
244if ( $?fflag ) then
245 $mkbom "$parent" "$pkgBom" >& /dev/null
246else
247 $mkbom "$rootDir" "$pkgBom" >& /dev/null
248endif
249/bin/chmod 444 "$pkgArchive"
250echo done.
251
252# generate sizes file
253set pkgSizes = "$pkg/Contents/Resources/$root.sizes"
254echo -n " generating sizes file ... "
255
256# compute number of files in package
257set numFiles = `$lsbom -s "$pkgBom" | /usr/bin/wc -l`
258
259# compute package size when compressed
260@ compressedSize = `/usr/bin/du -k -s "$pkg" | $awk '{print $1}'`
261@ compressedSize += 3 # add 1KB each for sizes, location, status files
262
263@ infoSize = `/bin/ls -s "$pkgInfo" | $awk '{print $1}'`
264@ bomSize = `/bin/ls -s "$pkgBom" | $awk '{print $1}'`
265if ( $?tiff ) then
266 @ tiffSize = `/bin/ls -s "$pkgTiff" | $awk '{print $1}'`
267else
268 @ tiffSize = 0
269endif
270
271@ installedSize = `/usr/bin/du -k -s "$rootDir" | $awk '{print $1}'`
272@ installedSize += $infoSize + $bomSize + $tiffSize + 3
273
274# echo size parameters to sizes file
275echo NumFiles $numFiles > "$pkgSizes"
276echo InstalledSize $installedSize >> "$pkgSizes"
277echo CompressedSize $compressedSize >> "$pkgSizes"
278echo done.
279echo " ... finished generating $pkg."
280
281exit(0)
282
283# end package