Subversion Repositories DevTools

Rev

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

Rev 6302 Rev 6306
Line 24... Line 24...
24
require 5.6.1;
24
require 5.6.1;
25
use strict;
25
use strict;
26
use warnings;
26
use warnings;
27
use Digest::file qw(digest_file_hex);
27
use Digest::file qw(digest_file_hex);
28
use Digest::file qw(digest_file_base64);
28
use Digest::file qw(digest_file_base64);
-
 
29
use ArrayHashUtils;
29
 
30
 
30
#
31
#
31
#   Globals
32
#   Globals
32
#
33
#
33
my @Manifests;                      # Manifest entries
34
my @Manifests;                      # Manifest entries
Line 90... Line 91...
90
    return if ( ! ActivePlatform($platforms) );
91
    return if ( ! ActivePlatform($platforms) );
91
 
92
 
92
    my $name;
93
    my $name;
93
    my $tier;
94
    my $tier;
94
    my @files;
95
    my @files;
-
 
96
    my %fileVersions;
95
    my $mug_dir;
97
    my $mug_dir;
96
    my $default_arch = $::ScmPlatform;
98
    my $default_arch = $::ScmPlatform;
97
    my $default_prod = '';
99
    my $default_prod = '';
98
    my $imported_manifest = 0;
100
    my $imported_manifest = 0;
99
    my $include_md5 = 0;
101
    my $include_md5 = 0;
Line 127... Line 129...
127
 
129
 
