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
$nameProductInternal = $ENV{WIZ_nameProductInternal};
93
$fileMainExe = $ENV{WIZ_fileMainExe};
94
$fileUninstall = $ENV{WIZ_fileUninstall};
95
$fileUninstallZip = $ENV{WIZ_fileUninstallZip};
96
$greBuildID = $ENV{WIZ_greBuildID};
97
$greFileVersion = $ENV{WIZ_greFileVersion};
98
$greUniqueID = $ENV{WIZ_greUniqueID};
105
($inDomain, $inServerPath) = ParseDomainAndPath($inUrl);
106
($inRedirDomain, $inRedirServerPath) = ParseDomainAndPath($inRedirIniUrl);
108
# Get the name of the file replacing the .it extension with a .ini extension
109
@inItFileSplit = split(/\./,$inItFile);
110
$outIniFile = $inItFileSplit[0];
111
$outIniFile .= ".ini";
113
# Open the input file
114
open(fpInIt, $inItFile) || die "\ncould not open $ARGV[0]: $!\n";
116
# Open the output file
117
open(fpOutIni, ">$outIniFile") || die "\nCould not open $outIniFile: $!\n";
119
print "\n Making $outIniFile...\n";
121
# While loop to read each line from input file
122
while($line = <fpInIt>)
124
# For each line read, search and replace $InstallSize$ with the calculated size
125
if($line =~ /\$InstallSize\$/i)
128
$installSizeSystem = 0;
130
# split read line by ":" deliminator
131
@colonSplit = split(/:/, $line);
132
if($#colonSplit >= 0)
134
$componentName = $colonSplit[1];
135
chop($componentName);
137
if($componentName =~ /\$UninstallFileZip\$/i)
139
$installSize = OutputInstallSizeArchive("$inXpiPath/$fileUninstallZip") * 2;
143
$installSize = OutputInstallSize("$inStagePath/$componentName");
145
# special oji consideration here. Since it's an installer that
146
# seamonkey installer will be calling, the disk space allocation
147
# needs to be adjusted by an expansion factor of 3.62.
148
if($componentName =~ /oji/i)
150
$installSize = int($installSize * 3.62);
155
# Read the next line to calculate for the "Install Size System="
158
if($line =~ /\$InstallSizeSystem\$/i)
160
$installSizeSystem = OutputInstallSizeSystem($line, "$inStagePath/$componentName");
164
$installSize -= $installSizeSystem;
165
print fpOutIni "Install Size=$installSize\n";
166
print fpOutIni "Install Size System=$installSizeSystem\n";
168
elsif($line =~ /\$InstallSizeArchive\$/i)
170
$installSizeArchive = 0;
172
# split read line by ":" deliminator
173
@colonSplit = split(/:/, $line);
174
if($#colonSplit >= 0)
176
$componentName = $colonSplit[1];
177
chop($componentName);
178
$componentName =~ s/\$UninstallFileZip\$/$fileUninstallZip/gi;
179
$installSizeArchive = OutputInstallSizeArchive("$inXpiPath/$componentName");
182
print fpOutIni "Install Size Archive=$installSizeArchive\n";
186
# For each line read, search and replace $Version$ with the version passed in
187
$line =~ s/\$Version\$/$inVersion/gi;
188
$line =~ s/\$Domain\$/$inDomain/gi;
189
$line =~ s/\$ServerPath\$/$inServerPath/gi;
190
$line =~ s/\$RedirIniUrl\$/$inRedirIniUrl/gi;
191
$line =~ s/\$ArchiveServerPath\$/$inServerPath/gi;
192
$line =~ s/\$ArchiveUrl\$/$inUrl/gi;
193
$line =~ s/\$RedirectServerPath\$/$inRedirServerPath/gi;
194
$line =~ s/\$RedirectUrl\$/$inRedirUrl/gi;
195
$line =~ s/\$UserAgent\$/$userAgent/gi;
196
$line =~ s/\$UserAgentShort\$/$userAgentShort/gi;
197
$line =~ s/\$XPInstallVersion\$/$xpinstallVersion/gi;
198
$line =~ s/\$CompanyName\$/$nameCompany/gi;
199
$line =~ s/\$ProductName\$/$nameProduct/gi;
200
$line =~ s/\$ProductNameInternal\$/$nameProductInternal/gi;
201
$line =~ s/\$MainExeFile\$/$fileMainExe/gi;
202
$line =~ s/\$UninstallFile\$/$fileUninstall/gi;
203
$line =~ s/\$UninstallFileZip\$/$fileUninstallZip/gi;
204
$line =~ s/\$GreBuildID\$/$greBuildID/gi;
205
$line =~ s/\$GreFileVersion\$/$greFileVersion/gi;
206
$line =~ s/\$GreUniqueID\$/$greUniqueID/gi;
207
print fpOutIni $line;
216
sub ParseDomainAndPath()
219
my($aDomain, $aServerPath);
221
@slashSplit = split(/\//, $aUrl);
222
if($#slashSplit >= 0)
224
for($i = 0; $i <= $#slashSplit; $i++)
230
$aDomain = "$slashSplit[$i]";
234
$aDomain = "$aDomain/$slashSplit[$i]";
239
if($aServerPath eq "")
241
$aServerPath = "/$slashSplit[$i]";
245
$aServerPath = "$aServerPath/$slashSplit[$i]";
251
return($aDomain, $aServerPath);
254
sub OutputInstallSize()
259
print " calculating size for $inPath\n";
260
$installSize = `$ENV{WIZ_distInstallPath}/../install/ds32.exe /D /L0 /A /S /C 32768 $inPath`;
261
$installSize += 32768; # take into account install.js
262
$installSize = int($installSize / 1024);
264
return($installSize);
267
sub OutputInstallSizeArchive()
270
my($installSizeArchive);
271
my($dev, $ino, $mode, $nlink, $uid, $gui, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks);
273
print " calculating size for $inPath\n";
274
($dev, $ino, $mode, $nlink, $uid, $gui, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $inPath;
275
$installSizeArchive += 32768; # take into account install.js
276
$installSizeArchive = int($size / 1024);
277
$installSizeArchive += 1;
278
return($installSizeArchive);
281
sub OutputInstallSizeSystem()
283
my($inLine, $inPath) = @_;
284
my($installSizeSystem) = 0;
286
# split read line by ":" deliminator
287
@colonSplit = split(/:/, $inLine);
288
if($#colonSplit >= 0)
290
# split line by "," deliminator
291
@commaSplit = split(/\,/, $colonSplit[1]);
292
if($#commaSplit >= 0)
296
# calculate the size of component installed using ds32.exe in Kbytes
297
print " calculating size for $inPath/$_";
298
$installSizeSystem += `$ENV{WIZ_distInstallPath}/../install/ds32.exe /D /L0 /A /S /C 32768 $inPath/$_`;
303
$installSizeSystem = int($installSizeSystem / 1024);
304
$installSizeSystem += 1;
305
return($installSizeSystem);
308
sub ParseUserAgentShort()
310
my($aUserAgent) = @_;
311
my($aUserAgentShort);
313
@spaceSplit = split(/ /, $aUserAgent);
314
if($#spaceSplit >= 0)
316
$aUserAgentShort = $spaceSplit[0];
319
return($aUserAgentShort);