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

« back to all changes in this revision

Viewing changes to mozilla/toolkit/mozapps/installer/makecfgini.pl

  • 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
#!c:\perl\bin\perl
 
2
 
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/
 
7
#  
 
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.
 
12
#  
 
13
# The Original Code is Mozilla Communicator client code, released
 
14
# March 31, 1998.
 
15
 
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
 
19
# Rights Reserved.
 
20
 
21
# Contributor(s): 
 
22
# Sean Su <ssu@netscape.com>
 
23
 
24
 
 
25
#
 
26
# This perl script parses the input file for special variables
 
27
# in the format of $Variable$ and replace it with the appropriate
 
28
# value(s).
 
29
#
 
30
# Input: .it file
 
31
#             - which is a .ini template
 
32
#
 
33
#        version
 
34
#             - version to display on the blue background
 
35
#
 
36
#        Path to staging area
 
37
#             - path on where the seamonkey built bits are staged to
 
38
#
 
39
#        xpi path
 
40
#             - path on where xpi files will be located at
 
41
#
 
42
#        redirect file url
 
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
 
46
#
 
47
#        xpi url
 
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
 
51
#
 
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
 
53
#
 
54
#
 
55
 
 
56
# Make sure there are at least two arguments
 
57
if($#ARGV < 5)
 
58
{
 
59
  die "usage: $0 <.it file> <version> <staging path> <.xpi path> <redirect file url> <xpi url>
 
60
 
 
61
       .it file      : input ini template file
 
62
 
 
63
       version       : version to be shown in setup.  Typically the same version
 
64
                       as show in mozilla.exe.
 
65
 
 
66
       staging path  : path to where the components are staged at
 
67
 
 
68
       .xpi path     : path to where the .xpi files have been built to
 
69
                       ie: d:/builds/mozilla/dist/win32_o.obj/install/xpi
 
70
 
 
71
       redirect file : url to where the redirect.ini file will be staged at.
 
72
 
 
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
 
76
       \n";
 
77
}
 
78
 
 
79
$inItFile         = $ARGV[0];
 
80
$inVersion        = $ARGV[1];
 
81
$inStagePath      = $ARGV[2];
 
82
$inXpiPath        = $ARGV[3];
 
83
$inRedirIniUrl    = $ARGV[4];
 
84
$inUrl            = $ARGV[5];
 
85
 
 
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};
 
100
 
 
101
$inDomain;
 
102
$inRedirDomain;
 
103
$inServerPath;
 
104
$inRedirServerPath;
 
105
 
 
106
($inDomain,      $inServerPath)      = ParseDomainAndPath($inUrl);
 
107
($inRedirDomain, $inRedirServerPath) = ParseDomainAndPath($inRedirIniUrl);
 
108
 
 
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";
 
113
 
 
114
# Open the input file
 
115
open(fpInIt, $inItFile) || die "\ncould not open $ARGV[0]: $!\n";
 
116
 
 
117
# Open the output file
 
118
open(fpOutIni, ">$outIniFile") || die "\nCould not open $outIniFile: $!\n";
 
119
 
 
120
print "\n Making $outIniFile...\n";
 
121
 
 
122
# While loop to read each line from input file
 
123
while($line = <fpInIt>)
 
