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

« back to all changes in this revision

Viewing changes to mozilla/xpinstall/wizard/windows/builder/build.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, 
 
14
# released March 31, 1998. 
 
15
#
 
16
# The Initial Developer of the Original Code is Netscape Communications 
 
17
# Corporation.  Portions created by Netscape are
 
18
# Copyright (C) 1999 Netscape Communications Corporation. All
 
19
# Rights Reserved.
 
20
#
 
21
# Contributor(s): 
 
22
#   Sean Su <ssu@netscape.com>
 
23
 
 
24
#
 
25
# Purpose:
 
26
#    To build the mozilla self-extracting installer and its corresponding .xpi files
 
27
#    given a mozilla build on a local system.
 
28
#
 
29
# Requirements:
 
30
# 1. perl needs to be installed correctly on the build system because cwd.pm is used.
 
31
# 2. mozilla\xpinstall\wizard\windows needs to be built.
 
32
#    a. to build it, MFC must be installed with VC
 
33
#    b. set MOZ_MFC=1 in the build environment
 
34
#    c. run nmake -f makefile.win from the above directory
 
35
#
 
36
 
 
37
use Cwd;
 
38
use File::Copy;
 
39
use File::Path;
 
40
use File::Basename;
 
41
 
 
42
$DEPTH         = "../../../..";
 
43
$topsrcdir     = GetTopSrcDir();
 
44
# ensure that Packager.pm is in @INC, since we might not be called from
 
45
# mozilla/xpinstall/packager
 
46
push(@INC, "$topsrcdir/../mozilla/xpinstall/packager");
 
47
require StageUtils;
 
48
 
 
49
ParseArgv(@ARGV);
 
50
 
 
51
$topobjdir        = $topsrcdir                   if !defined($topobjdir);
 
52
$inXpiURL         = "ftp://not.supplied.invalid" if !defined($inXpiURL);
 
53
$inRedirIniURL    = $inXpiURL                    if !defined($inRedirIniURL);
 
54
$inStagePath      = "$topobjdir/stage"           if !defined($inStagePath);
 
55
$inDistPath       = "$topobjdir/dist"            if !defined($inDistPath);
 
56
$cwdBuilder       = "$topsrcdir/xpinstall/wizard/windows/builder";
 
57
$gDistInstallPath = "$inDistPath/install";
 
58
$gPackagerPath    = "$topsrcdir/xpinstall/packager";
 
59
 
 
60
if(defined($ENV{DEBUG_INSTALLER_BUILD}))
 
61
{
 
62
  print " build.pl\n";
 
63
  print "   topobjdir: $topobjdir\n";
 
64
  print "   inDistPath: $inDistPath\n";
 
65
}
 
66
 
 
67
# mozilla's makeall.pl will call GRE's makeall.pl
 
68
chdir("$gPackagerPath/windows");
 
69
if(system("perl makeall.pl -objDir \"$topobjdir\" -stagePath \"$inStagePath\" -distPath \"$inDistPath\" -aurl $inXpiURL -rurl $inRedirIniURL"))
 
70
{
 
71
  die "\n Error: perl makeall.pl -objDir \"$topobjdir\" -stagePath \"$inStagePath\" -distPath \"$inDistPath\" -aurl $inXpiURL -rurl $inRedirIniURL\n";
 
72
}
 
73
 
 
74
chdir($cwdBuilder);
 
75
 
 
76
# Copy the .xpi files to the same directory as setup.exe.
 
77
# This is so that setup.exe can find the .xpi files
 
78
# in the same directory and use them.
 
79
StageUtils::CopyFiles("$gDistInstallPath/xpi", "$gDistInstallPath");
 
80
 
 
81
print "\n";
 
82
print "**\n";
 
83
print "*\n";
 
84
print "*  A self-extracting installer has been built and delivered:\n";
 
85
print "*\n";
 
86
print "*      $gDistInstallPath/mozilla-win32-installer.exe\n";
 
87
print "*\n";
 
88
print "**\n";
 
89
print "\n";
 
90
 
 
91
exit(0);
 
92
 
 
93
sub PrintUsage
 
94
{
 
95
  die "usage: $0 [options]
 
96
 
 
97
       options available are:
 
98
 
 
99
           -h                - this usage.
 
100
 
 
101
           -objDir <path>    - the build directory (defaults to a srcdir build)
 
102
 
 
103
           -stagePath <path> - Full path to where the mozilla stage dir is at.
 
104
                               Default path, if one is not set, is:
 
105
                                 [mozilla]/stage
 
106
 
 
107
           -distPath <path>  - Full path to where the mozilla dist dir is at.
 
108
                               Default path, if one is not set, is:
 
109
                                 [mozilla]/dist
 
110
 
 
111
           -aurl <url>       - ftp or http url for where the archives (.xpi, exe, .zip, etx...) are.
 
112
                                 ie: ftp://my.ftp.com/mysoftware/version1.0/xpi
 
113
 
 
114
           -rurl <url>       - ftp or http url for where the redirect.ini file is located at.
 
115
                                 ie: ftp://my.ftp.com/mysoftware/version1.0
 
116
                   
 
117
                               This url can be the same as the archive url.
 
118
                               If -rurl is not supplied, it will be assumed that the redirect.ini
 
119
                               file is at -arul.
 
120
 
 
121
           -DEPTH location of the top of the Mozilla build tree
 
122
       \n";
 
123
}
 
124
 
 
125
sub ParseArgv
 
