Subversion Repositories DevTools

Rev

Rev 5105 | Rev 5654 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1119 dpurdie 1
########################################################################
2
# Copyright (C) 2007 ERG Limited, All rights reserved
3
#
4
# Module name   : jats.sh
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s): jats
8
#
9
# Description   : This package extends the JATS toolset at build time
10
#                 It provides additional directives to the JATS makefiles
11
#                 to simplify the directives.
12
#
13
#                 This directive does all its work at 'build' time
14
#                 It uses makefile.pl directives
15
#
16
# Operation     : This package adds the JATS directive ManifestFiles
17
#                 This is used to create linux manifest files
18
#
19
# Syntax        : ManifestFiles (<platforms>, Options+);
20
#                 See the function header for details
21
#
22
#......................................................................#
23
 
24
require 5.6.1;
25
use strict;
26
use warnings;
5649 dpurdie 27
use Digest::file qw(digest_file_hex);
1119 dpurdie 28
 
29
#
30
#   Globals
31
#
32
my @Manifests;                      # Manifest entries
1125 alewis 33
my $Manifest_has_version = 1;       # Create Manifest_xxxx by default
1121 dpurdie 34
my %package_dirs;                   # Package dirs discovered and used
1125 alewis 35
my $pkg_subdir;                     # Alternate packaging
1119 dpurdie 36
 
37
#-------------------------------------------------------------------------------
38
# Function        : BEGIN
39
#
40
# Description     : Setup directive hooks
41
#                   Register a function to be called just before we start to
42
#                   generate makefiles. This will be used to process the data
43
#                   collected in all the ManifestFiles directives
44
#
45
# Inputs          : None
46
#
47
# Returns         : None
48
#
49
BEGIN
50
{
51
    RegisterMakefileGenerate (\&ManifestFiles_Generate);
52
}
53
 