124
{
 
125
  # For each line read, search and replace $InstallSize$ with the calculated size
 
126
  if($line =~ /\$InstallSize\$/i)
 
127
  {
 
128
    $installSize          = 0;
 
129
    $installSizeSystem    = 0;
 
130
 
 
131
    # split read line by ":" deliminator
 
132
    @colonSplit = split(/:/, $line);
 
133
    if($#colonSplit >= 0)
 
134
    {
 
135
      $componentName = $colonSplit[1];
 
136
      if (substr($componentName, -2, 2) eq "\r\n") {
 
137
        $componentName = substr($componentName, 0, length($componentName) - 2) . "\n";
 
138
      }
 
139
      else {
 
140
        chop($componentName);
 
141
      }
 
142
 
 
143
      if($componentName =~ /\$UninstallFileZip\$/i)
 
144
      {
 
145
        $installSize = OutputInstallSizeArchive("$inXpiPath/$fileUninstallZip") * 2;
 
146
      }
 
147
      else
 
148
      {
 
149
        $installSize = OutputInstallSize("$inStagePath/$componentName");
 
150
 
 
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)
 
155
        {
 
156
          $installSize = int($installSize * 3.62);
 
157
        }
 
158
 
 
159
        if($componentName =~ /gre/i)
 
160
        {
 
161
          $installSize = int($installSize * 4.48);
 
162
        }
 
163
      }
 
164
    }
 
165
 
 
166
    # Read the next line to calculate for the "Install Size System="
 
167
    if($line = <fpInIt>)
 
168
    {
 
169
      if($line =~ /\$InstallSizeSystem\$/i)
 
170
      {
 
171
        $installSizeSystem = OutputInstallSizeSystem($line, "$inStagePath/$componentName");
 
172
      }
 
173
    }
 
174
 
 
175
    $installSize -= $installSizeSystem;
 
176
    print fpOutIni "Install Size=$installSize\n";
 
177
    print fpOutIni "Install Size System=$installSizeSystem\n";
 
178
  }
 
179
  elsif($line =~ /\$InstallSizeArchive\$/i)
 
180
  {
 
181
    $installSizeArchive = 0;
 
182
 
 
183
    # split read line by ":" deliminator
 
184
    @colonSplit = split(/:/, $line);
 
185
    if($#colonSplit >= 0)
 
186
    {
 
187
      $componentName = $colonSplit[1];
 
188
      if (substr($componentName, -2, 2) eq "\r\n") {
 
189
        $componentName = substr($componentName, 0, length($componentName) - 2) . "\n";
 
190
      }
 
191
      else {
 
192
        chop($componentName);
 
193
      }
 
194
      $componentName      =~ s/\$UninstallFileZip\$/$fileUninstallZip/gi;
 
195
      $installSizeArchive = OutputInstallSizeArchive("$inXpiPath/$componentName");
 
196
    }
 
197
 
 
198
    print fpOutIni "Install Size Archive=$installSizeArchive\n";
 
199
  }
 
200
  elsif($line =~ /\$FileCount\$/i) 
 
201
  {
 
202
    if (!($componentName eq "")) 
 
203
    {
 
204
      $stageDir = "$inStagePath/$componentName";
 
205
      $stageDir =~ s/(.xpi|.zip)\b//i;
 
206
      if (substr($stageDir, -1, 1) eq "\n") {
 
207
        chop($stageDir);
 
208
      }
 
209
      $fileCount = `find $stageDir -type f | wc -l`;
 
210
      if (substr($fileCount, -1, 1) eq "\n") {
 
211
        chop($fileCount);
 
212
      }
 
213
  
 
214
      $line =~ s/\$FileCount\$/$fileCount/i;
 
215
 
 
216
      print fpOutIni $line;
 
217
    }
 
218
  }
 
219
  else
 
220
  {
 
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;
 
244
  }
 
245
}
 
246
 
 
247
print " done!\n";
 
248
 
 
249
# end of script
 
250
exit(0);
 
251
 
 
252
sub ParseDomainAndPath()
 
253
{
 
254
  my($aUrl) = @_;
 
255
  my($aDomain, $aServerPath);
 
256
 
 
257
  @slashSplit = split(/\//, $aUrl);
 
258
  if($#slashSplit >= 0)
 
259
  {
 
260
    for($i = 0; $i <= $#slashSplit; $i++)
 
261
    {
 
262
      if($i <= 2)
 
263
      {
 
264
        if($aDomain eq "")
 
265
        {
 
266
          $aDomain = "$slashSplit[$i]";
 
267
        }
 
268
        else
 
269
        {
 
270
          $aDomain = "$aDomain/$slashSplit[$i]";
 
271
        }
 
272
      }
 
273
      else
 
274
      {
 
275
        if($aServerPath eq "")
 
276
        {
 
277
          $aServerPath = "/$slashSplit[$i]";
 
278
        }
 
279
        else
 
280
        {
 
281
          $aServerPath = "$aServerPath/$slashSplit[$i]";
 
282
        }
 
283
      }
 
284
    }
 
285
  }
 
286
 
 
287
  return($aDomain, $aServerPath);
 
288
}
 
289
 
 
290
sub OutputInstallSize()
 
291
{
 
292
  my($inPath) = @_;
 
293
  my($installSize);
 
294
 
 
295
  print "   calculating size for $inPath\n";
 
296
 
 
297
  my ($inPathWin) = `cygpath -wa $inPath`;
 
298
  chomp($inPathWin);
 
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);
 
303
  $installSize   += 1;
 
304
  return($installSize);
 
305
}
 
306
 
 
307
sub OutputInstallSizeArchive()
 
308
{
 
309
  my($inPath) = @_;
 
310
  my($installSizeArchive);
 
311
  my($dev, $ino, $mode, $nlink, $uid, $gui, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks);
 
312
 
 
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);
 
319
}
 
320
 
 
321
sub OutputInstallSizeSystem()
 
322
{
 
323
  my($inLine, $inPath) = @_;
 
324
  my($installSizeSystem) = 0;
 
325
 
 
326
  # split read line by ":" deliminator
 
327
  @colonSplit = split(/:/, $inLine);
 
328
  if($#colonSplit >= 0)
 
329
  {
 
330
    # split line by "," deliminator
 
331
    @commaSplit = split(/\,/, $colonSplit[1]);
 
332
    if($#commaSplit >= 0)
 
333
    {
 
334
      foreach(@commaSplit)
 
335
      {
 
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/$_`;
 
339
      }
 
340
    }
 
341
  }
 
342
 
 
343
  $installSizeSystem  = int($installSizeSystem / 1024);
 
344
  $installSizeSystem += 1;
 
345
  return($installSizeSystem);
 
346
}
 
347
 
 
348
sub ParseUserAgentShort()
 
349
{
 
350
  my($aUserAgent) = @_;
 
351
  my($aUserAgentShort);
 
352
 
 
353
  @spaceSplit = split(/ /, $aUserAgent);
 
354
  if($#spaceSplit >= 0)
 
355
  {
 
356
    $aUserAgentShort = $spaceSplit[0];
 
357
  }
 
358
 
 
359
  return($aUserAgentShort);
 
360
}
 
361