128
        } elsif ( m~^--Debian=(.+)~ ) {
130
        } elsif ( m~^--Debian=(.+)~ ) {
129
            push @files, {'file' => _LocateDebianFile($1, $default_arch, $default_prod)};
131
            push @files, {'file' => _LocateDebianFile($1, $default_arch, $default_prod)};
130
 
132
 
131
        } elsif ( m~^--Apk=(.+)~ ) {
133
        } elsif ( m~^--Apk=(.+)~ ) {
132
            push @files, {'file' => _LocateApkFile($1, $default_arch)};
134
            my $apkData = _LocateApkFile($1, $default_arch);
-
 
135
            my ($fname, $fversion) = split($;, $apkData);
-
 
136
            $fileVersions{$fname} = $fversion;
-
 
137
            push @files, {'file' => $fname };
133
 
138
 
134
        } elsif ( m~^--SrcFile=(.+)~ ) {
139
        } elsif ( m~^--SrcFile=(.+)~ ) {
135
            push @files, {'file' => LocatePreReq($1)};
140
            push @files, {'file' => LocatePreReq($1)};
136
 
141
 
137
        } elsif ( m~^--SrcFileNoCopy=(.+)~ ) {
142
        } elsif ( m~^--SrcFileNoCopy=(.+)~ ) {
Line 208... Line 213...
208
    #
213
    #
209
    my %data;
214
    my %data;
210
    $data{tier} = $tier;
215
    $data{tier} = $tier;
211
    $data{name} = $name;
216
    $data{name} = $name;
212
    $data{files} = \@files;
217
    $data{files} = \@files;
-
 
218
    $data{fileVersions} = \%fileVersions;
213
    $data{mugdir} = $mug_dir;
219
    $data{mugdir} = $mug_dir;
214
    $data{pkgsubdir} = $pkg_subdir;
220
    $data{pkgsubdir} = $pkg_subdir;
215
    $data{md5} = $include_md5;
221
    $data{md5} = $include_md5;
216
    $data{dmf} = $generate_dmf;
222
    $data{dmf} = $generate_dmf;
217
    $data{arch} = $default_arch;
223
    $data{arch} = $default_arch;
Line 248... Line 254...
248
    my ($arg, $arch, $product) = @_;
254
    my ($arg, $arch, $product) = @_;
249
    Verbose("LocateDebianFile: Processing: $arg");
255
    Verbose("LocateDebianFile: Processing: $arg");
250
 
256
 
251
    my @type = qw( P D );
257
    my @type = qw( P D );
252
    my @debian_file_path;
258
    my @debian_file_path;
-
 
259
    my @searchPath;
253
 
260
 
254
    #
261
    #
255
    #   Extract sub-options
262
    #   Extract sub-options
256
    #       --Prod[uction]
263
    #       --Prod[uction]
257
    #       --Debug
264
    #       --Debug
Line 292... Line 299...
292
            foreach my $prd ( @products )
299
            foreach my $prd ( @products )
293
            {
300
            {
294
                foreach my $joiner ( qw(/ .) )
301
                foreach my $joiner ( qw(/ .) )
295
                {
302
                {
296
                    my $dir = "$package_dir/bin$joiner$prd$type";
303
                    my $dir = "$package_dir/bin$joiner$prd$type";
297
                    Verbose("ManifestFiles: Search in $dir");
304
                    UniquePush(\@searchPath, $dir);
298
                    next unless ( -d $dir );
305
                    next unless ( -d $dir );
299
                    my @files = glob ( "$dir/${base_name}_*.deb" );
306
                    my @files = glob ( "$dir/${base_name}_*.deb" );
300
                    next unless ( @files );
307
                    next unless ( @files );
301
                    push @debian_file_path, @files;
308
                    push @debian_file_path, @files;
302
                    $package_dirs{$package_dir}{used} = 1;
309
                    $package_dirs{$package_dir}{used} = 1;
Line 306... Line 313...
306
        foreach my $type ( @type )
313
        foreach my $type ( @type )
307
        {
314
        {
308
            foreach my $prd ( @products )
315
            foreach my $prd ( @products )
309
            {
316
            {
310
                my $dir = "$package_dir";
317
                my $dir = "$package_dir";
311
                Verbose("ManifestFiles: Search in $dir");
318
                UniquePush(\@searchPath, $dir);
312
                next unless ( -d $dir );
319
                next unless ( -d $dir );
313
                my @files = glob ( "$dir/${base_name}_*_${prd}_${type}.deb" );
320
                my @files = glob ( "$dir/${base_name}_*_${prd}_${type}.deb" );
314
                next unless ( @files );
321
                next unless ( @files );
315
                push @debian_file_path, @files;
322
                push @debian_file_path, @files;
316
                $package_dirs{$package_dir}{used} = 1;
323
                $package_dirs{$package_dir}{used} = 1;
317
            }
324
            }
318
        }
325
        }
319
    }
326
    }
320
 
327
 
-
 
328
    #
-
 
329
    #   Keep user informed
-
 
330
    #   Report errors and provide useful information
-
 
331
    #
-
 
332
    if (IsVerbose(1) || IsDebug(1) || $#debian_file_path != 0)
-
 
333
    {
-
 
334
        Message ("Search for ($base_name). In search Path", @searchPath);
-
 
335
    }
-
 
336
 
321
    ReportError ("Required Debian package not found: $base_name") unless @debian_file_path;
337
    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 );
338
    ReportError ("Multiple matching Debian Packages located: $base_name", @debian_file_path ) if ( $#debian_file_path > 0 );
323
    return $debian_file_path[0];
339
    return $debian_file_path[0];
324
}
340
}
325
 
341
 
Line 342... Line 358...
342
#                       Full path to .apk file
358
#                       Full path to .apk file
343
#                       .apk in package root directory
359
#                       .apk in package root directory
344
#
360
#
345
# Inputs          : Apk base name, complete with suboptions
361
# Inputs          : Apk base name, complete with suboptions
346
#
362
#
347
# Returns         : Full path of the file
363
# Returns         : Full path of the file $; PackageVersion
-
 
364
#                   apk packages do not appear to have version numbers in the file name
-
 
365
#                   Retain package version number for later processing
348
#
366
#
349
sub _LocateApkFile
367
sub _LocateApkFile
350
{
368
{
351
    my ($arg, $arch) = @_;
369
    my ($arg, $arch) = @_;
352
    Verbose("LocateApkFile: Processing: $arg");
370
    Verbose("LocateApkFile: Processing: $arg");
353
 
371
 
354
    my @type = qw( P );
372
    my @type = qw( P );
355
    my @apk_file_path;
373
    my @apk_file_path;
356
    my %type = ('P' => '-release', 'D' => '-debug' );
374
    my %type = ('P' => '-release', 'D' => '-debug' );
-
 
375
    my @searchPath;
357
 
376
 
358
    #
377
    #
359
    #   Extract sub-options
378
    #   Extract sub-options
360
    #       --Prod[uction]
379
    #       --Prod[uction]
361
    #       --Debug
380
    #       --Debug
Line 379... Line 398...
379
    #   Scan all packages for the specified APK package
398
    #   Scan all packages for the specified APK package
380
    #   Try:
399
    #   Try:
381
    #       Raw name - for apks from the SDK or 3rd parties
400
    #       Raw name - for apks from the SDK or 3rd parties
382
    #       PLATFORM(P|D)/baseName-(release|debug) - Expected
401
    #       PLATFORM(P|D)/baseName-(release|debug) - Expected
383
    #       baseName-(release|debug) - Repackaged badly
402
    #       baseName-(release|debug) - Repackaged badly
384
    #       
403
    # 
385
    foreach my $package_dir ( getPackagePaths ('--All') )
404
    foreach my $pkgEntry ( getPackageList() )
386
    {
405
    {
387
        my $testFile;
406
        next if ($pkgEntry->getType() eq 'interface');
388
        $testFile = "$package_dir/${base_name}.apk";
407
        my $pkgVersion = $pkgEntry->getVersion();
389
        if ( -f $testFile ) {
408
        
390
                push @apk_file_path, $testFile;
409
        my $pkgLocal = $pkgEntry->getBase(2);
391
        }
410
        my $pkgRoot = $pkgEntry->getDir();
392
 
411
 
-
 
412
        #
-
 
413
        #   Helper function
-
 
414
        #   Uses closure
-
 
415
        #   Notes: Test the package in dpkg_archive so that we can retain the package-version
-
 
416
        #          Use the version in the interface directory if BuildPkgArchive
-
 
417
        #   $pkgLocal - Local base of the package. May in the interface directory
-
 
418
        #   $pkgRoot  - Directory in dpkg_achive. Will have version info
-
 
419
        #   $subdir   - subdir within the package
-
 
420
        #   $fname    - File to look for
-
 
421
        #   
-
 
422
        #   Returns: Nothing
-
 
423
        #   Maintains: apk_file_path. Tupple: filename, PackageVersion
-
 
424
        #
-
 
425
        my $testOneFile = sub {
-
 
426
            my ( $subdir, $fname) = @_;
-
 
427
            my $testFile = "$pkgRoot/$subdir";
-
 
428
            $testFile =~ s~//~/~g;
-
 
429
            $testFile =~ s~/$~~;
-
 
430
            UniquePush(\@searchPath, $testFile);
-
 
431
            return unless (-d $testFile);
-
 
432
 
-
 
433
            $testFile .= '/' . $fname;
-
 
434
            if (-f $testFile ) {
-
 
435
                if ($pkgLocal ne $pkgRoot) {
-
 
436
                    my $testFile2 = "$pkgLocal/$subdir/$fname";
-
 
437
                    $testFile2 =~ s~//~/~g;
-
 
438
                    if ( -f $testFile2 ) {
-
 
439
                        $testFile = $testFile2;
-
 
440
                    }
-
 
441
                }
-
 
442
 
-
 
443
             $testFile = join($;, $testFile, $pkgVersion);
-
 
444
             push @apk_file_path, $testFile;
-
 
445
            }
-
 
446
        };
-
 
447
 
-
 
448
        #
-
 
449
        #   Test for the specified file in the package root
-
 
450
        #
-
 
451
        $testOneFile->("", "${base_name}.apk");
393
 
452
 
-
 
453
        #
-
 
454
        #   Test for BIN/PLATFORM
-
 
455
        #   
394
        foreach my $type ( @type )
456
        foreach my $type ( @type )
395
        {
457
        {
396
            my $typeSuffix = $type{$type};
458
            my $typeSuffix = $type{$type};
397
            foreach my $joiner ( qw(/ .) )
459
            foreach my $joiner ( qw(/ .) ) {
398
            {
-
 
399
                my $dir = "$package_dir/bin$joiner$arch$type";
-
 
400
                Verbose("ManifestFiles: Search in $dir");
-
 
401
                next unless ( -d $dir );
-
 
402
                $testFile = "$dir/${base_name}${typeSuffix}.apk";
460
                $testOneFile->("bin$joiner$arch$type","${base_name}${typeSuffix}.apk");
403
                if ( -f $testFile ) {
-
 
404
                        push @apk_file_path, $testFile;
-
 
405
                }
-
 
406
            }
461
            }
407
        }
462
        }
-
 
463
 
408
        foreach my $type ( @type )
464
        foreach my $type ( @type )
409
        {
465
        {
410
            my $typeSuffix = $type{$type};
466
            my $typeSuffix = $type{$type};
411
            my $dir = "$package_dir";
-
 
412
            Verbose("ManifestFiles: Search in $dir");
-
 
413
            next unless ( -d $dir );
-
 
414
            my $testFile = "$dir/${base_name}${typeSuffix}.apk";
467
            $testOneFile->("","${base_name}${typeSuffix}.apk");
415
            if ( -f $testFile ) {
-
 
416
                    push @apk_file_path, $testFile;
-
 
417
            }
-
 
418
        }
468
        }
419
        $package_dirs{$package_dir}{used} = 1 if (@apk_file_path) ;
469
        $package_dirs{$pkgRoot}{used} = 1 if (@apk_file_path) ;
-
 
470
    }
-
 
471
 
-
 
472
    #
-
 
473
    #   Keep user informed
-
 
474
    #   Report errors and provide useful information
-
 
475
    #
-
 
476
    if (IsVerbose(1) || IsDebug(1) || $#apk_file_path != 0)
-
 
477
    {
-
 
478
        Message ("Search for ($base_name). In search Path", @searchPath);
420
    }
479
    }
421
 
480
 
422
    ReportError ("Required APK package not found: $base_name") unless @apk_file_path;
481
    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 );
482
    ReportError ("Multiple matching APK Packages located: $base_name", @apk_file_path ) if ( $#apk_file_path > 0 );
-
 
483
 
-
 
484
#DebugDumpData("apk_file_path", \@apk_file_path);
424
    return $apk_file_path[0];
485
    return $apk_file_path[0];
425
}
486
}
426
 
487
 
427
#-------------------------------------------------------------------------------
488
#-------------------------------------------------------------------------------
428
# Function        : _LocateMugDir
489
# Function        : _LocateMugDir
Line 760... Line 821...
760
 
821
 
761
            print_mf ('#') if ( $last_was_comment );
822
            print_mf ('#') if ( $last_was_comment );
762
            if ( my $file = $fentry->{'file'} )
823
            if ( my $file = $fentry->{'file'} )
763
            {
824
            {
764
                my $base_file = StripDir( $file );
825
                my $base_file = StripDir( $file );
-
 
826
                my @extraItems;
765
                if ($include_md5) {
827
                if ($include_md5) {
766
                    my $md5 = digest_file_hex($file, 'MD5');
828
                    my $md5 = digest_file_hex($file, 'MD5');
-
 
829
                    push @extraItems, "MD5=$md5" ;
-
 
830
                }
-
 
831
 
-
 
832
                if (exists $entry->{fileVersions} && exists $entry->{fileVersions}{$file} ) {
-
 
833
                    push @extraItems, "VERSION=" . $entry->{fileVersions}{$file};
-
 
834
                }
-
 
835
                if (@extraItems) {
767
                    print_mf ('--NoCheckLineWidth', "$name,$tier,$base_file,MD5=$md5");
836
                    print_mf ('--NoCheckLineWidth', "$name,$tier,$base_file," . join (',', @extraItems));
768
                } else {
837
                } else {
769
                    print_mf ("$name,$tier,$base_file");
838
                    print_mf ("$name,$tier,$base_file");
770
                }
839
                }
771
                PackageFile ('*', $file, '--Subdir=' . $pkgdir, '--Strip' );
840
                PackageFile ('*', $file, '--Subdir=' . $pkgdir, '--Strip' );
772
                $last_was_comment = 0;
841
                $last_was_comment = 0;