3
# The contents of this file are subject to the Netscape Public
4
# License Version 1.1 (the "License"); you may not use this file
5
# except in compliance with the License. You may obtain a copy of
6
# the License at http://www.mozilla.org/NPL/
8
# Software distributed under the License is distributed on an "AS
9
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
# implied. See the License for the specific language governing
11
# rights and limitations under the License.
13
# The Original Code is Mozilla Communicator client code, released
16
# The Initial Developer of the Original Code is Netscape
17
# Communications Corporation. Portions created by Netscape are
18
# Copyright (C) 1998-1999 Netscape Communications Corporation. All
22
# Sean Su <ssu@netscape.com>
26
# This perl script parses the input file for special variables
27
# in the format of $Variable$ and replace it with the appropriate
31
# - which is a .ini template
34
# - version to display on the blue background
36
# Path to staging area
37
# - path on where the seamonkey built bits are staged to
40
# - path on where xpi files will be located at
43
# - url to where the redirect.ini file will be staged at.
44
# Either ftp:// or http:// can be used
45
# ie: ftp://ftp.netscape.com/pub/seamonkey
48
# - url to where the .xpi files will be staged at.
49
# Either ftp:// or http:// can be used
50
# ie: ftp://ftp.netscape.com/pub/seamonkey/xpi
52
# ie: perl makecfgini.pl config.it 5.0.0.1999120608 k:\windows\32bit\5.0 d:\builds\mozilla\dist\win32_o.obj\install\xpi ftp://ftp.netscape.com/pub/seamonkey/windows/32bit/x86/1999-09-13-10-M10 ftp://ftp.netscape.com/pub/seamonkey/windows/32bit/x86/1999-09-13-10-M10/xpi
56
# Make sure there are at least two arguments
59
die "usage: $0 <.it file> <version> <staging path> <.xpi path> <redirect file url> <xpi url>
61
.it file : input ini template file
63
version : version to be shown in setup. Typically the same version
64
as show in mozilla.exe.
66
staging path : path to where the components are staged at
68
.xpi path : path to where the .xpi files have been built to
69
ie: d:/builds/mozilla/dist/win32_o.obj/install/xpi
71
redirect file : url to where the redirect.ini file will be staged at.
73
xpi url : url to where the .xpi files will be staged at.
74
Either ftp:// or http:// can be used
75
ie: ftp://ftp.netscape.com/pub/seamonkey/xpi
80
$inVersion = $ARGV[1];
81
$inStagePath = $ARGV[2];
82
$inXpiPath = $ARGV[3];
83
$inRedirIniUrl = $ARGV[4];
86
# get environment vars
87
$userAgent = $ENV{WIZ_userAgent};
88
$userAgentShort = $ENV{WIZ_userAgentShort};
89
$xpinstallVersion = $ENV{WIZ_xpinstallVersion};
90
$nameCompany = $ENV{WIZ_nameCompany};
91
$nameProduct = $ENV{WIZ_nameProduct};
92
$shortNameProduct = $ENV{WIZ_shortNameProduct};
93
$nameProductInternal = $ENV{WIZ_nameProductInternal};
94
$fileMainExe = $ENV{WIZ_fileMainExe};
95
$fileUninstall = $ENV{WIZ_fileUninstall};
96
$fileUninstallZip = $ENV{WIZ_fileUninstallZip};
97
$greBuildID = $ENV{WIZ_greBuildID};
98
$greFileVersion = $ENV{WIZ_greFileVersion};
99
$greUniqueID = $ENV{WIZ_greUniqueID};
106
($inDomain, $inServerPath) = ParseDomainAndPath($inUrl);
107
($inRedirDomain, $inRedirServerPath) = ParseDomainAndPath($inRedirIniUrl);
109
# Get the name of the file replacing the .it extension with a .ini extension
110
@inItFileSplit = split(/\./,$inItFile);
111
$outIniFile = $inItFileSplit[0];
112
$outIniFile .= ".ini";
114
# Open the input file
115
open(fpInIt, $inItFile) || die "\ncould not open $ARGV[0]: $!\n";
117
# Open the output file
118
open(fpOutIni, ">$outIniFile") || die "\nCould not open $outIniFile: $!\n";
120
print "\n Making $outIniFile...\n";
122
# While loop to read each line from input file
123
while($line = <fpInIt>)
125
# For each line read, search and replace $InstallSize$ with the calculated size
126
if($line =~ /\$InstallSize\$/i)
129
$installSizeSystem = 0;
131
# split read line by ":" deliminator
132
@colonSplit = split(/:/, $line);
133
if($#colonSplit >= 0)
135
$componentName = $colonSplit[1];
136
if (substr($componentName, -2, 2) eq "\r\n") {
137
$componentName = substr($componentName, 0, length($componentName) - 2) . "\n";
140
chop($componentName);
143
if($componentName =~ /\$UninstallFileZip\$/i)
145
$installSize = OutputInstallSizeArchive("$inXpiPath/$fileUninstallZip") * 2;
149
$installSize = OutputInstallSize("$inStagePath/$componentName");
151
# special oji consideration here. Since it's an installer that
152
# seamonkey installer will be calling, the disk space allocation
153
# needs to be adjusted by an expansion factor of 3.62.
154
if($componentName =~ /oji/i)
156
$installSize = int($installSize * 3.62);
159
if($componentName =~ /gre/i)
161
$installSize = int($installSize * 4.48);
166
# Read the next line to calculate for the "Install Size System="
169
if($line =~ /\$InstallSizeSystem\$/i)
171
$installSizeSystem = OutputInstallSizeSystem($line, "$inStagePath/$componentName");
175
$installSize -= $installSizeSystem;
176
print fpOutIni "Install Size=$installSize\n";
177
print fpOutIni "Install Size System=$installSizeSystem\n";
179
elsif($line =~ /\$InstallSizeArchive\$/i)
181
$installSizeArchive = 0;
183
# split read line by ":" deliminator
184
@colonSplit = split(/:/, $line);
185
if($#colonSplit >= 0)
187
$componentName = $colonSplit[1];
188
if (substr($componentName, -2, 2) eq "\r\n") {
189
$componentName = substr($componentName, 0, length($componentName) - 2) . "\n";
192
chop($componentName);
194
$componentName =~ s/\$UninstallFileZip\$/$fileUninstallZip/gi;
195
$installSizeArchive = OutputInstallSizeArchive("$inXpiPath/$componentName");
198
print fpOutIni "Install Size Archive=$installSizeArchive\n";
200
elsif($line =~ /\$FileCount\$/i)
202
if (!($componentName eq ""))
204
$stageDir = "$inStagePath/$componentName";
205
$stageDir =~ s/(.xpi|.zip)\b//i;
206
if (substr($stageDir, -1, 1) eq "\n") {
209
$fileCount = `find $stageDir -type f | wc -l`;
210
if (substr($fileCount, -1, 1) eq "\n") {
214
$line =~ s/\$FileCount\$/$fileCount/i;
216
print fpOutIni $line;
221
# For each line read, search and replace $Version$ with the version passed in
222
$line =~ s/\$Version\$/$inVersion/gi;
223
$line =~ s/\$Domain\$/$inDomain/gi;
224
$line =~ s/\$ServerPath\$/$inServerPath/gi;
225
$line =~ s/\$RedirIniUrl\$/$inRedirIniUrl/gi;
226
$line =~ s/\$ArchiveServerPath\$/$inServerPath/gi;
227
$line =~ s/\$ArchiveUrl\$/$inUrl/gi;
228
$line =~ s/\$RedirectServerPath\$/$inRedirServerPath/gi;
229
$line =~ s/\$RedirectUrl\$/$inRedirUrl/gi;
230
$line =~ s/\$UserAgent\$/$userAgent/gi;
231
$line =~ s/\$UserAgentShort\$/$userAgentShort/gi;
232
$line =~ s/\$XPInstallVersion\$/$xpinstallVersion/gi;
233
$line =~ s/\$CompanyName\$/$nameCompany/gi;
234
$line =~ s/\$ProductName\$/$nameProduct/gi;
235
$line =~ s/\$ProductNameInternal\$/$nameProductInternal/gi;
236
$line =~ s/\$ProductShortName\$/$shortNameProduct/gi;
237
$line =~ s/\$MainExeFile\$/$fileMainExe/gi;
238
$line =~ s/\$UninstallFile\$/$fileUninstall/gi;
239
$line =~ s/\$UninstallFileZip\$/$fileUninstallZip/gi;
240
$line =~ s/\$GreBuildID\$/$greBuildID/gi;
241
$line =~ s/\$GreFileVersion\$/$greFileVersion/gi;
242
$line =~ s/\$GreUniqueID\$/$greUniqueID/gi;
243
print fpOutIni $line;
252
sub ParseDomainAndPath()
255
my($aDomain, $aServerPath);
257
@slashSplit = split(/\//, $aUrl);
258
if($#slashSplit >= 0)
260
for($i = 0; $i <= $#slashSplit; $i++)
266
$aDomain = "$slashSplit[$i]";
270
$aDomain = "$aDomain/$slashSplit[$i]";
275
if($aServerPath eq "")
277
$aServerPath = "/$slashSplit[$i]";
281
$aServerPath = "$aServerPath/$slashSplit[$i]";
287
return($aDomain, $aServerPath);
290
sub OutputInstallSize()
295
print " calculating size for $inPath\n";
297
my ($inPathWin) = `cygpath -wa $inPath`;
299
$inPathWin =~ s/\\/\\\\/g;
300
$installSize = `$ENV{WIZ_distInstallPath}/ds32.exe /D /L0 /A /S /C 32768 $inPathWin`;
301
$installSize += 32768; # take into account install.js
302
$installSize = int($installSize / 1024);
304
return($installSize);
307
sub OutputInstallSizeArchive()
310
my($installSizeArchive);
311
my($dev, $ino, $mode, $nlink, $uid, $gui, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks);
313
print " calculating size for $inPath\n";
314
($dev, $ino, $mode, $nlink, $uid, $gui, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $inPath;
315
$installSizeArchive += 32768; # take into account install.js
316
$installSizeArchive = int($size / 1024);
317
$installSizeArchive += 1;
318
return($installSizeArchive);
321
sub OutputInstallSizeSystem()
323
my($inLine, $inPath) = @_;
324
my($installSizeSystem) = 0;
326
# split read line by ":" deliminator
327
@colonSplit = split(/:/, $inLine);
328
if($#colonSplit >= 0)
330
# split line by "," deliminator
331
@commaSplit = split(/\,/, $colonSplit[1]);
332
if($#commaSplit >= 0)
336
# calculate the size of component installed using ds32.exe in Kbytes
337
print " calculating size for $inPath/$_";
338
$installSizeSystem += `$ENV{WIZ_distInstallPath}/ds32.exe /D /L0 /A /S /C 32768 $inPath/$_`;
343
$installSizeSystem = int($installSizeSystem / 1024);
344
$installSizeSystem += 1;
345
return($installSizeSystem);
348
sub ParseUserAgentShort()
350
my($aUserAgent) = @_;
351
my($aUserAgentShort);
353
@spaceSplit = split(/ /, $aUserAgent);
354
if($#spaceSplit >= 0)
356
$aUserAgentShort = $spaceSplit[0];
359
return($aUserAgentShort);