Subversion Repositories DevTools

Rev

Rev 1127 | Rev 1131 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1127 Rev 1129
Line 66... Line 66...
66
#                       --SrcFile=xxx
66
#                       --SrcFile=xxx
67
#                       --SrcFileNoCopy=xxx
67
#                       --SrcFileNoCopy=xxx
68
#                       --Comment=xxx           - Add comment to Manifst
68
#                       --Comment=xxx           - Add comment to Manifst
69
#                       --NoManifestVersion     - Create unversioned Manifest File
69
#                       --NoManifestVersion     - Create unversioned Manifest File
70
#                       --PkgSubdir=xxx         - Specifies packaging subdir
70
#                       --PkgSubdir=xxx         - Specifies packaging subdir
-
 
71
#                       --ImportManifest=Package[,--Subdir=subdir] - Import Manifest from package
71
#
72
#
72
# Returns         : Nothing
73
# Returns         : Nothing
73
#
74
#
74
sub ManifestFiles
75
sub ManifestFiles
75
{
76
{
Line 81... Line 82...
81
    my $tier;
82
    my $tier;
82
    my @files;
83
    my @files;
83
    my $mug_dir;
84
    my $mug_dir;
84
    my $default_arch = $::ScmPlatform;
85
    my $default_arch = $::ScmPlatform;
85
    my $default_prod = '';
86
    my $default_prod = '';
-
 
87
    my $imported_manifest = 0;
86
 
88
 
87
    #
89
    #
88
    #   Collect user options
90
    #   Collect user options
89
    #
91
    #
90
    foreach ( @elements )
92
    foreach ( @elements )
Line 138... Line 140...
138
            $Manifest_has_version = 0;
140
            $Manifest_has_version = 0;
139
 
141
 
140
        } elsif ( m/^--PkgSubdir=(.+)/i ) {
142
        } elsif ( m/^--PkgSubdir=(.+)/i ) {
141
            if ( $pkg_subdir )
143
            if ( $pkg_subdir )
142
            {
144
            {
143
                ReportError ("ManifestFiles:--MugPackage option is only allowed once");
145
                ReportError ("ManifestFiles:--PkgSubdir option is only allowed once");
144
                next;
146
                next;
145
            }
147
            }
146
            $pkg_subdir = $1;
148
            $pkg_subdir = $1;
147
 
149
 
-
 
150
        } elsif ( m/^--ImportManifest=(.+)/i ) {
-
 
151
            my $import_info = ImportManifest($1);
-
 
152
#DebugDumpData("ImportInfo", $import_info );
-
 
153
            push @files, {'manifest' => $import_info };
-
 
154
 
-
 
155
            #
-
 
156
            #   Fill in details unless already provided
-
 
157
            #
-
 
158
            $tier = $import_info->{'tier'} unless ( defined $tier );
-
 
159
            $name = $import_info->{'name'} unless ( defined $name );
-
 
160
 
-
 
161
            $imported_manifest = 1;
-
 
162
 
148
        } else {
163
        } else {
149
            ReportError ("ManifestFiles: Unknown option or argument: $_");
164
            ReportError ("ManifestFiles: Unknown option or argument: $_");
150
 
165
 
151
        }
166
        }
152
    }
167
    }
Line 155... Line 170...
155
    #   Sanity test the user options
170
    #   Sanity test the user options
156
    #
171
    #
157
    ReportError ("ManifestFiles: No name specified")
172
    ReportError ("ManifestFiles: No name specified")
158
        unless $name;
173
        unless $name;
159
    ReportError ("ManifestFiles: No tier specified")
174
    ReportError ("ManifestFiles: No tier specified")
160
        unless $tier;
175
        unless defined ($tier);
161
    ReportError ("ManifestFiles: Cannot mix --Debian/--SrcFile with --MugPackage in one directive")
176
    ReportError ("ManifestFiles: Cannot mix --Debian/--SrcFile with --MugPackage in one directive")
162
        if ( $mug_dir &&  @files );
177
        if ( $mug_dir && (@files || $imported_manifest) );
163
    ReportError ("ManifestFiles: Must specify files to add to Manifest")
178
    ReportError ("ManifestFiles: Must specify files to add to Manifest")
164
        unless ( $mug_dir ||  @files );
179
        unless ( $mug_dir ||  @files || $imported_manifest);
165
    ErrorDoExit();
180
    ErrorDoExit();
166
 
181
 
167
    #
182
    #
168
    #   Save information for processing at the end of the parsing phase
183
    #   Save information for processing at the end of the parsing phase