54
#-------------------------------------------------------------------------------
55
# Function        : ManifestFiles
56
#
57
# Description     : Create a ManifestFiles entry
58
#
59
# Inputs          : Platform             - Active Platform Selector
60
#                   Options              - One or more options
61
#                       --Name=Name             - Mandatory
62
#                       --Tier=Name             - Mandatory
63
#                       --Architecture=xxxx     - Default actitecture is the current target
64
#                       --Product=yyyy          - Product Family
65
#                       --Debian=BaseName[,--Prod,--Debug,--Arch=xxxx,--Product=yyyy]
66
#                       --MugPackage=Package[,--Subdir=subdir[,subdir]+]
67
#                       --SrcFile=xxx
1125 alewis 68
#                       --SrcFileNoCopy=xxx
1123 dpurdie 69
#                       --Comment=xxx           - Add comment to Manifst
1125 alewis 70
#                       --NoManifestVersion     - Create unversioned Manifest File
71
#                       --PkgSubdir=xxx         - Specifies packaging subdir
5105 dpurdie 72
#                       --ImportManifest=Package[,--Subdir=subdir,--ReWrite] - Import Manifest from package
5649 dpurdie 73
#                       --Md5                   - Add MD5 checksums to the Manifest File
1119 dpurdie 74
#
75
# Returns         : Nothing
76
#
77
sub ManifestFiles
78
{
79
    my( $platforms, @elements ) = @_;
80
    Debug2( "ManifestFiles($platforms, @elements)" );
81
    return if ( ! ActivePlatform($platforms) );
82
 
83
    my $name;
84
    my $tier;
85
    my @files;
86
    my $mug_dir;
87
    my $default_arch = $::ScmPlatform;
88
    my $default_prod = '';
1129 dpurdie 89
    my $imported_manifest = 0;
5649 dpurdie 90
    my $include_md5 = 0;
1119 dpurdie 91
 
92
    #
93
    #   Collect user options
94
    #
95
    foreach ( @elements )
96
    {
97
        if ( m~^--Name=(.+)~ ) {
98
            if ( $name )
99
            {
100
                ReportError ("ManifestFiles:--Name option is only allowed once");
101
                next;
102
            }
103
            $name = $1;
104
 
105
        } elsif ( m~^--Tier=(.+)~ ) {
106
            if ( $tier )
107
            {
108
                ReportError ("ManifestFiles:--Tier option is only allowed once");
109
                next;
110
            }
111
            $tier = $1;
112
 
1123 dpurdie 113
        } elsif ( m~^--Comment=~ ) {
114
            my $cmt = $_;
115
            $cmt =~ s~.+=~~;
116
            $cmt =~ s~\s*\n\s*~\n~g;
117
            push @files, {'cmt' => $cmt };
118
 
1119 dpurdie 119
        } elsif ( m~^--Debian=(.+)~ ) {
1123 dpurdie 120
            push @files, {'file' => LocateDebianFile($1, $default_arch, $default_prod)};
1119 dpurdie 121
 
122
        } elsif ( m~^--SrcFile=(.+)~ ) {
1123 dpurdie 123
            push @files, {'file' => LocatePreReq($1)};
5649 dpurdie 124
 
1125 alewis 125
        } elsif ( m~^--SrcFileNoCopy=(.+)~ ) {
126
            push @files, {'filenocopy' => $1};
5649 dpurdie 127
 
1119 dpurdie 128
        } elsif ( m~^--MugPackage=(.+)~ ) {
129
            if ( $mug_dir )
130
            {
131
                ReportError ("ManifestFiles:--MugPackage option is only allowed once");
132
                next;
5649 dpurdie 133
            }
1119 dpurdie 134
            $mug_dir = LocateMugDir($1);
135
 
136
        } elsif ( m/^--Arch(.*)=(.+)/ ) {
137
            $default_arch = $2;
138
 
139
        } elsif ( m/^--Product=(.+)/ ) {
140
            $default_prod = $1;
141
 
1125 alewis 142
        } elsif ( m/^--NoManifestVersion/i ) {
143
            $Manifest_has_version = 0;
144
 
145
        } elsif ( m/^--PkgSubdir=(.+)/i ) {
146
            if ( $pkg_subdir )
147
            {
1129 dpurdie 148
                ReportError ("ManifestFiles:--PkgSubdir option is only allowed once");
1125 alewis 149
                next;
150
            }
151
            $pkg_subdir = $1;
152
 
1129 dpurdie 153
        } elsif ( m/^--ImportManifest=(.+)/i ) {
5105 dpurdie 154
            my $import_info = ImportManifest($1, $tier, $name);
1129 dpurdie 155
#DebugDumpData("ImportInfo", $import_info );
156
            push @files, {'manifest' => $import_info };
157
 
158
            #
159
            #   Fill in details unless already provided
160
            #
161
            $tier = $import_info->{'tier'} unless ( defined $tier );
162
            $name = $import_info->{'name'} unless ( defined $name );
163
            $imported_manifest = 1;
164
 
5649 dpurdie 165
        } elsif (m/^--Md5/i) {
166
            $include_md5 = 1
167
 
1119 dpurdie 168
        } else {
169
            ReportError ("ManifestFiles: Unknown option or argument: $_");
170
 
171
        }
172
    }
173
 
174
    #
175
    #   Sanity test the user options
176
    #
177
    ReportError ("ManifestFiles: No name specified")
178
        unless $name;
179
    ReportError ("ManifestFiles: No tier specified")
1129 dpurdie 180
        unless defined ($tier);
1119 dpurdie 181
    ReportError ("ManifestFiles: Cannot mix --Debian/--SrcFile with --MugPackage in one directive")
1129 dpurdie 182
        if ( $mug_dir && (@files || $imported_manifest) );
1119 dpurdie 183
    ReportError ("ManifestFiles: Must specify files to add to Manifest")
1129 dpurdie 184
        unless ( $mug_dir ||  @files || $imported_manifest);
1119 dpurdie 185
    ErrorDoExit();
186
 
187
    #
188
    #   Save information for processing at the end of the parsing phase
189
    #   Data collected from ALL the ManifestFiles directives will be collected
190
    #   and processed into one Manifest file
191
    #
192
    my %data;
193
    $data{tier} = $tier;
194
    $data{name} = $name;
195
    $data{files} = \@files;
196
    $data{mugdir} = $mug_dir;
1125 alewis 197
    $data{pkgsubdir} = $pkg_subdir;
5649 dpurdie 198
    $data{md5} = $include_md5;
1129 dpurdie 199
#DebugDumpData("DirectiveData", \%data );
1119 dpurdie 200
 
201
    push @Manifests, \%data;
202
    return;
203
 
204
    #-------------------------------------------------------------------------------
205
    # Function        : LocateDebianFile
206
    #
207
    # Description     : Locate a debian file
208
    #                   Internal Function
209
    #
210
    #                   Scan packages for the Debian package specified
211
    #                   The user provides the base name of the package
212
    #                   A Debian Package name has several fields
213
    #                   These are:
214
    #                       1) Base Name - Provided by the user
215
    #                       2) Version - Version will be wildcarded
216
    #                       3) Architecture - Wildcarded. Uses bin/arch directory
5649 dpurdie 217
    #
1119 dpurdie 218
    #                   Expect to find Debian Packages in the bin/PLATFORM subdir
219
    #
220
    # Inputs          : Debian base name, complete with suboptions
221
    #
222
    # Returns         : Full path of the file
223
    #
224
    sub LocateDebianFile
225
    {
226
        my ($arg, $arch, $product) = @_;
227
        Verbose("LocateDebianFile: Processing: $arg");
228
 
229
        my @type = qw( P D );
230
        my @debian_file_path;
5649 dpurdie 231
 
1119 dpurdie 232
        #
233
        #   Extract sub-options
234
        #       --Prod[uction]
235
        #       --Debug
236
        #       --Arch[itecture]=yyy
237
        #
238
        my ($base_name, @opts) = split( ',', $arg );
239
        foreach ( @opts )
240
        {
241
            if ( m/^--Arch(.*)=(.+)/ ) {
242
                $arch=$2;
243
            } elsif ( m/^--Product=(.+)/ ) {
244
                $product=$1;
245
            } elsif ( m/^--Prod/ ) {
246
                @type = 'P';
247
            } elsif ( m/^--Debug/ ) {
248
                @type = 'D';
249
            }
250
        }
251
 
252
        #
253
        #   Create a list of products
254
        #   ie: PRODUCT_ARCH
255
        #
256
        my @products;
257
        push @products, $product . '_' . $arch if ( $product );
258
        push @products, $arch;
259
 
260
        #
261
        #   Scan all packages for the specified debian package
262
        #
263
        foreach my $package_dir ( getPackagePaths ('--All') )
264
        {
265
            foreach my $type ( @type )
266
            {
267
                foreach my $prd ( @products )
268
                {
269
                    foreach my $joiner ( qw(/ .) )
270
                    {
271
                        my $dir = "$package_dir/bin$joiner$prd$type";
272
                        Verbose("ManifestFiles: Search in $dir");
273
                        next unless ( -d $dir );
274
                        my @files = glob ( "$dir/${base_name}_*.deb" );
275
                        next unless ( @files );
276
                        push @debian_file_path, @files;
1121 dpurdie 277
                        $package_dirs{$package_dir}{used} = 1;
1119 dpurdie 278
                    }
279
                }
280
            }
281
        }
282
 
283
        ReportError ("Required Debain package not found: $base_name") unless @debian_file_path;
1121 dpurdie 284
        ReportError ("Multiple matching Debian Packages located: $base_name", @debian_file_path ) if ( $#debian_file_path > 0 );
1119 dpurdie 285
        return $debian_file_path[0];
286
    }
287
 
288
    #-------------------------------------------------------------------------------
289
    # Function        : LocateMugDir
290
    #
291
    # Description     : Locate the directory containing the mugfiles
292
    #                   Internal Function
293
    #
294
    # Inputs          : Mufile package, with embedded options
295
    #
296
    # Returns         : Full path
297
    #
298
    sub LocateMugDir
299
    {
300
        my ($mug_package) = @_;
301
 
302
        #
303
        #   Locate the mugfile subdir
304
        #
305
        my $package_name = $mug_package;
306
        my @dirs = 'mug';
307
        my $mug_dir;
308
 
309
        #
310
        #   Extract sub options
311
        #       --Subdir=xxxx,yyyy,zzzz
312
        #
313
        if ( $package_name =~ m/(.*?),--Subdir=(.*)/ )
314
        {
315
            $package_name = $1;
316
            @dirs = split( ',', $2 );
317
        }
318
 
319
        my $package = GetPackageEntry( $package_name );
320
        unless ( $package )
321
        {
322
            ReportError ("ManifestFiles: Package not known to build: $package_name");
323
            return undef;
324
        }
325
 
326
        foreach my $subdir ( @dirs )
327
        {
328
            my $dir = "$package->{'ROOT'}/$subdir";
329
            if ( -d $dir )
330
            {
331
                Warning ("Multiple Mugfile directories located. Only the first will be used",
332
                         "Ignoring: $subdir" )if ( $mug_dir );
333
                $mug_dir = $dir;
334
            }
335
        }
336
        ReportError ("Mugfile directory not found in package: $package_name")
337
            unless $mug_dir;
338
 
339
        return $mug_dir;
340
    }
1129 dpurdie 341
 
342
    #-------------------------------------------------------------------------------
343
    # Function        : ImportManifest
344
    #
345
    # Description     : Import an existing manifest
346
    #
5105 dpurdie 347
    # Inputs          : Args    - PackageName[,Subdir=name,--ReWrite]
348
    #                   tier    - May be null
349
    #                   name    - May be null
1129 dpurdie 350
    #
351
    # Returns         : A hash of data to be used later
352
    #
353
    sub ImportManifest
354
    {
5105 dpurdie 355
        my ($args, $tier, $name) = @_;
1129 dpurdie 356
        my @file_contents;
357
        my @file_list;
358
 
359
        #
360
        #   Locate the mugfile subdir
361
        #
362
        my $package_name = $args;
363
        my @dirs = 'mug';
364
        my $pkg_dir;
365
        my $pkg_root;
366
        my $manifest;
367
        my $first_tier;
368
        my $first_name;
5105 dpurdie 369
        my $rewrite;
1129 dpurdie 370
 
371
        #
372
        #   Extract sub options
373
        #       --Subdir=xxxx,yyyy,zzzz
5105 dpurdie 374
        #       --ReWrite
1129 dpurdie 375
        #
5105 dpurdie 376
        if ( $package_name =~ m/(.*?)(,.*)/ )
1129 dpurdie 377
        {
378
            $package_name = $1;
5105 dpurdie 379
            my @subargs = split(',--', $2);
380
            foreach ( @subargs)
381
            {
382
                next unless (length($_) > 0);
383
                if (m~^Subdir=(.*)~i){
384
                    @dirs = split( ',', $1 );
385
 
386
                } elsif (m~^ReWrite~i) {
387
                    $rewrite = 1;
388
 
389
                } else {
390
                    ReportError("ManifestFiles: Unknown suboption to ImportManifest:" . $_);
391
                }
392
            }
1129 dpurdie 393
        }
394
 
395
        my $package = GetPackageEntry( $package_name );
396
        unless ( $package )
397
        {
398
            ReportError ("ManifestFiles: Package not known to build: $package_name");
399
            return undef;
400
        }
401
 
5105 dpurdie 402
        if (defined ($rewrite) && ( !defined($tier) || !defined($name)))
403
        {
404
            ReportError ("ManifestFiles: ImportManifest. --ReWrite cannot be used unless tier and name are specified");
405
            return undef;
406
        }
407
 
1129 dpurdie 408
        foreach my $subdir ( @dirs )
409
        {
410
            my $dir = "$package->{'ROOT'}/$subdir";
411
            my $root = $package->{'ROOT'};
412
            if ( -d $dir )
413
            {
414
                Warning ("Multiple Package directories located. Only the first will be used",
415
                         "Ignoring: $subdir" )if ( $pkg_dir );
416
                $pkg_dir = $dir;
417
                $pkg_root = $root;
418
            }
419
        }
420
 
5105 dpurdie 421
        unless ($pkg_dir)
422
        {
423
            ReportError ("Package directory not found in package: $package_name");
424
            return undef;
425
        }
426
 
1129 dpurdie 427
        #
428
        #   Determine Manifest File name
429
        #
430
        foreach my $file ( glob ($pkg_dir . '/Manifest*' ) )
431
        {
432
                next unless ( -f $file );
433
                Warning ("Multiple Manifest Files find. Only the first will be used",
434
                         "Using: $manifest",
435
                         "Ignoring: $file" ) if ( $manifest );
436
                $manifest = $file;
437
        }
438
 
5105 dpurdie 439
        unless ($manifest)
440
        {
441
            ReportError ("ImportManifest. No Manifest found: $package_name");
442
            return undef;
443
        }
1129 dpurdie 444
 
5105 dpurdie 445
 
1129 dpurdie 446
        #
447
        #
5649 dpurdie 448
        #
1129 dpurdie 449
        open (MF, '<', $manifest ) || Error ("Cannot open the Manifest file: $manifest", $!);
450
        while ( <MF> )
451
        {
1131 dpurdie 452
            #
453
            #   Clean traling whitespace ( line-feed and new lines )
454
            #   Comment out [Version] data
455
            #
1129 dpurdie 456
            s~\s+$~~;
1131 dpurdie 457
            s~(\s*\[Version])~#$1~;
1129 dpurdie 458
 
459
            #
460
            #   Part lines and determine files
461
            #
462
            next unless ( $_ );
463
            next if ( m~\s*#~ );
464
            next if ( m~\s*\[~ );
465
            my( $aname, $atier, $afile) = split(/\s*\,\s*/, $_);
466
#            print "---------- $_\n";
467
#            print "T: $atier, N:$aname, F:$afile\n";
468
            push @file_list, $afile;
469
 
470
            #
5105 dpurdie 471
            #   Rewrite the name and tier
1129 dpurdie 472
            #
5105 dpurdie 473
            if ($rewrite)
474
            {
475
                $_ = join(',', $name, $tier, $afile);
476
                $first_tier = $tier;
477
                $first_name = $name;
478
            }
479
            else
480
            {
481
                #
482
                #   Capture first tier and name
483
                #
484
                $first_tier = $atier unless ( defined $first_tier );
485
                $first_name = $aname unless ( defined $first_name );
486
            }
1129 dpurdie 487
        }
5105 dpurdie 488
        continue
489
        {
490
            push @file_contents, $_;
491
        }
1129 dpurdie 492
        close MF;
493
 
494
        #
495
        #   Create a hash of data that describes the manifest that has
496
        #   just been read in.
497
        #
498
        $package_dirs{$pkg_root}{used} = 1;
499
        $manifest =~ s~.*/~~;
500
        return { 'contents' => \@file_contents,
501
                  'files' => \@file_list,
502
                  'file_base' => $pkg_dir,
503
                  'manifest' => $manifest,
504
                  'pkg_dir' => $pkg_root,
505
                  'tier' => $first_tier,
506
                  'name' => $first_name,
5105 dpurdie 507
                  'rewrite' => $rewrite,
1129 dpurdie 508
                };
509
    }
1119 dpurdie 510
}
511
 
512
#-------------------------------------------------------------------------------
513
# Function        : ManifestFiles_Generate
514
#
515
# Description     : Internal Function
516
#                   Process all the collected data and create directives
517
#                   for the creation of the manifest
518
#
519
#                   This function will be called, just before the Makefile
520
#                   is created. The function will:
521
#                       1) Create the Manifest File
522
#                       2) Package the Manifest File
523
#                       3) Package the manifest file contents
524
#
525
#                   using (mostly) normal makefile.pl directives.
526
#
527
# Inputs          : None
528
#
529
# Returns         : Nothing
530
#
531
sub ManifestFiles_Generate
532
{
533
    Debug ("ManifestFiles_Generate");
534
    Message ("Generating Manifest File");
1123 dpurdie 535
 
536
    #
537
    #   Need at least one Manifest Entry
538
    #
539
    return unless ( @Manifests );
1119 dpurdie 540
#DebugDumpData ( "Manifests", \@Manifests );
541
 
542
    #
1125 alewis 543
    #   Determine the target packaging directory
544
    #   Default is .../mug
545
    #
546
    my $pkgdir = 'mug';
1129 dpurdie 547
    if ( exists $Manifests[0]->{pkgsubdir} && defined $Manifests[0]->{pkgsubdir} )
1125 alewis 548
    {
549
        my $subdir = $Manifests[0]->{pkgsubdir};
550
        $pkgdir .= '/' . $subdir;
551
        $pkgdir =~ s~^mug/mug~mug~;
552
    }
553
 
554
    #
1119 dpurdie 555
    #   Create the Manifest File as we process the lists
1125 alewis 556
    #   Place this in the 'lib' directory:
1119 dpurdie 557
    #       - So that it will be deleted on clobber
1123 dpurdie 558
    #       - So that it can be placed in a target-specific subdir
1125 alewis 559
    #       - So that we can have one per makefile.pl
1119 dpurdie 560
    #
561
    Error ("ManifestFiles: Needs local directory specified in build.pl") unless ( $::ScmLocal );
562
 
1125 alewis 563
    my $manifest_dir = "$::ScmPlatform.LIB";
1119 dpurdie 564
    System( "$::GBE_BIN/mkdir -p $manifest_dir" );
565
 
1125 alewis 566
    my $manifest_file = $manifest_dir . '/Manifest';
567
    $manifest_file .= '_' . $::ScmBuildVersion if ( $Manifest_has_version );
568
    ToolsetGenerate( $manifest_file );
1119 dpurdie 569
    Verbose ("ManifestFiles_Generate: File: $manifest_file");
5649 dpurdie 570
 
1125 alewis 571
    PackageFile ('*', $manifest_file, '--Subdir=' . $pkgdir, '--Strip' );
1119 dpurdie 572
 
573
    open (MF, '>', $manifest_file ) || Error ("Cannot create the Manifest file: $manifest_file");
574
 
575
    print_mf ("# PackageName: $::ScmBuildPackage");
576
    print_mf ("# PackageVersion: $::ScmBuildVersion");
577
    print_mf ("# BuildDate: $::CurrentTime");
578
    print_mf ("#");
579
    print_mf ("[Version],$::ScmBuildVersion");
580
    print_mf ("#");
581
 
582
    #
1125 alewis 583
    #   Process each tier in the order presented in the source file
1119 dpurdie 584
    #
1123 dpurdie 585
    my $last_was_comment = 0;
1119 dpurdie 586
    foreach my $entry ( @Manifests )
587
    {
1127 alewis 588
    #print_mf ("#");
1119 dpurdie 589
 
590
#DebugDumpData ( "Manifest Entry", $entry );
591
 
592
        my $tier = $entry->{tier};
593
        my $name = $entry->{name};
5649 dpurdie 594
        my $include_md5 = $entry->{md5};
1119 dpurdie 595
 
596
        #
597
        #   Insert all the files that have been specified
598
        #   The user specified order is preserved
599
        #
1123 dpurdie 600
        #   Entries may be either a file or a comment
601
        #   Comments: Merge multiple comments and create blocks
602
        #
603
        #
1119 dpurdie 604
        my @files = @{ $entry->{files} };
1123 dpurdie 605
        foreach my $fentry ( @files )
1119 dpurdie 606
        {
1123 dpurdie 607
            if ( my $cmt = $fentry->{'cmt'} )
608
            {
609
                print_mf ('') unless ( $last_was_comment ) ;
610
                print_mf ( map (('# ' . $_) , split ("\n", $cmt) ));
611
                $last_was_comment = 1;
612
                next;
613
            }
614
 
615
            print_mf ('#') if ( $last_was_comment );
616
            if ( my $file = $fentry->{'file'} )
617
            {
618
                my $base_file = StripDir( $file );
5649 dpurdie 619
                if ($include_md5) {
620
                    my $md5 = digest_file_hex($file, 'MD5');
621
                    print_mf ('--NoCheckLineWidth', "$name,$tier,$base_file,$md5");
622
                } else {
623
                    print_mf ("$name,$tier,$base_file");
624
                }
1125 alewis 625
                PackageFile ('*', $file, '--Subdir=' . $pkgdir, '--Strip' );
1123 dpurdie 626
                $last_was_comment = 0;
627
            }
1125 alewis 628
 
629
            if ( my $file = $fentry->{'filenocopy'} )
630
            {
631
                print_mf ("$name,$tier,$file");
632
                $last_was_comment = 0;
633
            }
1129 dpurdie 634
 
635
            if ( my $emf = $fentry->{'manifest'} )
636
            {
637
                $last_was_comment = 0;
638
                #
639
                #   Insert the entire manifest
640
                #   Items are:
641
                #        contents
642
                #        files
643
                #        file_base
644
                #        manifest
645
                #
646
#DebugDumpData ( "Embedded Manifest Entry", $emf );
647
                print_mf ( '## Included Manifest: ' .  $emf->{'manifest'}  );
648
                print_mf ($_) foreach  ( @{$emf->{'contents'}} );
649
                PackageFile ('*', $emf->{'file_base'}. '/' . $_, '--Subdir=' . $pkgdir, '--Strip' )foreach  ( @{$emf->{'files'}});;
650
                print_mf ( '## End Included Manifest' );
651
            }
1119 dpurdie 652
        }
653
 
654
        #
655
        #   Expand out the entire MUG directory
656
        #   All .mug files in the MUG directory will be added to the manifest
657
        #   The assumption is that the MUG directory has been created by
658
        #   something that knows what its doing
659
        #
660
        if ( my $mugdir = $entry->{mugdir} )
661
        {
662
            foreach my $file ( glob ($mugdir . '/*.mug' ) )
663
            {
664
                next unless ( -f $file );
665
                my $base_file = StripDir($file);
666
                print_mf ("$name,$tier,$base_file");
667
                PackageFile ('*', $file, '--Subdir=mug', '--Strip' );
668
            }
669
        }
670
    }
671
 
672
    #
673
    #   Complete the creation of the Manifest File
674
    #
675
    print_mf ("#");
676
    print_mf ("# End of File");
677
    close MF;
678
    ErrorDoExit();
1121 dpurdie 679
 
680
    #
681
    #   Sanity test of packages that did not provide a debian file
682
    #   Just a hint that something may have been missed
683
    #
684
    my @not_used_packages;
685
    foreach my $package_dir ( getPackagePaths ('--All') )
686
    {
687
        next if ( $package_dir =~ m~/manifest-tool/~ );
688
        unless ( exists $package_dirs{$package_dir}{used} )
689
        {
690
            push @not_used_packages, $package_dir;
691
        }
692
    }
693
    if ( @not_used_packages )
694
    {
695
        Warning ("Packages that did not contribute packages to the manifest:",
696
                  @not_used_packages );
697
    }
698
 
1119 dpurdie 699
    return;
700
 
701
    #-------------------------------------------------------------------------------
702
    # Function        : print_mf
703
    #
704
    # Description     : Internal Function
705
    #                   Print one line to the Manifest File
706
    #                   Checks the length of the line being created
707
    #
708
    # Inputs          : $line
709
    #
5649 dpurdie 710
    # Returns         :
1119 dpurdie 711
    #
712
 
713
    sub print_mf
714
    {
5649 dpurdie 715
        my $check_line_width = 1;
716
 
717
        if ($_[0] eq '--NoCheckLineWidth')
718
        {
719
            shift @_;
720
            $check_line_width = 0;
721
        }
722
 
1119 dpurdie 723
        foreach  ( @_ )
724
        {
725
            ReportError ( "Manifest line too long",
5649 dpurdie 726
                    "Line: $_" ) if ( $check_line_width && length ($_) > 79);
1119 dpurdie 727
            print MF $_ . "\n";
728
        }
729
    }
730
}
731
 
732
1;