~ubuntu-branches/ubuntu/oneiric/enigmail/oneiric-updates

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2010-04-10 01:42:24 UTC
  • Revision ID: james.westby@ubuntu.com-20100410014224-fbq9ui5x3b0h2t36
Tags: 2:1.0.1-0ubuntu1
* First releaase of enigmail 1.0.1 for tbird/icedove 3
  (LP: #527138)
* redo packaging from scratch 
  + add debian/make-orig target that uses xulrunner provided
    buildsystem + enigmail tarball to produce a proper orig.tar.gz
  + use debhelper 7 with mozilla-devscripts
  + use debian source format 3.0 (quilt)
  + patch enigmail to use frozen API only
    - add debian/patches/frozen_api.diff
  + patch build system to not link against -lxul - which isnt
    available for sdks produced by all-static apps like tbird
    - add debian/patches/build_system_dont_link_libxul.diff
  + add minimal build-depends to control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!c:\perl\bin\perl
 
2
 
3
# ***** BEGIN LICENSE BLOCK *****
 
4
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
5
#
 
6
# The contents of this file are subject to the Mozilla Public License Version
 
7
# 1.1 (the "License"); you may not use this file except in compliance with
 
8
# the License. You may obtain a copy of the License at
 
9
# http://www.mozilla.org/MPL/
 
10
#
 
11
# Software distributed under the License is distributed on an "AS IS" basis,
 
12
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
13
# for the specific language governing rights and limitations under the
 
14
# License.
 
15
#
 
16
# The Original Code is Mozilla Communicator client code, released
 
17
# March 31, 1998.
 
18
#
 
19
# The Initial Developer of the Original Code is
 
20
# Netscape Communications Corporation.
 
21
# Portions created by the Initial Developer are Copyright (C) 1998-1999
 
22
# the Initial Developer. All Rights Reserved.
 
23
#
 
24
# Contributor(s):
 
25
#   Sean Su <ssu@netscape.com>
 
26
#   Howard Chu <hyc@symas.com>
 
27
#
 
28
# Alternatively, the contents of this file may be used under the terms of
 
29
# either the GNU General Public License Version 2 or later (the "GPL"), or
 
30
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
31
# in which case the provisions of the GPL or the LGPL are applicable instead
 
32
# of those above. If you wish to allow use of your version of this file only
 
33
# under the terms of either the GPL or the LGPL, and not to allow others to
 
34
# use your version of this file under the terms of the MPL, indicate your
 
35
# decision by deleting the provisions above and replace them with the notice
 
36
# and other provisions required by the GPL or the LGPL. If you do not delete
 
37
# the provisions above, a recipient may use your version of this file under
 
38
# the terms of any one of the MPL, the GPL or the LGPL.
 
39
#
 
40
# ***** END LICENSE BLOCK *****
 
41
 
 
42
#
 
43
# This perl script parses the input file for special variables
 
44
# in the format of $Variable$ and replace it with the appropriate
 
45
# value(s).
 
46
#
 
47
# Input: .it file
 
48
#             - which is a .ini template
 
49
#
 
50
#        version
 
51
#             - version to display on the blue background
 
52
#
 
53
#        Path to staging area
 
54
#             - path on where the seamonkey built bits are staged to
 
55
#
 
56
#        xpi path
 
57
#             - path on where xpi files will be located at
 
58
#
 
59
#        redirect file url
 
60
#             - url to where the redirect.ini file will be staged at.
 
61
#               Either ftp:// or http:// can be used
 
62
#               ie: ftp://ftp.netscape.com/pub/seamonkey
 
63
#
 
64
#        xpi url
 
65
#             - url to where the .xpi files will be staged at.
 
66
#               Either ftp:// or http:// can be used
 
67
#               ie: ftp://ftp.netscape.com/pub/seamonkey/xpi
 
68
#
 
69
#   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
 
70
#
 
71
#
 
72
 
 
73
# Make sure there are at least two arguments
 
74
if($#ARGV < 5)
 
75
{
 
76
  die "usage: $0 <.it file> <version> <staging path> <.xpi path> <redirect file url> <xpi url>
 
77
 
 
78
       .it file      : input ini template file
 
79
 
 
80
       version       : version to be shown in setup.  Typically the same version
 
81
                       as show in mozilla.exe.
 
82
 
 
83
       staging path  : path to where the components are staged at
 
84
 
 
85
       .xpi path     : path to where the .xpi files have been built to
 
86
                       ie: d:/builds/mozilla/dist/win32_o.obj/install/xpi
 
87
 
 
88
       redirect file : url to where the redirect.ini file will be staged at.
 
89
 
 
90
       xpi url       : url to where the .xpi files will be staged at.
 
91
                       Either ftp:// or http:// can be used
 
92
                       ie: ftp://ftp.netscape.com/pub/seamonkey/xpi
 
93
       \n";
 
94
}
 
95
 
 
96
$inItFile         = $ARGV[0];
 
97
$inVersion        = $ARGV[1];
 
98
$inStagePath      = $ARGV[2];
 
99
$inXpiPath        = $ARGV[3];
 
100
$inRedirIniUrl    = $ARGV[4];
 
101
$inUrl            = $ARGV[5];
 
102
 
 
103
# get environment vars
 
104
$userAgent        = $ENV{WIZ_userAgent};
 
105
$userAgentShort   = $ENV{WIZ_userAgentShort};
 
106
$xpinstallVersion = $ENV{WIZ_xpinstallVersion};
 
107
$nameCompany      = $ENV{WIZ_nameCompany};
 
108
$nameProduct      = $ENV{WIZ_nameProduct};
 
109
$shortNameProduct = $ENV{WIZ_shortNameProduct};
 
110
$nameProductInternal = $ENV{WIZ_nameProductInternal};
 
111
$fileMainExe      = $ENV{WIZ_fileMainExe};
 
112
$greBuildID       = $ENV{WIZ_greBuildID};
 
113
$greFileVersion   = $ENV{WIZ_greFileVersion};
 
114
$greUniqueID      = $ENV{WIZ_greUniqueID};
 
115
 
 
116
$inDomain;
 
117
$inRedirDomain;
 
118
$inServerPath;
 
119
$inRedirServerPath;
 
120
 
 
121
($inDomain,      $inServerPath)      = ParseDomainAndPath($inUrl);
 
122
($inRedirDomain, $inRedirServerPath) = ParseDomainAndPath($inRedirIniUrl);
 
123
 
 
124
# Get the name of the file replacing the .it extension with a .ini extension
 
125
@inItFileSplit    = split(/\./,$inItFile);
 
126
$outIniFile       = $inItFileSplit[0];
 
127
$outIniFile      .= ".ini";
 
128
 
 
129
# Open the input file
 
130
open(fpInIt, $inItFile) || die "\ncould not open $ARGV[0]: $!\n";
 
131
 
 
132
# Open the output file
 
133
open(fpOutIni, ">$outIniFile") || die "\nCould not open $outIniFile: $!\n";
 
134
 
 
135
print "\n Making $outIniFile...\n";
 
136
 
 
137
# While loop to read each line from input file
 
138
while($line = <fpInIt>)
 
139
{
 
140
  # For each line read, search and replace $InstallSize$ with the calculated size
 
141
  if($line =~ /\$InstallSize\$/i)
 
142
  {
 
143
    $installSize          = 0;
 
144
    $installSizeSystem    = 0;
 
145
 
 
146
    # split read line by ":" deliminator
 
147
    @colonSplit = split(/:/, $line);
 
148
    if($#colonSplit >= 0)
 
149
    {
 
150
      $componentName = $colonSplit[1];
 
151
      if (substr($componentName, -2, 2) eq "\r\n") {
 
152
        $componentName = substr($componentName, 0, length($componentName) - 2) . "\n";
 
153
      }
 
154
      else {
 
155
        chop($componentName);
 
156
      }
 
157
 
 
158
      $installSize = OutputInstallSize("$inStagePath/$componentName");
 
159
 
 
160
      # special oji consideration here.  Since it's an installer that 
 
161
      # seamonkey installer will be calling, the disk space allocation
 
162
      # needs to be adjusted by an expansion factor of 3.62.
 
163
      if($componentName =~ /oji/i)
 
164
      {
 
165
        $installSize = int($installSize * 3.62);
 
166
      }
 
167
 
 
168
      if($componentName =~ /gre/i)
 
169
      {
 
170
        $installSize = int($installSize * 4.48);
 
171
      }
 
172
    }
 
173
 
 
174
    # Read the next line to calculate for the "Install Size System="
 
175
    if($line = <fpInIt>)
 
176
    {
 
177
      if($line =~ /\$InstallSizeSystem\$/i)
 
178
      {
 
179
        $installSizeSystem = OutputInstallSizeSystem($line, "$inStagePath/$componentName");
 
180
      }
 
181
    }
 
182
 
 
183
    $installSize -= $installSizeSystem;
 
184
    print fpOutIni "Install Size=$installSize\n";
 
185
    print fpOutIni "Install Size System=$installSizeSystem\n";
 
186
  }
 
187
  elsif($line =~ /\$InstallSizeArchive\$/i)
 
188
  {
 
189
    $installSizeArchive = 0;
 
190
 
 
191
    # split read line by ":" deliminator
 
192
    @colonSplit = split(/:/, $line);
 
193
    if($#colonSplit >= 0)
 
194
    {
 
195
      $componentName = $colonSplit[1];
 
196
      if (substr($componentName, -2, 2) eq "\r\n") {
 
197
        $componentName = substr($componentName, 0, length($componentName) - 2) . "\n";
 
198
      }
 
199
      else {
 
200
        chop($componentName);
 
201
      }
 
202
      $installSizeArchive = OutputInstallSizeArchive("$inXpiPath/$componentName");
 
203
    }
 
204
 
 
205
    print fpOutIni "Install Size Archive=$installSizeArchive\n";
 
206
  }
 
207
  elsif($line =~ /\$FileCount\$/i) 
 
208
  {
 
209
    if (!($componentName eq "")) 
 
210
    {
 
211
      $stageDir = "$inStagePath/$componentName";
 
212
      $stageDir =~ s/(.xpi|.zip)\b//i;
 
213
      if (substr($stageDir, -1, 1) eq "\n") {
 
214
        chop($stageDir);
 
215
      }
 
216
      $fileCount = `find $stageDir -type f | wc -l`;
 
217
      if (substr($fileCount, -1, 1) eq "\n") {
 
218
        chop($fileCount);
 
219
      }
 
220
  
 
221
      $line =~ s/\$FileCount\$/$fileCount/i;
 
222
 
 
223
      print fpOutIni $line;
 
224
    }
 
225
  }
 
226
  else
 
227
  {
 
228
    # For each line read, search and replace $Version$ with the version passed in
 
229
    $line =~ s/\$Version\$/$inVersion/gi;
 
230
    $line =~ s/\$Domain\$/$inDomain/gi;
 
231
    $line =~ s/\$ServerPath\$/$inServerPath/gi;
 
232
    $line =~ s/\$RedirIniUrl\$/$inRedirIniUrl/gi;
 
233
    $line =~ s/\$ArchiveServerPath\$/$inServerPath/gi;
 
234
    $line =~ s/\$ArchiveUrl\$/$inUrl/gi;
 
235
    $line =~ s/\$RedirectServerPath\$/$inRedirServerPath/gi;
 
236
    $line =~ s/\$RedirectUrl\$/$inRedirUrl/gi;
 
237
    $line =~ s/\$UserAgent\$/$userAgent/gi;
 
238
    $line =~ s/\$UserAgentShort\$/$userAgentShort/gi;
 
239
    $line =~ s/\$XPInstallVersion\$/$xpinstallVersion/gi;
 
240
    $line =~ s/\$CompanyName\$/$nameCompany/gi;
 
241
    $line =~ s/\$ProductName\$/$nameProduct/gi;
 
242
    $line =~ s/\$ProductNameInternal\$/$nameProductInternal/gi;
 
243
    $line =~ s/\$ProductShortName\$/$shortNameProduct/gi;
 
244
    $line =~ s/\$MainExeFile\$/$fileMainExe/gi;
 
245
    $line =~ s/\$GreBuildID\$/$greBuildID/gi;
 
246
    $line =~ s/\$GreFileVersion\$/$greFileVersion/gi;
 
247
    $line =~ s/\$GreUniqueID\$/$greUniqueID/gi;
 
248
    print fpOutIni $line;
 
249
  }
 
250
}
 
251
 
 
252
print " done!\n";
 
253
 
 
254
# end of script
 
255
exit(0);
 
256
 
 
257
sub ParseDomainAndPath()
 
258
{
 
259
  my($aUrl) = @_;
 
260
  my($aDomain, $aServerPath);
 
261
 
 
262
  @slashSplit = split(/\//, $aUrl);
 
263
  if($#slashSplit >= 0)
 
264
  {
 
265
    for($i = 0; $i <= $#slashSplit; $i++)
 
266
    {
 
267
      if($i <= 2)
 
268
      {
 
269
        if($aDomain eq "")
 
270
        {
 
271
          $aDomain = "$slashSplit[$i]";
 
272
        }
 
273
        else
 
274
        {
 
275
          $aDomain = "$aDomain/$slashSplit[$i]";
 
276
        }
 
277
      }
 
278
      else
 
279
      {
 
280
        if($aServerPath eq "")
 
281
        {
 
282
          $aServerPath = "/$slashSplit[$i]";
 
283
        }
 
284
        else
 
285
        {
 
286
          $aServerPath = "$aServerPath/$slashSplit[$i]";
 
287
        }
 
288
      }
 
289
    }
 
290
  }
 
291
 
 
292
  return($aDomain, $aServerPath);
 
293
}
 
294
 
 
295
sub OutputInstallSize()
 
296
{
 
297
  my($inPath) = @_;
 
298
  my($installSize);
 
299
 
 
300
  print "   calculating size for $inPath\n";
 
301
 
 
302
  my ($inPathWin);
 
303
  if($^O =~ msys)
 
304
  {
 
305
    $inPathWin = $inPath;
 
306
  } else {
 
307
    $inPathWin = `cygpath -wa $inPath`;
 
308
  chomp($inPathWin);
 
309
  $inPathWin =~ s/\\/\\\\/g;
 
310
  }
 
311
  $installSize    = `$ENV{WIZ_distInstallPath}/ds32.exe -D -L0 -A -S -C 32768 $inPathWin`;
 
312
  $installSize   += 32768; # take into account install.js
 
313
  $installSize    = int($installSize / 1024);
 
314
  $installSize   += 1;
 
315
  return($installSize);
 
316
}
 
317
 
 
318
sub OutputInstallSizeArchive()
 
319
{
 
320
  my($inPath) = @_;
 
321
  my($installSizeArchive);
 
322
  my($dev, $ino, $mode, $nlink, $uid, $gui, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks);
 
323
 
 
324
  print "   calculating size for $inPath\n";
 
325
  ($dev, $ino, $mode, $nlink, $uid, $gui, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $inPath;
 
326
  $installSizeArchive   += 32768; # take into account install.js
 
327
  $installSizeArchive    = int($size / 1024);
 
328
  $installSizeArchive   += 1;
 
329
  return($installSizeArchive);
 
330
}
 
331
 
 
332
sub OutputInstallSizeSystem()
 
333
{
 
334
  my($inLine, $inPath) = @_;
 
335
  my($installSizeSystem) = 0;
 
336
 
 
337
  # split read line by ":" deliminator
 
338
  @colonSplit = split(/:/, $inLine);
 
339
  if($#colonSplit >= 0)
 
340
  {
 
341
    # split line by "," deliminator
 
342
    @commaSplit = split(/\,/, $colonSplit[1]);
 
343
    if($#commaSplit >= 0)
 
344
    {
 
345
      foreach(@commaSplit)
 
346
      {
 
347
        # calculate the size of component installed using ds32.exe in Kbytes
 
348
        print "   calculating size for $inPath/$_";
 
349
        $installSizeSystem += `$ENV{WIZ_distInstallPath}/ds32.exe /D /L0 /A /S /C 32768 $inPath/$_`;
 
350
      }
 
351
    }
 
352
  }
 
353
 
 
354
  $installSizeSystem  = int($installSizeSystem / 1024);
 
355
  $installSizeSystem += 1;
 
356
  return($installSizeSystem);
 
357
}
 
358
 
 
359
sub ParseUserAgentShort()
 
360
{
 
361
  my($aUserAgent) = @_;
 
362
  my($aUserAgentShort);
 
363
 
 
364
  @spaceSplit = split(/ /, $aUserAgent);
 
365
  if($#spaceSplit >= 0)
 
366
  {
 
367
    $aUserAgentShort = $spaceSplit[0];
 
368
  }
 
369
 
 
370
  return($aUserAgentShort);
 
371
}
 
372