169
    #   Data collected from ALL the ManifestFiles directives will be collected
184
    #   Data collected from ALL the ManifestFiles directives will be collected
Line 173... Line 188...
173
    $data{tier} = $tier;
188
    $data{tier} = $tier;
174
    $data{name} = $name;
189
    $data{name} = $name;
175
    $data{files} = \@files;
190
    $data{files} = \@files;
176
    $data{mugdir} = $mug_dir;
191
    $data{mugdir} = $mug_dir;
177
    $data{pkgsubdir} = $pkg_subdir;
192
    $data{pkgsubdir} = $pkg_subdir;
-
 
193
#DebugDumpData("DirectiveData", \%data );
178
 
194
 
179
    push @Manifests, \%data;
195
    push @Manifests, \%data;
180
    return;
196
    return;
181
 
197
 
182
    #-------------------------------------------------------------------------------
198
    #-------------------------------------------------------------------------------
Line 314... Line 330...
314
        ReportError ("Mugfile directory not found in package: $package_name")
330
        ReportError ("Mugfile directory not found in package: $package_name")
315
            unless $mug_dir;
331
            unless $mug_dir;
316
 
332
 
317
        return $mug_dir;
333
        return $mug_dir;
318
    }
334
    }
-
 
335
 
-
 
336
    #-------------------------------------------------------------------------------
-
 
337
    # Function        : ImportManifest
-
 
338
    #
-
 
339
    # Description     : Import an existing manifest
-
 
340
    #
-
 
341
    # Inputs          : Args
-
 
342
    #                           PackageName[,Subdir=name]
-
 
343
    #
-
 
344
    # Returns         : A hash of data to be used later
-
 
345
    #
-
 
346
    sub ImportManifest
-
 
347
    {
-
 
348
        my ($args) = @_;
-
 
349
        my @file_contents;
-
 
350
        my @file_list;
-
 
351
 
-
 
352
        #
-
 
353
        #   Locate the mugfile subdir
-
 
354
        #
-
 
355
        my $package_name = $args;
-
 
356
        my @dirs = 'mug';
-
 
357
        my $pkg_dir;
-
 
358
        my $pkg_root;
-
 
359
        my $manifest;
-
 
360
        my $first_tier;
-
 
361
        my $first_name;
-
 
362
 
-
 
363
        #
-
 
364
        #   Extract sub options
-
 
365
        #       --Subdir=xxxx,yyyy,zzzz
-
 
366
        #
-
 
367
        if ( $package_name =~ m/(.*?),--Subdir=(.*)/ )
-
 
368
        {
-
 
369
            $package_name = $1;
-
 
370
            @dirs = split( ',', $2 );
-
 
371
        }
-
 
372
 
-
 
373
        my $package = GetPackageEntry( $package_name );
-
 
374
        unless ( $package )
-
 
375
        {
-
 
376
            ReportError ("ManifestFiles: Package not known to build: $package_name");
-
 
377
            return undef;
-
 
378
        }
-
 
379
 
-
 
380
        foreach my $subdir ( @dirs )
-
 
381
        {
-
 
382
            my $dir = "$package->{'ROOT'}/$subdir";
-
 
383
            my $root = $package->{'ROOT'};
-
 
384
            if ( -d $dir )
-
 
385
            {
-
 
386
                Warning ("Multiple Package directories located. Only the first will be used",
-
 
387
                         "Ignoring: $subdir" )if ( $pkg_dir );
-
 
388
                $pkg_dir = $dir;
-
 
389
                $pkg_root = $root;
-
 
390
            }
-
 
391
        }
-
 
392
        ReportError ("Package directory not found in package: $package_name")
-
 
393
            unless $pkg_dir;
-
 
394
 
-
 
395
        #
-
 
396
        #   Determine Manifest File name
-
 
397
        #
-
 
398
        foreach my $file ( glob ($pkg_dir . '/Manifest*' ) )
-
 
399
        {
-
 
400
                next unless ( -f $file );
-
 
401
                Warning ("Multiple Manifest Files find. Only the first will be used",
-
 
402
                         "Using: $manifest",
-
 
403
                         "Ignoring: $file" ) if ( $manifest );
-
 
404
                $manifest = $file;
-
 
405
        }
-
 
406
        ReportError ("ImportManifest. No Manifest found: $package_name")
-
 
407
            unless $manifest;
-
 
408
 
-
 
409
 
-
 
410
        #
-
 
411
        #   
-
 
412
        #
-
 
413
        open (MF, '<', $manifest ) || Error ("Cannot open the Manifest file: $manifest", $!);
-
 
414
        while ( <MF> )
-
 
415
        {
-
 
416
            s~\s+$~~;
-
 
417
            push @file_contents, $_;
-
 
418
 
-
 
419
            #
-
 
420
            #   Part lines and determine files
-
 
421
            #
-
 
422
            next unless ( $_ );
-
 
423
            next if ( m~\s*#~ );
-
 
424
            next if ( m~\s*\[~ );
-
 
425
            my( $aname, $atier, $afile) = split(/\s*\,\s*/, $_);
-
 
426
#            print "---------- $_\n";
-
 
427
#            print "T: $atier, N:$aname, F:$afile\n";
-
 
428
            push @file_list, $afile;
-
 
429
 
-
 
430
            #
-
 
431
            #   Capture first tier and name
-
 
432
            #
-
 
433
            $first_tier = $atier unless ( defined $first_tier );
-
 
434
            $first_name = $aname unless ( defined $first_name );
-
 
435
 
-
 
436
        }
-
 
437
        close MF;
-
 
438
 
-
 
439
        #
-
 
440
        #   Create a hash of data that describes the manifest that has
-
 
441
        #   just been read in.
-
 
442
        #
-
 
443
        $package_dirs{$pkg_root}{used} = 1;
-
 
444
        $manifest =~ s~.*/~~;
-
 
445
        return { 'contents' => \@file_contents,
-
 
446
                  'files' => \@file_list,
-
 
447
                  'file_base' => $pkg_dir,
-
 
448
                  'manifest' => $manifest,
-
 
449
                  'pkg_dir' => $pkg_root,
-
 
450
                  'tier' => $first_tier,
-
 
451
                  'name' => $first_name,
-
 
452
                };
-
 
453
    }
319
}
454
}
320
 
