Subversion Repositories DevTools

Rev

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

Rev 5873 Rev 6302
Line 1... Line 1...
1
########################################################################
1
########################################################################
2
# Copyright (C) 2007 ERG Limited, All rights reserved
2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
3
#
3
#
4
# Module name   : jats.sh
4
# Module name   : ManifestFiles.pm
5
# Module type   : Makefile system
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
-
 
7
# Environment(s): jats
6
# Environment(s): JATS Build System
8
# Documents     : MASS-00232 Format of the Linux App Upgrade Manifest File
7
# Documents     : MASS-00232 Format of the Linux App Upgrade Manifest File
9
#
8
#
10
# Description   : This package extends the JATS toolset at build time
9
# Description   : This package extends the JATS toolset at build time
11
#                 It provides additional directives to the JATS makefiles
10
#                 It provides additional directives to the JATS makefiles
12
#                 to simplify the directives.
11
#                 to simplify the directives.
Line 63... Line 62...
63
#                       --Name=Name             - Mandatory
62
#                       --Name=Name             - Mandatory
64
#                       --Tier=Name             - Mandatory
63
#                       --Tier=Name             - Mandatory
65
#                       --Architecture=xxxx     - Default actitecture is the current target
64
#                       --Architecture=xxxx     - Default actitecture is the current target
66
#                       --Product=yyyy          - Product Family
65
#                       --Product=yyyy          - Product Family
67
#                       --Debian=BaseName[,--Prod,--Debug,--Arch=xxxx,--Product=yyyy]
66
#                       --Debian=BaseName[,--Prod,--Debug,--Arch=xxxx,--Product=yyyy]
-
 
67
#                       --Apk=BaseName[,--Prod,--Debug,--Platform=pppp]
-
 
68
#                                                   Default platform = ANDROID
-
 
69
#                                                   Default type = Production
68
#                       --MugPackage=Package[,--Subdir=subdir[,subdir]+]
70
#                       --MugPackage=Package[,--Subdir=subdir[,subdir]+]
69
#                       --SrcFile=xxx
71
#                       --SrcFile=xxx
70
#                       --SrcFileNoCopy=xxx
72
#                       --SrcFileNoCopy=xxx
71
#                       --Comment=xxx           - Add comment to Manifst
73
#                       --Comment=xxx           - Add comment to Manifst
72
#                       --NoManifestVersion     - Create unversioned Manifest File
74
#                       --NoManifestVersion     - Create unversioned Manifest File
Line 102... Line 104...
102
    #   Collect user options
104
    #   Collect user options
103
    #
105
    #
104
    foreach ( @elements )
106
    foreach ( @elements )
