Subversion Repositories DevTools

Rev

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