~ubuntu-branches/ubuntu/precise/enigmail/precise-security

« back to all changes in this revision

Viewing changes to mozilla/toolkit/mozapps/installer/Packager.pm

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2014-01-30 11:42:56 UTC
  • mfrom: (0.12.17)
  • Revision ID: package-import@ubuntu.com-20140130114256-6yvx7ylu1cwrhwp2
Tags: 2:1.7-0ubuntu0.12.04.1
* New upstream release v1.7 to support Thunderbird 31

* No longer requires a Mozilla build system, so we use the upstream
  tarball directly now
  - update debian/rules
  - drop libgtk2.0-dev, libidl-dev, libdbus-glib-1-dev, libnotify-dev,
    libasound2-dev, libxt-dev, autoconf2.13 and mesa-common-dev
    build-depends, as these were only there because we were using a hacked
    Mozilla build system
* Update to source format 3.0
* Drop thunderbird-dev build-depend - the only binary code in enigmail now
  uses ctypes, so we don't need the SDK
* Drop debian/patches/no_libxpcom.patch - it doesn't build a binary component
  now
* Drop debian/patches/use_sdk.patch - there's no dependency on the
  Thunderbird SDK now

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!perl -w
2
 
# This Source Code Form is subject to the terms of the Mozilla Public
3
 
# License, v. 2.0. If a copy of the MPL was not distributed with this
4
 
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
 
 
6
 
package Packager;
7
 
 
8
 
require 5.004;
9
 
 
10
 
use strict;
11
 
use File::stat;
12
 
use Cwd;
13
 
use File::Basename;
14
 
use File::Copy;
15
 
use File::Find;
16
 
use File::Path;
17
 
use File::stat;
18
 
require Exporter;
19
 
 
20
 
use vars qw(@ISA @EXPORT);
21
 
 
22
 
# Package that generates a jar manifest from an input file
23
 
 
24
 
@ISA      = qw(Exporter);
25
 
@EXPORT   = qw(
26
 
                Copy
27
 
              );
28
 
 
29
 
# initialize variables
30
 
my($saved_cwd)        = cwd();
31
 
my($component)        = "";   # current component being copied
32
 
my(@components)       = ();   # list of components to copy
33
 
my($components)       = "";   # string version of @components
34
 
my($altdest)          = "";   # alternate file destination
35
 
my($line)             = "";   # line being processed
36
 
my($srcdir)           = "";   # root directory being copied from
37
 
my($destdir)          = "";   # root directory being copied to
38
 
my($package)          = "";   # file listing files to copy
39
 
my($os)               = "";   # os type (MSDOS, Unix)
40
 
my($lineno)           = 0;    # line # of package file for error text
41
 
my($debug)            = 0;    # controls amount of debug output
42
 
my($dirflag)          = 0;    # flag: are we copying a directory?
43
 
my($help)             = 0;    # flag: if set, print usage
44
 
my($fatal_warnings)   = 0;    # flag: whether package warnings (missing files or invalid entries) are fatal
45
 
my($flat)             = 0;    # copy everything into the package dir, not into separate
46
 
                              #   component dirs
47
 
my($delayed_error)    = 0;    # flag: whether an error was found while reading the manifest but we still
48
 
                              # chose to finish reading it 
49
 
#
50
 
# Copy
51
 
#
52
 
# Loop over each line in the specified manifest, copying into $destdir
53
 
#
54
 
 
55
 