126
{
 
127
  my(@myArgv) = @_;
 
128
  my($counter);
 
129
 
 
130
  for($counter = 0; $counter <= $#myArgv; $counter++)
 
131
  {
 
132
    if($myArgv[$counter] =~ /^[-,\/]h$/i)
 
133
    {
 
134
      PrintUsage();
 
135
    }
 
136
    elsif($myArgv[$counter] =~ /^[-,\/]objDir$/i)
 
137
    {
 
138
      if($#myArgv >= ($counter + 1))
 
139
      {
 
140
        ++$counter;
 
141
        $topobjdir = $myArgv[$counter];
 
142
        $topobjdir =~ s/\\/\//g;
 
143
      }
 
144
    }
 
145
    elsif($myArgv[$counter] =~ /^[-,\/]stagePath$/i)
 
146
    {
 
147
      if($#myArgv >= ($counter + 1))
 
148
      {
 
149
        ++$counter;
 
150
        $inStagePath = $myArgv[$counter];
 
151
        $inStagePath =~ s/\\/\//g;
 
152
      }
 
153
    }
 
154
    elsif($myArgv[$counter] =~ /^[-,\/]distPath$/i)
 
155
    {
 
156
      if($#myArgv >= ($counter + 1))
 
157
      {
 
158
        ++$counter;
 
159
        $inDistPath = $myArgv[$counter];
 
160
        $inDistPath =~ s/\\/\//g;
 
161
      }
 
162
    }
 
163
    elsif($myArgv[$counter] =~ /^[-,\/]aurl$/i)
 
164
    {
 
165
      if($#myArgv >= ($counter + 1))
 
166
      {
 
167
        ++$counter;
 
168
        $inXpiURL = $myArgv[$counter];
 
169
        $inRedirIniURL = $inXpiURL;
 
170
      }
 
171
    }
 
172
    elsif($myArgv[$counter] =~ /^[-,\/]rurl$/i)
 
173
    {
 
174
      if($#myArgv >= ($counter + 1))
 
175
      {
 
176
        ++$counter;
 
177
        $inRedirIniURL = $myArgv[$counter];
 
178
      }
 
179
    }
 
180
    elsif($myArgv[$counter] =~ /^[-,\/]depth$/i)
 
181
    {
 
182
      if($#myArgv >= ($counter + 1))
 
183
      {
 
184
        ++$counter;
 
185
        $DEPTH = $myArgv[$counter];
 
186
      }
 
187
    }
 
188
  }
 
189
  PrintUsage() if (!defined($topsrcdir));
 
190
  $tmpdir = get_system_cwd();
 
191
  chdir("$topsrcdir") || die "$topsrcdir: Directory does not exist!\n";
 
192
  $topsrcdir = get_system_cwd();
 
193
  chdir("$tmpdir") || die "$tmpdir: Cannot find our way back home\n";
 
194
  if (defined($DEPTH)) {
 
195
      chdir("$DEPTH") || die "$DEPTH: Directory does not exist!\n";
 
196
      $DEPTH = get_system_cwd();
 
197
      chdir("$tmpdir") || die "$tmpdir: Cannot find our way back home again\n";
 
198
  }
 
199
}
 
200
 
 
201
sub get_system_cwd {
 
202
  my $a = Cwd::getcwd()||`pwd`;
 
203
  chomp($a);
 
204
  return $a;
 
205
}
 
206
 
 
207
sub GetVersion
 
208
{
 
209
  my($depthPath) = @_;
 
210
  my($fileMozilla);
 
211
  my($fileMozillaVer);
 
212
  my($distWinPathName);
 
213
  my($monAdjusted);
 
214
  my($yy);
 
215
  my($mm);
 
216
  my($dd);
 
217
  my($hh);
 
218
 
 
219
  # determine if build was built via gmake
 
220
  $distWinPathName = "dist";
 
221
 
 
222
  $fileMozilla = "$depthPath/$distWinPathName/bin/mozilla.exe";
 
223
  # verify the existance of file
 
224
  if(!(-e "$fileMozilla"))
 
225
  {
 
226
    print "file not found: $fileMozilla\n";
 
227
    exit(1);
 
228
  }
 
229
 
 
230
  ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $fileMozilla;
 
231
  ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($mtime);
 
232
 
 
233
  # calculate year
 
234
  # localtime() returns year 2000 as 100, we mod 100 to get at the last 2 digits
 
235
  $yy = $year % 100;
 
236
  $yy = "20" . sprintf("%.2d", $yy);
 
237
 
 
238
  # calculate month
 
239
  $monAdjusted = $mon + 1;
 
240
  $mm = sprintf("%.2d", $monAdjusted);
 
241
 
 
242
  # calculate month day
 
243
  $dd = sprintf("%.2d", $mday);
 
244
 
 
245
  # calculate day hour
 
246
  $hh = sprintf("%.2d", $hour);
 
247
 
 
248
  $fileMozillaVer = "$yy$mm$dd$hh";
 
249
  print "y2k compliant version string for $fileMozilla: $fileMozillaVer\n";
 
250
  return($fileMozillaVer);
 
251
}
 
252
 
 
253
sub GetTopSrcDir
 
254
{
 
255
  my($rootDir) = dirname($0) . "/$DEPTH";
 
256
  my($savedCwdDir) = cwd();
 
257
 
 
258
  chdir($rootDir);
 
259
  $rootDir = cwd();
 
260
  chdir($savedCwdDir);
 
261
  return($rootDir);
 
262
}
 
263