455
 
321
#-------------------------------------------------------------------------------
456
#-------------------------------------------------------------------------------
322
# Function        : ManifestFiles_Generate
457
# Function        : ManifestFiles_Generate
323
#
458
#
Line 351... Line 486...
351
    #
486
    #
352
    #   Determine the target packaging directory
487
    #   Determine the target packaging directory
353
    #   Default is .../mug
488
    #   Default is .../mug
354
    #
489
    #
355
    my $pkgdir = 'mug';
490
    my $pkgdir = 'mug';
356
    if ( exists $Manifests[0]->{pkgsubdir} )
491
    if ( exists $Manifests[0]->{pkgsubdir} && defined $Manifests[0]->{pkgsubdir} )
357
    {
492
    {
358
        my $subdir = $Manifests[0]->{pkgsubdir};
493
        my $subdir = $Manifests[0]->{pkgsubdir};
359
        $pkgdir .= '/' . $subdir;
494
        $pkgdir .= '/' . $subdir;
360
        $pkgdir =~ s~^mug/mug~mug~;
495
        $pkgdir =~ s~^mug/mug~mug~;
361
    }
496
    }
Line 432... Line 567...
432
            if ( my $file = $fentry->{'filenocopy'} )
567
            if ( my $file = $fentry->{'filenocopy'} )
433
            {
568
            {
434
                print_mf ("$name,$tier,$file");
569
                print_mf ("$name,$tier,$file");
435
                $last_was_comment = 0;
570
                $last_was_comment = 0;
436
            }
571
            }
-
 
572
 
-
 
573
            if ( my $emf = $fentry->{'manifest'} )
-
 
574
            {
-
 
575
                $last_was_comment = 0;
-
 
576
                #
-
 
577
                #   Insert the entire manifest
-
 
578
                #   Items are:
-
 
579
                #        contents
-
 
580
                #        files
-
 
581
                #        file_base
-
 
582
                #        manifest
-
 
583
                #
-
 
584
#DebugDumpData ( "Embedded Manifest Entry", $emf );
-
 
585
                print_mf ( '## Included Manifest: ' .  $emf->{'manifest'}  );
-
 
586
                print_mf ($_) foreach  ( @{$emf->{'contents'}} );
-
 
587
                PackageFile ('*', $emf->{'file_base'}. '/' . $_, '--Subdir=' . $pkgdir, '--Strip' )foreach  ( @{$emf->{'files'}});;
-
 
588
                print_mf ( '## End Included Manifest' );
-
 
589
            }
437
        }
590
        }
438
 
591
 
439
        #
592
        #
440
        #   Expand out the entire MUG directory
593
        #   Expand out the entire MUG directory
441
        #   All .mug files in the MUG directory will be added to the manifest
594
        #   All .mug files in the MUG directory will be added to the manifest