105
    {
107
    {
106
        if ( m~^--Name=(.+)~ ) {
108
        if ( m~^--Name=(.+)~ ) {
107
            if ( $name )
109
            if ( $name ) {
108
            {
-
 
109
                ReportError ("ManifestFiles:--Name option is only allowed once");
110
                ReportError ("ManifestFiles:--Name option is only allowed once");
110
                next;
111
                next;
111
            }
112
            }
112
            $name = $1;
113
            $name = $1;
113
 
114
 
114
        } elsif ( m~^--Tier=(.+)~ ) {
115
        } elsif ( m~^--Tier=(.+)~ ) {
115
            if ( $tier )
116
            if ( $tier ) {
116
            {
-
 
117
                ReportError ("ManifestFiles:--Tier option is only allowed once");
117
                ReportError ("ManifestFiles:--Tier option is only allowed once");
118
                next;
118
                next;
119
            }
119
            }
120
            $tier = $1;
120
            $tier = $1;
121
 
121
 
Line 124... Line 124...
124
            $cmt =~ s~.+=~~;
124
            $cmt =~ s~.+=~~;
125
            $cmt =~ s~\s*\n\s*~\n~g;
125
            $cmt =~ s~\s*\n\s*~\n~g;
126
            push @files, {'cmt' => $cmt };
126
            push @files, {'cmt' => $cmt };
127
 
127
 
128
        } elsif ( m~^--Debian=(.+)~ ) {
128
        } elsif ( m~^--Debian=(.+)~ ) {
129
            push @files, {'file' => LocateDebianFile($1, $default_arch, $default_prod)};
129
            push @files, {'file' => _LocateDebianFile($1, $default_arch, $default_prod)};
-
 
130
 
-
 
131
        } elsif ( m~^--Apk=(.+)~ ) {
-
 
132
            push @files, {'file' => _LocateApkFile($1, $default_arch)};
130
 
133
 
131
        } elsif ( m~^--SrcFile=(.+)~ ) {
134
        } elsif ( m~^--SrcFile=(.+)~ ) {
132
            push @files, {'file' => LocatePreReq($1)};
135
            push @files, {'file' => LocatePreReq($1)};
133
 
136
 
134
        } elsif ( m~^--SrcFileNoCopy=(.+)~ ) {
137
        } elsif ( m~^--SrcFileNoCopy=(.+)~ ) {
135
            push @files, {'filenocopy' => $1};
138
            push @files, {'filenocopy' => $1};
136
 
139
 
137
        } elsif ( m~^--MugPackage=(.+)~ ) {
140
        } elsif ( m~^--MugPackage=(.+)~ ) {
138
            if ( $mug_dir )
141
            if ( $mug_dir ) {
139
            {
-
 
140
                ReportError ("ManifestFiles:--MugPackage option is only allowed once");
142
                ReportError ("ManifestFiles:--MugPackage option is only allowed once");
141
                next;
143
                next;
142
            }
144
            }
143
            $mug_dir = LocateMugDir($1);
145
            $mug_dir = _LocateMugDir($1);
144
 
146
 
145
        } elsif ( m/^--Arch(.*)=(.+)/ ) {
147
        } elsif ( m/^--Arch(.*)=(.+)/ ) {
146
            $default_arch = $2;
148
            $default_arch = $2;
147
 
149
 
148
        } elsif ( m/^--Product=(.+)/ ) {
150
        } elsif ( m/^--Product=(.+)/ ) {
Line 150... Line 152...
150
 
152
 
151
        } elsif ( m/^--NoManifestVersion/i ) {
153
        } elsif ( m/^--NoManifestVersion/i ) {
152
            $Manifest_has_version = 0;
154
            $Manifest_has_version = 0;
153
 
155
 
154
        } elsif ( m/^--PkgSubdir=(.+)/i ) {
156
        } elsif ( m/^--PkgSubdir=(.+)/i ) {
155
            if ( $pkg_subdir )
157
            if ( $pkg_subdir ) {
156
            {
-
 
157
                ReportError ("ManifestFiles:--PkgSubdir option is only allowed once");
158
                ReportError ("ManifestFiles:--PkgSubdir option is only allowed once");
158
                next;
159
                next;
159
            }
160
            }
160
            $pkg_subdir = $1;
161
            $pkg_subdir = $1;
161
 
162
 
162
        } elsif ( m/^--ImportManifest=(.+)/i ) {
163
        } elsif ( m/^--ImportManifest=(.+)/i ) {
163
            my $import_info = ImportManifest($1, $tier, $name);
164
            my $import_info = _ImportManifest($1, $tier, $name);
164
#DebugDumpData("ImportInfo", $import_info );
165
#DebugDumpData("ImportInfo", $import_info );
165
            push @files, {'manifest' => $import_info };
166
            push @files, {'manifest' => $import_info };
166
 
167
 
167
            #
168
            #
168
            #   Fill in details unless already provided
169
            #   Fill in details unless already provided
Line 192... Line 193...
192
    #
193
    #
193
    ReportError ("ManifestFiles: No name specified")
194
    ReportError ("ManifestFiles: No name specified")
194
        unless $name;
195
        unless $name;
195
    ReportError ("ManifestFiles: No tier specified")
196
    ReportError ("ManifestFiles: No tier specified")
196
        unless defined ($tier);
197
        unless defined ($tier);
197
    ReportError ("ManifestFiles: Cannot mix --Debian/--SrcFile with --MugPackage in one directive")
198
    ReportError ("ManifestFiles: Cannot mix --Debian/-Apk/--SrcFile with --MugPackage in one directive")
198
        if ( $mug_dir && (@files || $imported_manifest) );
199
        if ( $mug_dir && (@files || $imported_manifest) );
199
    ReportError ("ManifestFiles: Must specify files to add to Manifest")
200
    ReportError ("ManifestFiles: Must specify files to add to Manifest")
200
        unless ( $mug_dir ||  @files || $imported_manifest);
201
        unless ( $mug_dir ||  @files || $imported_manifest);
201
    ErrorDoExit();
202
    ErrorDoExit();
202
 
203
 
Line 218... Line 219...
218
 
219
 
219
#DebugDumpData("DirectiveData", \%data );
220
#DebugDumpData("DirectiveData", \%data );
220
 
221
 
221
    push @Manifests, \%data;
222
    push @Manifests, \%data;
222
    return;
223
    return;
-
 
224
}
-
 
225
 
-
 
226
#-------------------------------------------------------------------------------
-
 
227
# Function        : _LocateDebianFile
-
 
228
#
-
 
229
# Description     : Locate a debian file
-
 
230
#                   Internal Function
-
 
231
#
-
 
232
#                   Scan packages for the Debian package specified
-
 
233
#                   The user provides the base name of the package
-
 
234
#                   A Debian Package name has several fields
-
 
235
#                   These are:
-
 
236
#                       1) Base Name - Provided by the user
-
 
237
#                       2) Version - Version will be wildcarded
-
 
238
#                       3) Architecture - Wildcarded. Uses bin/arch directory
-
 
239
#
-
 
240
#                   Expect to find Debian Packages in the bin/PLATFORM subdir
-
 
241
#
-
 
242
# Inputs          : Debian base name, complete with suboptions
-
 
243
#
-
 
244
# Returns         : Full path of the file
-
 
245
#
-
 
246
sub _LocateDebianFile
-
 
247
{
-
 
248
    my ($arg, $arch, $product) = @_;
-
 
249
    Verbose("LocateDebianFile: Processing: $arg");
-
 
250
 
-
 
251
    my @type = qw( P D );
-
 
252
    my @debian_file_path;
223
 
253
 
224
    #-------------------------------------------------------------------------------
-
 
225
    # Function        : LocateDebianFile
-
 
226
    #
254
    #
227
    # Description     : Locate a debian file
255
    #   Extract sub-options
228
    #                   Internal Function
256
    #       --Prod[uction]
-
 
257
    #       --Debug
-
 
258
    #       --Arch[itecture]=yyy
-
 
259
    #       --Product=yyy
229
    #
260
    #
230
    #                   Scan packages for the Debian package specified
261
    my ($base_name, @opts) = split( ',', $arg );
-
 
262
    foreach ( @opts )
-
 
263
    {
231
    #                   The user provides the base name of the package
264
        if ( m/^--Arch(.*)=(.+)/ ) {
-
 
265
            $arch=$2;
232
    #                   A Debian Package name has several fields
266
        } elsif ( m/^--Product=(.+)/ ) {
233
    #                   These are:
267
            $product=$1;
234
    #                       1) Base Name - Provided by the user
268
        } elsif ( m/^--Prod/ ) {
-
 
269
            @type = 'P';
235
    #                       2) Version - Version will be wildcarded
270
        } elsif ( m/^--Debug/ ) {
-
 
271
            @type = 'D';
-
 
272
        } else {
236
    #                       3) Architecture - Wildcarded. Uses bin/arch directory
273
            Warning ('--Debian: Unknown Option: ' . $_);
-
 
274
        }
-
 
275
    }
-
 
276
 
237
    #
277
    #
238
    #                   Expect to find Debian Packages in the bin/PLATFORM subdir
278
    #   Create a list of products
-
 
279
    #   ie: PRODUCT_ARCH
239
    #
280
    #
-
 
281
    my @products;
240
    # Inputs          : Debian base name, complete with suboptions
282
    push @products, $product . '_' . $arch if ( $product );
-
 
283
    push @products, $arch;
-
 
284
 
241
    #
285
    #
242
    # Returns         : Full path of the file
286
    #   Scan all packages for the specified debian package
243
    #
287
    #
244
    sub LocateDebianFile
288
    foreach my $package_dir ( getPackagePaths ('--All') )
245
    {
289
    {
246
        my ($arg, $arch, $product) = @_;
-
 
247
        Verbose("LocateDebianFile: Processing: $arg");
-
 
248
 
-
 
249
        my @type = qw( P D );
-
 
250
        my @debian_file_path;
-
 
251
 
-
 
252
        #
-
 
253
        #   Extract sub-options
-
 
254
        #       --Prod[uction]
-
 
255
        #       --Debug
-
 
256
        #       --Arch[itecture]=yyy
-
 
257
        #
-
 
258
        my ($base_name, @opts) = split( ',', $arg );
-
 
259
        foreach ( @opts )
290
        foreach my $type ( @type )
260
        {
291
        {
261
            if ( m/^--Arch(.*)=(.+)/ ) {
-
 
262
                $arch=$2;
-
 
263
            } elsif ( m/^--Product=(.+)/ ) {
-
 
264
                $product=$1;
-
 
265
            } elsif ( m/^--Prod/ ) {
-
 
266
                @type = 'P';
-
 
267
            } elsif ( m/^--Debug/ ) {
-
 
268
                @type = 'D';
-
 
269
            }
-
 
270
        }
-
 
271
 
-
 
272
        #
-
 
273
        #   Create a list of products
-
 
274
        #   ie: PRODUCT_ARCH
-
 
275
        #
-
 
276
        my @products;
-
 
277
        push @products, $product . '_' . $arch if ( $product );
-
 
278
        push @products, $arch;
-
 
279
 
-
 
280
        #
-
 
281
        #   Scan all packages for the specified debian package
-
 
282
        #
-
 
283
        foreach my $package_dir ( getPackagePaths ('--All') )
-
 
284
        {
-
 
285
            foreach my $type ( @type )
-
 
286
            {
-
 
287
                foreach my $prd ( @products )
292
            foreach my $prd ( @products )
288
                {
-
 
289
                    foreach my $joiner ( qw(/ .) )
-
 
290
                    {
-
 
291
                        my $dir = "$package_dir/bin$joiner$prd$type";
-
 
292
                        Verbose("ManifestFiles: Search in $dir");
-
 
293
                        next unless ( -d $dir );
-
 
294
                        my @files = glob ( "$dir/${base_name}_*.deb" );
-
 
295
                        next unless ( @files );
-
 
296
                        push @debian_file_path, @files;
-
 
297
                        $package_dirs{$package_dir}{used} = 1;
-
 
298
                    }
-
 
299
                }
-
 
300
            }
-
 
301
            foreach my $type ( @type )
-
 
302
            {
293
            {
303
                foreach my $prd ( @products )
294
                foreach my $joiner ( qw(/ .) )
304
                {
295
                {
305
                    my $dir = "$package_dir";
296
                    my $dir = "$package_dir/bin$joiner$prd$type";
306
                    Verbose("ManifestFiles: Search in $dir");
297
                    Verbose("ManifestFiles: Search in $dir");
307
                    next unless ( -d $dir );
298
                    next unless ( -d $dir );
308
                    my @files = glob ( "$dir/${base_name}_*_${prd}_${type}.deb" );
299
                    my @files = glob ( "$dir/${base_name}_*.deb" );
309
                    next unless ( @files );
300
                    next unless ( @files );
310
                    push @debian_file_path, @files;
301
                    push @debian_file_path, @files;
311
                    $package_dirs{$package_dir}{used} = 1;
302
                    $package_dirs{$package_dir}{used} = 1;
312
                }
303
                }
313
            }
304
            }
314
        }
305
        }
-
 
306
        foreach my $type ( @type )
315
 
307
        {
-
 
308
            foreach my $prd ( @products )
-
 
309
            {
-
 
310
                my $dir = "$package_dir";
316
        ReportError ("Required Debian package not found: $base_name") unless @debian_file_path;
311
                Verbose("ManifestFiles: Search in $dir");
-
 
312
                next unless ( -d $dir );
317
        ReportError ("Multiple matching Debian Packages located: $base_name", @debian_file_path ) if ( $#debian_file_path > 0 );
313
                my @files = glob ( "$dir/${base_name}_*_${prd}_${type}.deb" );
-
 
314
                next unless ( @files );
318
        return $debian_file_path[0];
315
                push @debian_file_path, @files;
-
 
316
                $package_dirs{$package_dir}{used} = 1;
-
 
317
            }
-
 
318
        }
319
    }
319
    }
320
 
320
 
-
 
321
    ReportError ("Required Debian package not found: $base_name") unless @debian_file_path;
-
 
322
    ReportError ("Multiple matching Debian Packages located: $base_name", @debian_file_path ) if ( $#debian_file_path > 0 );
-
 
323
    return $debian_file_path[0];
-
 
324
}
-
 
325
 
321
    #-------------------------------------------------------------------------------
326
#-------------------------------------------------------------------------------
322
    # Function        : LocateMugDir
327
# Function        : _LocateApkFile
323
    #
328
#
324
    # Description     : Locate the directory containing the mugfiles
329
# Description     : Locate a APK file
325
    #                   Internal Function
330
#                   Internal Function
-
 
331
#
-
 
332
#                   Scan packages for the APK package specified
-
 
333
#                   The user provides the base name of the package
-
 
334
#                   APK ( Android Packages )
-
 
335
#                   Expect to have a '-release' or '-debug' suffix, except those provided via a
-
 
336
#                   3rd party SDK.
-
 
337
#                   Expect to find APK Packages in the bin/PLATFORM(P/D) subdir
-
 
338
#                   Expect to find -debug in the <PLATFORM>D directory
-
 
339
#                   Expect to find -release' in the <PLATFORM>P directory
-
 
340
#                   
-
 
341
#                   Allow for:
-
 
342
#                       Full path to .apk file
-
 
343
#                       .apk in package root directory
326
    #
344
#
327
    # Inputs          : Mufile package, with embedded options
345
# Inputs          : Apk base name, complete with suboptions
-
 
346
#
-
 
347
# Returns         : Full path of the file
-
 
348
#
-
 
349
sub _LocateApkFile
-
 
350
{
-
 
351
    my ($arg, $arch) = @_;
-
 
352
    Verbose("LocateApkFile: Processing: $arg");
-
 
353
 
-
 
354
    my @type = qw( P );
-
 
355
    my @apk_file_path;
-
 
356
    my %type = ('P' => '-release', 'D' => '-debug' );
-
 
357
 
328
    #
358
    #
-
 
359
    #   Extract sub-options
329
    # Returns         : Full path
360
    #       --Prod[uction]
-
 
361
    #       --Debug
-
 
362
    #       --Architecture=yyy
330
    #
363
    #
-
 
364
    my ($base_name, @opts) = split( ',', $arg );
331
    sub LocateMugDir
365
    foreach ( @opts )
332
    {
366
    {
333
        my ($mug_package) = @_;
367
        if ( m/^--Arch(.*)=(.+)/ ) {
334
 
-
 
335
        #
368
            $arch=$2;
336
        #   Locate the mugfile subdir
369
        } elsif ( m/^--Prod/ ) {
337
        #
-
 
338
        my $package_name = $mug_package;
-
 
339
        my @dirs = 'mug';
370
            @type = 'P';
340
        my $mug_dir;
371
        } elsif ( m/^--Debug/ ) {
341
 
-
 
342
        #
-
 
343
        #   Extract sub options
372
            @type = 'D';
344
        #       --Subdir=xxxx,yyyy,zzzz
-
 
345
        #
-
 
346
        if ( $package_name =~ m/(.*?),--Subdir=(.*)/ )
-
 
347
        {
373
        } else {
348
            $package_name = $1;
-
 
349
            @dirs = split( ',', $2 );
374
            Warning ('--Apk: Unknown Option: ' . $_);
350
        }
375
        }
-
 
376
    }
351
 
377
 
-
 
378
    #
352
        my $package = GetPackageEntry( $package_name );
379
    #   Scan all packages for the specified APK package
-
 
380
    #   Try:
-
 
381
    #       Raw name - for apks from the SDK or 3rd parties
-
 
382
    #       PLATFORM(P|D)/baseName-(release|debug) - Expected
353
        unless ( $package )
383
    #       baseName-(release|debug) - Repackaged badly
354
        {
384
    #       
355
            ReportError ("ManifestFiles: Package not known to build: $package_name");
385
    foreach my $package_dir ( getPackagePaths ('--All') )
-
 
386
    {
356
            return undef;
387
        my $testFile;
-
 
388
        $testFile = "$package_dir/${base_name}.apk";
-
 
389
        if ( -f $testFile ) {
-
 
390
                push @apk_file_path, $testFile;
357
        }
391
        }
358
 
392
 
-
 
393
 
359
        foreach my $subdir ( @dirs )
394
        foreach my $type ( @type )
360
        {
395
        {
361
            my $dir = "$package->{'ROOT'}/$subdir";
396
            my $typeSuffix = $type{$type};
362
            if ( -d $dir )
397
            foreach my $joiner ( qw(/ .) )
363
            {
398
            {
364
                Warning ("Multiple Mugfile directories located. Only the first will be used",
399
                my $dir = "$package_dir/bin$joiner$arch$type";
365
                         "Ignoring: $subdir" )if ( $mug_dir );
400
                Verbose("ManifestFiles: Search in $dir");
366
                $mug_dir = $dir;
401
                next unless ( -d $dir );
-
 
402
                $testFile = "$dir/${base_name}${typeSuffix}.apk";
-
 
403
                if ( -f $testFile ) {
-
 
404
                        push @apk_file_path, $testFile;
-
 
405
                }
367
            }
406
            }
368
        }
407
        }
-
 
408
        foreach my $type ( @type )
-
 
409
        {
-
 
410
            my $typeSuffix = $type{$type};
-
 
411
            my $dir = "$package_dir";
369
        ReportError ("Mugfile directory not found in package: $package_name")
412
            Verbose("ManifestFiles: Search in $dir");
370
            unless $mug_dir;
413
            next unless ( -d $dir );
371
 
-
 
-
 
414
            my $testFile = "$dir/${base_name}${typeSuffix}.apk";
372
        return $mug_dir;
415
            if ( -f $testFile ) {
-
 
416
                    push @apk_file_path, $testFile;
-
 
417
            }
-
 
418
        }
-
 
419
        $package_dirs{$package_dir}{used} = 1 if (@apk_file_path) ;
373
    }
420
    }
374
 
421
 
-
 
422
    ReportError ("Required APK package not found: $base_name") unless @apk_file_path;
-
 
423
    ReportError ("Multiple matching APK Packages located: $base_name", @apk_file_path ) if ( $#apk_file_path > 0 );
-
 
424
    return $apk_file_path[0];
-
 
425
}
-
 
426
 
375
    #-------------------------------------------------------------------------------
427
#-------------------------------------------------------------------------------
376
    # Function        : ImportManifest
428
# Function        : _LocateMugDir
-
 
429
#
-
 
430
# Description     : Locate the directory containing the mugfiles
-
 
431
#                   Internal Function
-
 
432
#
-
 
433
# Inputs          : Mufile package, with embedded options
-
 
434
#
-
 
435
# Returns         : Full path
-
 
436
#
-
 
437
sub _LocateMugDir
-
 
438
{
-
 
439
    my ($mug_package) = @_;
-
 
440
 
377
    #
441
    #
378
    # Description     : Import an existing manifest
442
    #   Locate the mugfile subdir
379
    #
443
    #
380
    # Inputs          : Args    - PackageName[,Subdir=name,--ReWrite]
444
    my $package_name = $mug_package;
381
    #                   tier    - May be null
445
    my @dirs = 'mug';
382
    #                   name    - May be null
446
    my $mug_dir;
-
 
447
 
383
    #
448
    #
-
 
449
    #   Extract sub options
384
    # Returns         : A hash of data to be used later
450
    #       --Subdir=xxxx,yyyy,zzzz
385
    #
451
    #
386
    sub ImportManifest
452
    if ( $package_name =~ m/(.*?),--Subdir=(.*)/ )
387
    {
453
    {
388
        my ($args, $tier, $name) = @_;
454
        $package_name = $1;
389
        my @file_contents;
455
        @dirs = split( ',', $2 );
390
        my @file_list;
456
    }
391
 
457
 
392
        #
-
 
393
        #   Locate the mugfile subdir
-
 
394
        #
-
 
395
        my $package_name = $args;
458
    my $package = GetPackageEntry( $package_name );
396
        my @dirs = 'mug';
-
 
397
        my $pkg_dir;
-
 
398
        my $pkg_root;
459
    unless ( $package )
399
        my $manifest;
460
    {
400
        my $first_tier;
461
        ReportError ("ManifestFiles: Package not known to build: $package_name");
401
        my $first_name;
462
        return undef;
402
        my $rewrite;
463
    }
403
 
464
 
-
 
465
    foreach my $subdir ( @dirs )
404
        #
466
    {
405
        #   Extract sub options
-
 
406
        #       --Subdir=xxxx,yyyy,zzzz
467
        my $dir = "$package->{'ROOT'}/$subdir";
407
        #       --ReWrite
468
        if ( -d $dir )
408
        #
-
 
409
        if ( $package_name =~ m/(.*?)(,.*)/ )
-
 
410
        {
469
        {
411
            $package_name = $1;
470
            Warning ("Multiple Mugfile directories located. Only the first will be used",
412
            my @subargs = split(',--', $2);
471
                     "Ignoring: $subdir" )if ( $mug_dir );
413
            foreach ( @subargs)
472
            $mug_dir = $dir;
414
            {
473
        }
-
 
474
    }
415
                next unless (length($_) > 0);
475
    ReportError ("Mugfile directory not found in package: $package_name")
416
                if (m~^Subdir=(.*)~i){
476
        unless $mug_dir;
417
                    @dirs = split( ',', $1 );
-
 
418
 
477
 
419
                } elsif (m~^ReWrite~i) {
-
 
420
                    $rewrite = 1;
478
    return $mug_dir;
-
 
479
}
421
 
480
 
422
                } else {
-
 
423
                    ReportError("ManifestFiles: Unknown suboption to ImportManifest:" . $_);
-
 
424
                }
-
 
425
            }
-
 
426
        }
-
 
427
 
481
 
-
 
482
#-------------------------------------------------------------------------------
-
 
483
# Function        : _ImportManifest
-
 
484
#
-
 
485
# Description     : Import an existing manifest
-
 
486
#
428
        my $package = GetPackageEntry( $package_name );
487
# Inputs          : Args    - PackageName[,Subdir=name,--ReWrite]
429
        unless ( $package )
488
#                   tier    - May be null
430
        {
489
#                   name    - May be null
-
 
490
#
431
            ReportError ("ManifestFiles: Package not known to build: $package_name");
491
# Returns         : A hash of data to be used later
-
 
492
#
-
 
493
sub _ImportManifest
-
 
494
{
-
 
495
    my ($args, $tier, $name) = @_;
432
            return undef;
496
    my @file_contents;
433
        }
497
    my @file_list;
434
 
498
 
-
 
499
    #
435
        if (defined ($rewrite) && ( !defined($tier) || !defined($name)))
500
    #   Locate the mugfile subdir
436
        {
501
    #
437
            ReportError ("ManifestFiles: ImportManifest. --ReWrite cannot be used unless tier and name are specified");
502
    my $package_name = $args;
-
 
503
    my @dirs = 'mug';
-
 
504
    my $pkg_dir;
-
 
505
    my $pkg_root;
-
 
506
    my $manifest;
-
 
507
    my $first_tier;
438
            return undef;
508
    my $first_name;
439
        }
509
    my $rewrite;
440
 
510
 
-
 
511
    #
441
        foreach my $subdir ( @dirs )
512
    #   Extract sub options
-
 
513
    #       --Subdir=xxxx,yyyy,zzzz
-
 
514
    #       --ReWrite
-
 
515
    #
-
 
516
    if ( $package_name =~ m/(.*?)(,.*)/ )
442
        {
517
    {
443
            my $dir = "$package->{'ROOT'}/$subdir";
518
        $package_name = $1;
444
            my $root = $package->{'ROOT'};
519
        my @subargs = split(',--', $2);
445
            if ( -d $dir )
520
        foreach ( @subargs)
446
            {
521
        {
447
                Warning ("Multiple Package directories located. Only the first will be used",
522
            next unless (length($_) > 0);
-
 
523
            if (m~^Subdir=(.*)~i){
448
                         "Ignoring: $subdir" )if ( $pkg_dir );
524
                @dirs = split( ',', $1 );
-
 
525
 
449
                $pkg_dir = $dir;
526
            } elsif (m~^ReWrite~i) {
450
                $pkg_root = $root;
527
                $rewrite = 1;
-
 
528
 
-
 
529
            } else {
-
 
530
                ReportError("ManifestFiles: Unknown suboption to ImportManifest:" . $_);
451
            }
531
            }
452
        }
532
        }
-
 
533
    }
453
 
534
 
-
 
535
    my $package = GetPackageEntry( $package_name );
454
        unless ($pkg_dir)
536
    unless ( $package )
455
        {
537
    {
456
            ReportError ("Package directory not found in package: $package_name");
538
        ReportError ("ManifestFiles: Package not known to build: $package_name");
457
            return undef;
539
        return undef;
458
        }
540
    }
459
 
541
 
460
        #
-
 
461
        #   Determine Manifest File name
-
 
462
        #
-
 
463
        foreach my $file ( glob ($pkg_dir . '/Manifest*' ) )
542
    if (defined ($rewrite) && ( !defined($tier) || !defined($name)))
464
        {
543
    {
465
                next unless ( -f $file );
-
 
466
                Warning ("Multiple Manifest Files find. Only the first will be used",
544
        ReportError ("ManifestFiles: ImportManifest. --ReWrite cannot be used unless tier and name are specified");
467
                         "Using: $manifest",
-
 
468
                         "Ignoring: $file" ) if ( $manifest );
-
 
469
                $manifest = $file;
545
        return undef;
470
        }
546
    }
471
 
547
 
-
 
548
    foreach my $subdir ( @dirs )
-
 
549
    {
-
 
550
        my $dir = "$package->{'ROOT'}/$subdir";
-
 
551
        my $root = $package->{'ROOT'};
472
        unless ($manifest)
552
        if ( -d $dir )
473
        {
553
        {
-
 
554
            Warning ("Multiple Package directories located. Only the first will be used",
474
            ReportError ("ImportManifest. No Manifest found: $package_name");
555
                     "Ignoring: $subdir" )if ( $pkg_dir );
475
            return undef;
556
            $pkg_dir = $dir;
-
 
557
            $pkg_root = $root;
476
        }
558
        }
-
 
559
    }
477
 
560
 
-
 
561
    unless ($pkg_dir)
-
 
562
    {
-
 
563
        ReportError ("Package directory not found in package: $package_name");
-
 
564
        return undef;
-
 
565
    }
478
 
566
 
-
 
567
    #
-
 
568
    #   Determine Manifest File name
-
 
569
    #
-
 
570
    foreach my $file ( glob ($pkg_dir . '/Manifest*' ) )
-
 
571
    {
-
 
572
            next unless ( -f $file );
-
 
573
            Warning ("Multiple Manifest Files find. Only the first will be used",
-
 
574
                     "Using: $manifest",
-
 
575
                     "Ignoring: $file" ) if ( $manifest );
-
 
576
            $manifest = $file;
-
 
577
    }
-
 
578
 
-
 
579
    unless ($manifest)
-
 
580
    {
-
 
581
        ReportError ("ImportManifest. No Manifest found: $package_name");
-
 
582
        return undef;
-
 
583
    }
-
 
584
 
-
 
585
 
-
 
586
    #
-
 
587
    #
-
 
588
    #
-
 
589
    open (MF, '<', $manifest ) || Error ("Cannot open the Manifest file: $manifest", $!);
-
 
590
    while ( <MF> )
-
 
591
    {
479
        #
592
        #
-
 
593
        #   Clean trailing whitespace ( line-feed and new lines )
-
 
594
        #   Comment out [Version] data
480
        #
595
        #
481
        #
-
 
482
        open (MF, '<', $manifest ) || Error ("Cannot open the Manifest file: $manifest", $!);
-
 
483
        while ( <MF> )
-
 
484
        {
-
 
485
            #
-
 
486
            #   Clean trailing whitespace ( line-feed and new lines )
-
 
487
            #   Comment out [Version] data
-
 
488
            #
-
 
489
            s~\s+$~~;
596
        s~\s+$~~;
490
            s~(\s*\[Version])~#$1~;
597
        s~(\s*\[Version])~#$1~;
491
 
598
 
492
            #
599
        #
493
            #   Part lines and determine files
600
        #   Part lines and determine files
494
            #
601
        #
495
            next unless ( $_ );
602
        next unless ( $_ );
496
            next if ( m~\s*#~ );
603
        next if ( m~\s*#~ );
497
            next if ( m~\s*\[~ );
604
        next if ( m~\s*\[~ );
498
            my( $aname, $atier, $afile) = split(/\s*\,\s*/, $_);
605
        my( $aname, $atier, $afile) = split(/\s*\,\s*/, $_);
499
#            print "---------- $_\n";
606
#            print "---------- $_\n";
500
#            print "T: $atier, N:$aname, F:$afile\n";
607
#            print "T: $atier, N:$aname, F:$afile\n";
501
            push @file_list, $afile;
608
        push @file_list, $afile;
502
 
609
 
503
            #
610
        #
504
            #   Rewrite the name and tier
611
        #   Rewrite the name and tier
505
            #
612
        #
506
            if ($rewrite)
613
        if ($rewrite)
507
            {
614
        {
508
                $_ = join(',', $name, $tier, $afile);
615
            $_ = join(',', $name, $tier, $afile);
509
                $first_tier = $tier;
616
            $first_tier = $tier;
510
                $first_name = $name;
617
            $first_name = $name;
511
            }
-
 
512
            else
-
 
513
            {
-
 
514
                #
-
 
515
                #   Capture first tier and name
-
 
516
                #
-
 
517
                $first_tier = $atier unless ( defined $first_tier );
-
 
518
                $first_name = $aname unless ( defined $first_name );
-
 
519
            }
-
 
520
        }
618
        }
521
        continue
619
        else
522
        {
620
        {
-
 
621
            #
523
            push @file_contents, $_;
622
            #   Capture first tier and name
-
 
623
            #
-
 
624
            $first_tier = $atier unless ( defined $first_tier );
-
 
625
            $first_name = $aname unless ( defined $first_name );
524
        }
626
        }
525
        close MF;
-
 
526
 
-
 
527
        #
-
 
528
        #   Create a hash of data that describes the manifest that has
-
 
529
        #   just been read in.
-
 
530
        #
-
 
531
        $package_dirs{$pkg_root}{used} = 1;
-
 
532
        $manifest =~ s~.*/~~;
-
 
533
        return { 'contents' => \@file_contents,
-
 
534
                  'files' => \@file_list,
-
 
535
                  'file_base' => $pkg_dir,
-
 
536
                  'manifest' => $manifest,
-
 
537
                  'pkg_dir' => $pkg_root,
-
 
538
                  'tier' => $first_tier,
-
 
539
                  'name' => $first_name,
-
 
540
                  'rewrite' => $rewrite,
-
 
541
                };
-
 
542
    }
627
    }
-
 
628
    continue
-
 
629
    {
-
 
630
        push @file_contents, $_;
-
 
631
    }
-
 
632
    close MF;
-
 
633
 
-
 
634
    #
-
 
635
    #   Create a hash of data that describes the manifest that has
-
 
636
    #   just been read in.
-
 
637
    #
-
 
638
    $package_dirs{$pkg_root}{used} = 1;
-
 
639
    $manifest =~ s~.*/~~;
-
 
640
    return { 'contents' => \@file_contents,
-
 
641
              'files' => \@file_list,
-
 
642
              'file_base' => $pkg_dir,
-
 
643
              'manifest' => $manifest,
-
 
644
              'pkg_dir' => $pkg_root,
-
 
645
              'tier' => $first_tier,
-
 
646
              'name' => $first_name,
-
 
647
              'rewrite' => $rewrite,
-
 
648
            };
543
}
649
}
544
 
650
 
545
#-------------------------------------------------------------------------------
651
#-------------------------------------------------------------------------------
546
# Function        : ManifestFiles_Generate
652
# Function        : ManifestFiles_Generate
547
#
653
#
Line 628... Line 734...
628
        my $name = $entry->{name};
734
        my $name = $entry->{name};
629
        my $include_md5 = $entry->{md5};
735
        my $include_md5 = $entry->{md5};
630
 
736
 
631
        if ( $entry->{dmf} )
737
        if ( $entry->{dmf} )
632
        {
738
        {
633
        	DmfGenerate($entry);
739
            DmfGenerate($entry);
634
        }
740
        }
635
 
741
 
636
        #
742
        #
637
        #   Insert all the files that have been specified
743
        #   Insert all the files that have been specified
638
        #   The user specified order is preserved
744
        #   The user specified order is preserved
Line 828... Line 934...
828
    my $i = 0;
934
    my $i = 0;
829
    foreach my $fentry ( @files )
935
    foreach my $fentry ( @files )
830
    {
936
    {
831
        if ( my $file = $fentry->{'file'} )
937
        if ( my $file = $fentry->{'file'} )
832
        {
938
        {
833
        	my $order = $i + 1;
939
            my $order = $i + 1;
834
            my $base_file = StripDir( $file );
940
            my $base_file = StripDir( $file );
835
            my $publish_file = $name . '_' . $version . '_' . $order . '.aup';
941
            my $publish_file = $name . '_' . $version . '_' . $order . '.aup';
836
            my $aup_file = $work_dir . $publish_file;
942
            my $aup_file = $work_dir . $publish_file;
837
 
943
 
838
            GenerateCesFile($file, $aup_file, 0x3, $gen_time, $publish_file);
944
            GenerateCesFile($file, $aup_file, 0x3, $gen_time, $publish_file);