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

« back to all changes in this revision

Viewing changes to mozilla/xpinstall/packager/win_gre/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
$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};
 
99
 
 
100
$inDomain;
 
101
$inRedirDomain;
 
102
$inServerPath;
 
103
$inRedirServerPath;
 
104
 
 
105
($inDomain,      $inServerPath)      = ParseDomainAndPath($inUrl);
 
106
($inRedirDomain, $inRedirServerPath) = ParseDomainAndPath($inRedirIniUrl);
 
107
 
 
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";
 
112
 
 
113
# Open the input file
 
114
open(fpInIt, $inItFile) || die "\ncould not open $ARGV[0]: $!\n";
 
115
 
 
116
# Open the output file
 
117
open(fpOutIni, ">$outIniFile") || die "\nCould not open $outIniFile: $!\n";
 
118
 
 
119
print "\n Making $outIniFile...\n";
 
120
 
 
121
# While loop to read each line from input file
 
122
while($line = <fpInIt>)
 
123
{
 
124
  # For each line read, search and replace $InstallSize$ with the calculated size
 
125
  if($line =~ /\$InstallSize\$/i)
 
126
  {
 
127
    $installSize          = 0;
 
128
    $installSizeSystem    = 0;
 
129
 
 
130
    # split read line by ":" deliminator
 
131
    @colonSplit = split(/:/, $line);
 
132
    if($#colonSplit >= 0)
 
133
    {
 
134
      $componentName    = $colonSplit[1];
 
135
      chop($componentName);
 
136
 
 
137
      if($componentName =~ /\$UninstallFileZip\$/i)
 
138
      {
 
139
        $installSize = OutputInstallSizeArchive("$inXpiPath/$fileUninstallZip") * 2;
 
140
      }
 
141
      else
 
142
      {
 
143
        $installSize = OutputInstallSize("$inStagePath/$componentName");
 
144
 
 
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)
 
149
        {
 
150
          $installSize = int($installSize * 3.62);
 
151
        }
 
152
      }
 
153
    }
 
154
 
 
155
    # Read the next line to calculate for the "Install Size System="
 
156
    if($line = <fpInIt>)
 
157
    {
 
158
      if($line =~ /\$InstallSizeSystem\$/i)
 
159
      {
 
160
        $installSizeSystem = OutputInstallSizeSystem($line, "$inStagePath/$componentName");
 
161
      }
 
162
    }
 
163
 
 
164
    $installSize -= $installSizeSystem;
 
165
    print fpOutIni "Install Size=$installSize\n";
 
166
    print fpOutIni "Install Size System=$installSizeSystem\n";
 
167
  }
 
168
  elsif($line =~ /\$InstallSizeArchive\$/i)
 
169
  {
 
170
    $installSizeArchive = 0;
 
171
 
 
172
    # split read line by ":" deliminator
 
173
    @colonSplit = split(/:/, $line);
 
174
    if($#colonSplit >= 0)
 
175
    {
 
176
      $componentName = $colonSplit[1];
 
177
      chop($componentName);
 
178
      $componentName      =~ s/\$UninstallFileZip\$/$fileUninstallZip/gi;
 
179
      $installSizeArchive = OutputInstallSizeArchive("$inXpiPath/$componentName");
 
180
    }
 
181
 
 
182
    print fpOutIni "Install Size Archive=$installSizeArchive\n";
 
183
  }
 
184
  else
 
185
  {
 
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;
 
208
  }
 
209
}
 
210
 
 
211
print " done!\n";
 
212
 
 
213
# end of script
 
214
exit(0);
 
215
 
 
216
sub ParseDomainAndPath()
 
217
{
 
218
  my($aUrl) = @_;
 
219
  my($aDomain, $aServerPath);
 
220
 
 
221
  @slashSplit = split(/\//, $aUrl);
 
222
  if($#slashSplit >= 0)
 
223
  {
 
224
    for($i = 0; $i <= $#slashSplit; $i++)
 
225
    {
 
226
      if($i <= 2)
 
227
      {
 
228
        if($aDomain eq "")
 
229
        {
 
230
          $aDomain = "$slashSplit[$i]";
 
231
        }
 
232
        else
 
233
        {
 
234
          $aDomain = "$aDomain/$slashSplit[$i]";
 
235
        }
 
236
      }
 
237
      else
 
238
      {
 
239
        if($aServerPath eq "")
 
240
        {
 
241
          $aServerPath = "/$slashSplit[$i]";
 
242
        }
 
243
        else
 
244
        {
 
245
          $aServerPath = "$aServerPath/$slashSplit[$i]";
 
246
        }
 
247
      }
 
248
    }
 
249
  }
 
250
 
 
251
  return($aDomain, $aServerPath);
 
252
}
 
253
 
 
254
sub OutputInstallSize()
 
255
{
 
256
  my($inPath) = @_;
 
257
  my($installSize);
 
258
 
 
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);
 
263
  $installSize   += 1;
 
264
  return($installSize);
 
265
}
 
266
 
 
267
sub OutputInstallSizeArchive()
 
268
{
 
269
  my($inPath) = @_;
 
270
  my($installSizeArchive);
 
271
  my($dev, $ino, $mode, $nlink, $uid, $gui, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks);
 
272
 
 
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);
 
279
}
 
280
 
 
281
sub OutputInstallSizeSystem()
 
282
{
 
283
  my($inLine, $inPath) = @_;
 
284
  my($installSizeSystem) = 0;
 
285
 
 
286
  # split read line by ":" deliminator
 
287
  @colonSplit = split(/:/, $inLine);
 
288
  if($#colonSplit >= 0)
 
289
  {
 
290
    # split line by "," deliminator
 
291
    @commaSplit = split(/\,/, $colonSplit[1]);
 
292
    if($#commaSplit >= 0)
 
293
    {
 
294
      foreach(@commaSplit)
 
295
      {
 
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/$_`;
 
299
      }
 
300
    }
 
301
  }
 
302
 
 
303
  $installSizeSystem  = int($installSizeSystem / 1024);
 
304
  $installSizeSystem += 1;
 
305
  return($installSizeSystem);
 
306
}
 
307
 
 
308
sub ParseUserAgentShort()
 
309
{
 
310
  my($aUserAgent) = @_;
 
311
  my($aUserAgentShort);
 
312
 
 
313
  @spaceSplit = split(/ /, $aUserAgent);
 
314
  if($#spaceSplit >= 0)
 
315
  {
 
316
    $aUserAgentShort = $spaceSplit[0];
 
317
  }
 
318
 
 
319
  return($aUserAgentShort);
 
320
}
 
321