sub Copy {
56
 
  ($srcdir, $destdir, $package, $os, $flat, $fatal_warnings, $help, $debug, @components) = @_;
57
 
 
58
 
  check_arguments();
59
 
 
60
 
  if ($os eq "MSDOS") {
61
 
    $srcdir =~ s|\\|/|;
62
 
    $destdir =~ s|\\|/|;
63
 
  }
64
 
 
65
 
  open (MANIFEST,"<$package") ||
66
 
    die "Error: couldn't open file $package for reading: $!.  Exiting...\n";
67
 
 
68
 
  LINE: while (<MANIFEST>) {
69
 
    $line =    "";
70
 
    $altdest = "";
71
 
    $lineno++;
72
 
 
73
 
    s/\\/\//g if ($os eq "MSDOS");  # Convert to posix path
74
 
    s/\;.*//;     # it's a comment, kill it.
75
 
    s/^\s+//;     # nuke leading whitespace
76
 
    s/\s+$//;     # nuke trailing whitespace
77
 
 
78
 
    ($debug >= 2) && print "\n";
79
 
    ($debug >= 8) && print "line $lineno:$_\n";
80
 
 
81
 
    # it's a blank line, skip it.
82
 
    /^$/  && do {
83
 
        ($debug >= 10) && print "blank line.\n";
84
 
        next LINE;
85
 
    };
86
 
 
87
 
    # it's a new component
88
 
    /^\[/ && do {
89
 
        ($debug >= 10) && print "component.\n";
90
 
        $component = $_;
91
 
        do_component();
92
 
        next LINE;
93
 
    };
94
 
 
95
 
    # if we find a file before we have a component and we are in flat mode,
96
 
    # copy it - allows for flat only files (installed-chrome.txt)
97
 
    if (( $component eq "" ) && ($components eq "" ) && (!$flat)) {
98
 
      next LINE;
99
 
    }
100
 
 
101
 
    # skip line if we're only copying specific components and outside
102
 
    # those components
103
 
    if (( $component eq "" ) && ($components ne "" )) {
104
 
      ($debug >= 10) && print "Not in specifed component.  Skipping $_\n";
105
 
      next LINE;
106
 
    }
107
 
    if ($line eq "") {
108
 
      $line = $_;       # if $line not set, set it.
109
 
    }
110
 
 
111
 
    if ($os ne "MSDOS") {   # hack - need to fix for dos
112
 
      $line =~ s|^/||;    # strip any leading path delimiter
113
 
    }
114
 
 
115
 
    # delete the file or directory following the '-'
116
 
    /^-/  && do {
117
 
        $line =~ s/^-//;    # strip leading '-'
118
 
        ($debug >= 10) && print "delete: $destdir/$component/$line\n";
119
 
        do_delete ("$destdir", "$component", "$line");
120
 
        next LINE;
121
 
    };
122
 
 
123
 
    # file/directory being copied to different target location
124
 
    /\,/  && do {
125
 
        /.*\,.*\,.*/ &&
126
 
          die "Error: multiple commas not allowed ($package, $lineno): $_.\n";
127
 
        ($line, $altdest) = split (/\s*\,\s*/, $line, 2);
128
 
        $line =~ s|/*$||;    # strip any trailing path delimiters
129
 
        $altdest =~ s|/*$||; # strip any trailing delimiter
130
 
        ($debug >= 10) && print "relocate: $line => $altdest.\n";
131
 
    };
132
 
 
133
 
    # if it has wildcards, do recursive copy.
134
 
    /(?:\*|\?)/ && do {
135
 
      ($debug >= 10) && print "wildcard copy.\n";
136
 
      do_wildcard ("$srcdir/$line");
137
 
      next LINE;
138
 
    };
139
 
 
140
 
    # if it's a single file, copy it.
141
 
    ( -f "$srcdir/$line" ) && do {
142
 
      ($debug >= 10) && print "file copy.\n";
143
 
      do_copyfile ();
144
 
      next LINE;
145
 
    };
146
 
 
147
 
    # if it's a directory, do recursive copy.
148
 
    (-d "$srcdir/$line") && do {
149
 
      ($debug >= 10) && print "directory copy.\n";
150
 
      do_copydir ("$srcdir/$line");
151
 
      next LINE;
152
 
    };
153
 
 
154
 
    # if we hit this, it's either a file in the package file that is
155
 
    # not in the src directory, or it is not a valid entry.
156
 
    delayed_die_or_warn("package error or possible missing or unnecessary file: $line ($package, $lineno).");
157
 
 
158
 
  } # LINE
159
 
 
160
 
  close (MANIFEST);
161
 
  chdir ($saved_cwd);
162
 
  if ($delayed_error) {
163
 
    die "Error: found error(s) while packaging, see above for details.\n"
164
 
  }
165
 
}
166
 
 
167
 
#
168
 
# Delete the given file or directory
169
 
#
170
 
sub do_delete
171
 
{
172
 
  my ($targetpath) = $_[0];
173
 
  my ($targetcomp) = $_[1];
174
 
  my ($targetfile) = $_[2];
175
 
  my ($target) = ($flat) ? "$targetpath/$targetfile" : "$targetpath/$targetcomp/$targetfile";
176
 
 
177
 
  ($debug >= 2) && print "do_delete():\n";
178
 
  ($debug >= 1) && print "-$targetfile\n";
179
 
 
180
 
  if ( -f $target ) {
181
 
    (! -w $target ) &&
182
 
      die "Error: delete failed: $target not writeable ($package, $component, $lineno).  Exiting...\n";
183
 
    ($debug >= 4) && print " unlink($target)\n";
184
 
    unlink ($target) ||
185
 
      die "Error: unlink() failed: $!.  Exiting...\n";
186
 
  } elsif ( -d $target ) {
187
 
    (! -w $target ) &&
188
 
      die "Error: delete failed: $target not writeable ($package, $component, $lineno).  Exiting...\n";
189
 
    ($debug >= 4) && print " rmtree($target)\n";
190
 
    rmtree ($target, 0, 0) ||
191
 
      die "Error: rmtree() failed: $!.  Exiting...\n";
192
 
  } else {
193
 
    warn "Warning: delete failed: $target is not a file or directory ($package, $component, $lineno).\n";
194
 
  }
195
 
}
196
 
 
197
 
 
198
 
#
199
 
# Copy an individual file from the srcdir to the destdir.
200
 
#
201
 
# This is called by both the individual and batch/recursive copy routines,
202
 
# using $dirflag to check if called from do_copydir.  Batch copy can pass in
203
 
# directories, so be sure to check first and break if it isn't a file.
204
 
#
205
 
sub do_copyfile
206
 
{
207
 
  my ($destpath)     = "";  # destination directory path
208
 
  my ($destpathcomp) = "";  # ditto, but possibly including component dir
209
 
  my ($destname)     = "";  # destination file name
210
 
  my ($destsuffix)   = "";  # destination file name suffix
211
 
  my ($altpath)      = "";  # alternate destination directory path
212
 
  my ($altname)      = "";  # alternate destination file name
213
 
  my ($altsuffix)    = "";  # alternate destination file name suffix
214
 
  my ($srcpath)      = "";  # source file directory path
215
 
  my ($srcname)      = "";  # source file name
216
 
  my ($srcsuffix)    = "";  # source file name suffix
217
 
  
218
 
  ($debug >= 2) && print "do_copyfile():\n";
219
 
  ($debug >= 10) && print " cwd: " . getcwd() . "\n";
220
 
 
221
 
  # set srcname correctly depending on how called
222
 
  if ( $dirflag ) {
223
 
    ($srcname, $srcpath, $srcsuffix) = fileparse("$File::Find::name", '\..*?$');
224
 
  } else {
225
 
    ($srcname, $srcpath, $srcsuffix) = fileparse("$srcdir/$line", '\..*?$');
226
 
  }
227
 
 
228
 
  ($debug >= 4) && print " fileparse(src): '$srcpath $srcname $srcsuffix'\n";
229
 
 
230
 
  # return if srcname is a directory from do_copydir
231
 
  if ( -d "$srcpath$srcname$srcsuffix" ) {
232
 
    ($debug >= 10) && print " return: '$srcpath$srcname$srcsuffix' is a directory\n";
233
 
    return;
234
 
  }
235
 
  else {
236
 
    ($debug >= 10) && print " '$srcpath$srcname$srcsuffix' is not a directory\n";
237
 
  }
238
 
 
239
 
  # set the destination path, if alternate destination given, use it.
240
 
  if ($flat) {
241
 
    # WebappRuntime has manifests that shouldn't be flattened, even though it
242
 
    # gets packaged with Firefox, which does get flattened, so special-case it.
243
 
    if ($srcsuffix eq ".manifest" && $srcpath =~ m'/(chrome|components)/$' &&
244
 
        $component ne "WebappRuntime") {
245
 
      my $subdir = $1;
246
 
      if ($component eq "") {
247
 
        die ("Manifest file was not part of a component.");
248
 
      }
249
 
 
250
 
      $destpathcomp = "$srcdir/manifests/$component/$subdir";
251
 
      $altdest = "$srcname$srcsuffix";
252
 
    }
253
 
    elsif ($srcsuffix eq ".xpt" && $srcpath =~ m|/components/$|) {
254
 
      if ($component eq "") {
255
 
        die ("XPT file was not part of a component.");
256
 
      }
257
 
 
258
 
      $destpathcomp = "$srcdir/xpt/$component/components";
259
 
      $altdest = "$srcname$srcsuffix";
260
 
    }
261
 
    else {
262
 
      $destpathcomp = "$destdir";
263
 
    }
264
 
  } else {
265
 
    if ( $component ne "" ) {
266
 
      $destpathcomp = "$destdir/$component";
267
 
    }
268
 
    else {
269
 
      $destpathcomp = "$destdir";
270
 
    }
271
 
  }
272
 
  if ( $altdest ne "" ) {
273
 
    if ( $dirflag ) { # directory copy to altdest
274
 
      ($destname, $destpath, $destsuffix) = fileparse("$destpathcomp/$altdest/$File::Find::name", '\..*?$');
275
 
      # Todo: add MSDOS hack
276
 
      $destpath =~ s|\Q$srcdir\E/$line/||;  # rm info added by find
277
 
      ($debug >= 5) &&
278
 
        print " dir copy to altdest: $destpath $destname $destsuffix\n";
279
 
    } else {  # single file copy to altdest
280
 
      ($destname, $destpath, $destsuffix) = fileparse("$destpathcomp/$altdest", '\..*?$');
281
 
      ($debug >= 5) &&
282
 
        print " file copy to altdest: $destpath $destname $destsuffix\n";
283
 
    }
284
 
  } else {
285
 
    if ( $dirflag ) { # directory copy, no altdest
286
 
      my $destfile = $File::Find::name;
287
 
      if ($os eq "MSDOS") {
288
 
        $destfile =~ s|\\|/|;
289
 
      }
290
 
      $destfile =~ s|\Q$srcdir\E/||;
291
 
 
292
 
      ($destname, $destpath, $destsuffix) = fileparse("$destpathcomp/$destfile", '\..*?$');
293
 
 
294
 
      ($debug >= 5) &&
295
 
        print " dir copy w/o altdest: $destpath $destname $destsuffix\n";
296
 
    } else {  # single file copy, no altdest
297
 
      ($destname, $destpath, $destsuffix) = fileparse("$destpathcomp/$line", '\..*?$');
298
 
      ($debug >= 5) &&
299
 
        print " file copy w/o altdest: $destpath $destname $destsuffix\n";
300
 
    }
301
 
  }
302
 
 
303
 
  if ($flat) {
304
 
    $destpath =~ s|bin[/\\]||;
305
 
  }
306
 
 
307
 
  # create the destination path if it doesn't exist
308
 
  if (! -d "$destpath" ) {
309
 
    ($debug >= 5) && print " mkpath($destpath)\n";
310
 
    # For OS/2 - remove trailing '/'
311
 
    chop($destpath);
312
 
    mkpath ($destpath, 0, 0755) ||
313
 
      die "Error: mkpath() failed: $!.  Exiting...\n";
314
 
    # Put delimiter back for copying...
315
 
    $destpath = "$destpath/"; 
316
 
  }
317
 
 
318
 
  # path exists, source and destination known, time to copy
319
 
  if ((-f "$srcpath$srcname$srcsuffix") && (-r "$srcpath$srcname$srcsuffix")) {
320
 
    if ( $debug >= 1 ) {
321
 
      if ( $dirflag ) {
322
 
        print "$destname$destsuffix\n"; # from unglob
323
 
      } else {
324
 
        print "$line\n";    # from single file
325
 
      }
326
 
      if ( $debug >= 3 ) {
327
 
        print " copy\t$srcpath$srcname$srcsuffix =>\n\t\t$destpath$destname$destsuffix\n";
328
 
      }
329
 
    }
330
 
 
331
 
    if (stat("$destpath$destname$destsuffix") &&
332
 
        stat("$srcpath$srcname$srcsuffix")->mtime < stat("$destpath$destname$destsuffix")->mtime) {
333
 
      if ( $debug >= 3 ) {
334
 
        print "source file older than destination, do not copy\n";
335
 
      }
336
 
      return;
337
 
    }
338
 
 
339
 
    unlink("$destpath$destname$destsuffix") if ( -e "$destpath$destname$destsuffix");
340
 
    # If source is a symbolic link pointing in the same directory, create a
341
 
    # symbolic link
342
 
    if ((-l "$srcpath$srcname$srcsuffix") && (readlink("$srcpath$srcname$srcsuffix") !~ /\//)) {
343
 
      symlink(readlink("$srcpath$srcname$srcsuffix"), "$destpath$destname$destsuffix") ||
344
 
        die "Error: copy of symbolic link $srcpath$srcname$srcsuffix failed ($package, $component, $lineno): $!.  Exiting...\n";
345
 
      return;
346
 
    }
347
 
    copy ("$srcpath$srcname$srcsuffix", "$destpath$destname$destsuffix") ||
348
 
      die "Error: copy of file $srcpath$srcname$srcsuffix failed ($package, $component, $lineno): $!.  Exiting...\n";
349
 
 
350
 
    # if this is unix, set the dest file permissions
351
 
    # read permissions
352
 
    my($st) = stat("$srcpath$srcname$srcsuffix") ||
353
 
        die "Error: can't stat $srcpath$srcname$srcsuffix: $!  Exiting...\n";
354
 
    # set permissions
355
 
    ($debug >= 2) && print " chmod ".$st->mode." $destpath$destname$destsuffix\n";
356
 
    chmod ($st->mode, "$destpath$destname$destsuffix") ||
357
 
        warn "Warning: chmod of $destpath$destname$destsuffix failed: $!.  Exiting...\n";
358
 
      } else {
359
 
    warn "Error: file $srcpath$srcname$srcsuffix is not a file or is not readable ($package, $component, $lineno).\n";
360
 
      }
361
 
}
362
 
 
363
 
 
364
 
#
365
 
# Expand any wildcards and copy files and/or directories
366
 
#
367
 
# todo: pass individual files to do_copyfile, not do_copydir
368
 
#
369
 
sub do_wildcard
370
 
{
371
 
  my ($entry) = $_[0];
372
 
  my (@list)  = ();
373
 
  my ($item)  = "";
374
 
 
375
 
  ($debug >= 2) && print "do_wildcard():\n";
376
 
 
377
 
  if ( $entry =~ /(?:\*|\?)/ ) {    # it's a wildcard,
378
 
    @list = glob($entry);     # expand it
379
 
    ($debug >= 4) && print " glob: $entry => @list\n";
380
 
 
381
 
    foreach $item ( @list ) {     # now copy each item in list
382
 
      if ( -f $item ) {
383
 
        ($debug >= 10) && print " do_copyfile: $item\n";
384
 
 
385
 
        # glob adds full path to item like find() in copydir so
386
 
        # take advantage of existing code in copyfile by using
387
 
        # $dirflag and $File::Find::name.
388
 
 
389
 
        $File::Find::name = $item;
390
 
        $dirflag = 1;
391
 
        do_copyfile();
392
 
        $dirflag = 0;
393
 
        $File::Find::name = "";
394
 
      } elsif ( -d $item ) {
395
 
        ($debug >= 10) && print " do_copydir($item)\n";
396
 
        do_copydir ($item);
397
 
      } else {
398
 
        warn "Warning: $item is not a file or directory ($package, $component, $lineno).  Skipped...\n";
399
 
      }
400
 
    }
401
 
  }
402
 
}
403
 
 
404
 
#
405
 
# Recursively copy directories specified.
406
 
#
407
 
sub do_copydir
408
 
{
409
 
  my ($entry) = $_[0];
410
 
 
411
 
  $dirflag = 1;     # flag indicating directory copy in progress
412
 
 
413
 
  ($debug >= 2) && print "do_copydir():\n";
414
 
 
415
 
  if (! -d "$entry" ) {
416
 
    warn "Warning: $entry is not a directory ($package, $component, $lineno).  Skipped...\n";
417
 
  }
418
 
 
419
 
  ($debug >= 4) && print " find($entry)\n";
420
 
 
421
 
  find (\&do_copyfile, $entry);
422
 
 
423
 
  $dirflag = 0;
424
 
}
425
 
 
426
 
 
427
 
#
428
 
# Handle new component
429
 
#
430
 
sub do_component
431
 
{
432
 
  ($debug >= 2) && print "do_component():\n";
433
 
 
434
 
  ( $component =~ /^\[.*(?:\s|\[|\])+.*\]/ ) && # no brackets or ws
435
 
    die "Error: malformed component $component.  Exiting...\n";
436
 
  $component =~ s/^\[(.*)\]/$1/;  # strip []
437
 
 
438
 
  if ( $components ne "") {
439
 
    if ( $components =~ /$component/ ) {
440
 
      ($debug >= 10) && print "Component $component is in $components.\n";
441
 
    } else {
442
 
      ($debug >= 10) && print "Component $component not in $components.\n";
443
 
      $component = "";
444
 
      return;   # named specific components and this isn't it
445
 
    }
446
 
  }
447
 
 
448
 
  if ($debug >= 1) {
449
 
    print "[$component]\n";
450
 
  }
451
 
  # create component directory
452
 
  if (!$flat) {
453
 
    if ( -d "$destdir/$component" ) {
454
 
      warn "Warning: component directory \"$component\" already exists in \"$destdir\".\n";
455
 
    } else {
456
 
      ($debug >= 4) && print " mkdir $destdir/$component\n";
457
 
      mkdir ("$destdir/$component", 0755) ||
458
 
        die "Error: couldn't create component directory \"$component\": $!.  Exiting...\n";
459
 
    }
460
 
  }
461
 
}
462
 
 
463
 
#
464
 
# Print error (and die later) or warn, based on whether $fatal_warnings is set.
465
 
#
466
 
sub delayed_die_or_warn
467
 
{
468
 
  my ($msg) = $_[0];
469
 
 
470
 
  if ($fatal_warnings) {
471
 
    warn "Error: $msg\n";
472
 
    $delayed_error = 1;
473
 
  } else {
474
 
    warn "Warning: $msg\n";
475
 
  }
476
 
}
477
 
 
478
 
#
479
 
# Check that arguments to script are valid.
480
 
#
481
 
sub check_arguments
482
 
{
483
 
  my ($exitval) = 0;
484
 
 
485
 
  ($debug >= 2) && print "check_arguments():\n";
486
 
 
487
 
  # if --help print usage
488
 
  if ($help) {
489
 
    print_usage();
490
 
    exit (1);
491
 
  }
492
 
 
493
 
  # make sure required variables are set:
494
 
  # check source directory
495
 
  if ( $srcdir eq "" ) {
496
 
    print "Error: source directory (--source) not specified.\n";
497
 
    $exitval += 8;
498
 
  } elsif ((! -d $srcdir) || (! -r $srcdir)) {
499
 
    print "Error: source directory \"$srcdir\" is not a directory or is unreadable.\n";
500
 
    $exitval = 1;
501
 
  }
502
 
 
503
 
  # check destination directory
504
 
  if ( $destdir eq "" ) {
505
 
    print "Error: destination directory (--destination) not specified.\n";
506
 
    $exitval += 8;
507
 
  } elsif ((! -d $destdir) || (! -w $destdir)) {
508
 
    print "Error: destination directory \"$destdir\" is not a directory or is not writeable.\n";
509
 
    $exitval += 2;
510
 
  }
511
 
 
512
 
  # check destdir not a subdir of srcdir
513
 
  # hack - workaround for bug 14558 that should be fixed eventually.
514
 
  if (0) {  # todo - write test
515
 
    print "Error: destination directory must not be subdirectory of the source directory.\n";
516
 
    $exitval += 32;
517
 
  }
518
 
 
519
 
  # check package file
520
 
  if ( $package eq "" ) {
521
 
    print "Error: package file (--file) not specified.\n";
522
 
    $exitval += 8;
523
 
  } elsif (!(-f $package) || !(-r $package)) {
524
 
    print "Error: package file \"$package\" is not a file or is unreadable.\n";
525
 
    $exitval += 4;
526
 
  }
527
 
 
528
 
  # check OS == {unix|dos}
529
 
  if ($os eq "") {
530
 
    print "Error: OS type (--os) not specified.\n";
531
 
    $exitval += 8;
532
 
  } elsif ( $os =~ /dos/i ) {
533
 
    $os = "MSDOS";
534
 
    fileparse_set_fstype ($os);
535
 
  } elsif ( $os =~ /unix/i ) {
536
 
    $os = "Unix";       # can be anything but MSDOS
537
 
    fileparse_set_fstype ($os);
538
 
  } else {
539
 
    print "Error: OS type \"$os\" unknown.\n";
540
 
    $exitval += 16;
541
 
  }
542
 
 
543
 
  # turn components array into a string for regexp
544
 
  if ( @components > 0 ) {
545
 
    $components = join (",",@components);
546
 
  } else {
547
 
    $components = "";
548
 
  }
549
 
 
550
 
  if ($debug > 4) {
551
 
    print ("source dir:\t$srcdir\ndest dir:\t$destdir\npackage:\t$package\nOS:\t$os\ncomponents:\t$components\n");
552
 
  }
553
 
 
554
 
  if ($exitval) {
555
 
    print "See \'$0 --help\' for more information.\n";
556
 
    print "Exiting...\n";
557
 
    exit ($exitval);
558
 
  }
559
 
 
560
 
}
561
 
 
562
 
 
563
 
 
564
 
#
565
 
# display usage information
566
 
#
567
 
sub print_usage
568
 
{
569
 
  ($debug >= 2) && print "print_usage():\n";
570
 
 
571
 
  print <<EOC
572
 
 
573
 
$0
574
 
  Copy files from the source directory to component directories
575
 
  in the destination directory as specified by the package file.
576
 
 
577
 
Options:
578
 
  -s, --source <source directory>
579
 
    Specifies the directory from which to copy the files
580
 
    specified in the file passed via --file.
581
 
    Required.
582
 
 
583
 
  -d, --destination <destination directory>
584
 
    Specifies the directory in which to create the component
585
 
    directories and copy the files specified in the file passed
586
 
    via --file.
587
 
    Required.
588
 
 
589
 
NOTE: Source and destination directories must be absolute paths.
590
 
  Relative paths will NOT work.  Also, the destination directory
591
 
  must NOT be a subdirectory of the source directory.
592
 
 
593
 
  -f, --file <package file>
594
 
    Specifies the file listing the components to be created in
595
 
    the destination directory and the files to copy from the
596
 
    source directory to each component directory in the
597
 
    destination directory.
598
 
    Required.
599
 
 
600
 
  -o, --os [dos|unix]
601
 
    Specifies which type of system this is.  Used for parsing
602
 
    file specifications from the package file.
603
 
    Required.
604
 
 
605
 
  -c, --component <component name>
606
 
    Specifies a specific component in the package file to copy
607
 
    rather than copying all the components in the package file.
608
 
    Can be used more than once for multiple components (e.g.
609
 
    "-c browser -c mail" to copy mail and news only).
610
 
    Optional.
611
 
 
612
 
  -l, --flat
613
 
                Suppresses creation of components dirs, but stuffes everything
614
 
                directly into the package destination dir. This is useful
615
 
                for creating tarballs.
616
 
 
617
 
  -h, --help
618
 
    Prints this information.
619
 
    Optional.
620
 
 
621
 
  --debug [1-10]
622
 
    Controls verbosity of debugging output, 10 being most verbose.
623
 
      1 : same as --verbose.
624
 
      2 : includes function calls.
625
 
      3 : includes source and destination for each copy.
626
 
    Optional.
627
 
 
628
 
  -v, --verbose
629
 
    Print component names and files copied/deleted.
630
 
    Optional. 
631
 
 
632
 
 
633
 
e.g.
634
 
 
635
 
$0 --os unix --source /builds/mozilla/dist --destination /h/lithium/install --file packages-win --os unix --verbose
636
 
 
637
 
Note: options can be specified by either a leading '--' or '-'.
638
 
 
639
 
EOC
640
 
}