Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
1119 dpurdie 1
########################################################################
6302 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
1119 dpurdie 3
#
6302 dpurdie 4
# Module name   : ManifestFiles.pm
1119 dpurdie 5
# Module type   : Makefile system
6302 dpurdie 6
# Environment(s): JATS Build System
5654 dpurdie 7
# Documents     : MASS-00232 Format of the Linux App Upgrade Manifest File
1119 dpurdie 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);
5771 alewis 28
use Digest::file qw(digest_file_base64);
6306 dpurdie 29
use ArrayHashUtils;
1119 dpurdie 30
 
31
#
32
#   Globals
33
#
34
my @Manifests;                      # Manifest entries
1125 alewis 35
my $Manifest_has_version = 1;       # Create Manifest_xxxx by default
1121 dpurdie 36
my %package_dirs;                   # Package dirs discovered and used
1125 alewis 37
my $pkg_subdir;                     # Alternate packaging
6314 dpurdie 38
my $ManifestLineWidth;              # Max length of lines
1119 dpurdie 39
 
40
#-------------------------------------------------------------------------------
41
# Function        : BEGIN
42
#
43
# Description     : Setup directive hooks
44
#                   Register a function to be called just before we start to
45
#                   generate makefiles. This will be used to process the data
46
#                   collected in all the ManifestFiles directives
47
#
48
# Inputs          : None
49
#
50
# Returns         : None
51
#
52
BEGIN
53
{
54
    RegisterMakefileGenerate (\&ManifestFiles_Generate);
55
}
56
 
57
#-------------------------------------------------------------------------------
58
# Function        : ManifestFiles
59
#
60
# Description     : Create a ManifestFiles entry
61
#
62
# Inputs          : Platform             - Active Platform Selector
63
#                   Options              - One or more options
64
#                       --Name=Name             - Mandatory
65
#                       --Tier=Name             - Mandatory
66
#                       --Architecture=xxxx     - Default actitecture is the current target
67
#                       --Product=yyyy          - Product Family
68
#                       --Debian=BaseName[,--Prod,--Debug,--Arch=xxxx,--Product=yyyy]
6302 dpurdie 69
#                       --Apk=BaseName[,--Prod,--Debug,--Platform=pppp]
70
#                                                   Default platform = ANDROID
71
#                                                   Default type = Production
1119 dpurdie 72
#                       --MugPackage=Package[,--Subdir=subdir[,subdir]+]
73
#                       --SrcFile=xxx
1125 alewis 74
#                       --SrcFileNoCopy=xxx
1123 dpurdie 75
#                       --Comment=xxx           - Add comment to Manifst
1125 alewis 76
#                       --NoManifestVersion     - Create unversioned Manifest File
77
#                       --PkgSubdir=xxx         - Specifies packaging subdir
5105 dpurdie 78
#                       --ImportManifest=Package[,--Subdir=subdir,--ReWrite] - Import Manifest from package
5649 dpurdie 79
#                       --Md5                   - Add MD5 checksums to the Manifest File
5767 alewis 80
#                       --Dmf                   - Generate the Device Management Framework
81
#                                                 combined archive ZIP file.
82
#                       --DmfVersion=xxxx       - Generate the Device Management Framework
83
#                                                 combined archive ZIP using a modified
84
#                                                 version number; only for testing!
6364 dpurdie 85
#                       --LineLength=nnn        - Limit line length. Default is 79
86
#                       --SubManifest           - Create a sub-manifest (not installable). Manifest will have no version.
87
#                                                 Gives a default name, tier and subdir if not explicitly provided.
1119 dpurdie 88
#
89
# Returns         : Nothing
90
#
91
sub ManifestFiles
92
{
93
    my( $platforms, @elements ) = @_;
94
    Debug2( "ManifestFiles($platforms, @elements)" );
95
    return if ( ! ActivePlatform($platforms) );
96
 
97
    my $name;
98
    my $tier;
99
    my @files;
6306 dpurdie 100
    my %fileVersions;
1119 dpurdie 101
    my $mug_dir;
102
    my $default_arch = $::ScmPlatform;
103
    my $default_prod = '';
1129 dpurdie 104
    my $imported_manifest = 0;
5649 dpurdie 105
    my $include_md5 = 0;
5767 alewis 106
    my $generate_dmf = 0;
5771 alewis 107
    my $dmf_version = $::ScmBuildVersionFull;
6314 dpurdie 108
    my $useDefaultLineWidth = 1;
6364 dpurdie 109
    my $is_sub_manifest = 0;
1119 dpurdie 110
 
111
    #
112
    #   Collect user options
113
    #
114
    foreach ( @elements )
115
    {
116
        if ( m~^--Name=(.+)~ ) {
6302 dpurdie 117
            if ( $name ) {
1119 dpurdie 118
                ReportError ("ManifestFiles:--Name option is only allowed once");
119
                next;
120
            }
121
            $name = $1;
122
 
123
        } elsif ( m~^--Tier=(.+)~ ) {
6302 dpurdie 124
            if ( $tier ) {
1119 dpurdie 125
                ReportError ("ManifestFiles:--Tier option is only allowed once");
126
                next;
127
            }
128
            $tier = $1;
129
 
1123 dpurdie 130
        } elsif ( m~^--Comment=~ ) {
131
            my $cmt = $_;
132
            $cmt =~ s~.+=~~;
133
            $cmt =~ s~\s*\n\s*~\n~g;
134
            push @files, {'cmt' => $cmt };
135
 
1119 dpurdie 136
        } elsif ( m~^--Debian=(.+)~ ) {
6302 dpurdie 137
            push @files, {'file' => _LocateDebianFile($1, $default_arch, $default_prod)};
1119 dpurdie 138
 
6302 dpurdie 139
        } elsif ( m~^--Apk=(.+)~ ) {
6306 dpurdie 140
            my $apkData = _LocateApkFile($1, $default_arch);
141
            my ($fname, $fversion) = split($;, $apkData);
142
            $fileVersions{$fname} = $fversion;
143
            push @files, {'file' => $fname };
6314 dpurdie 144
            $useDefaultLineWidth = 0;
6302 dpurdie 145
 
1119 dpurdie 146
        } elsif ( m~^--SrcFile=(.+)~ ) {
1123 dpurdie 147
            push @files, {'file' => LocatePreReq($1)};
5649 dpurdie 148
 
1125 alewis 149
        } elsif ( m~^--SrcFileNoCopy=(.+)~ ) {
150
            push @files, {'filenocopy' => $1};
5649 dpurdie 151
 
1119 dpurdie 152
        } elsif ( m~^--MugPackage=(.+)~ ) {
6302 dpurdie 153
            if ( $mug_dir ) {
1119 dpurdie 154
                ReportError ("ManifestFiles:--MugPackage option is only allowed once");
155
                next;
5649 dpurdie 156
            }
6302 dpurdie 157
            $mug_dir = _LocateMugDir($1);
1119 dpurdie 158
 
159
        } elsif ( m/^--Arch(.*)=(.+)/ ) {
160
            $default_arch = $2;
161
 
162
        } elsif ( m/^--Product=(.+)/ ) {
163
            $default_prod = $1;
164
 
1125 alewis 165
        } elsif ( m/^--NoManifestVersion/i ) {
166
            $Manifest_has_version = 0;
167
 
168
        } elsif ( m/^--PkgSubdir=(.+)/i ) {
6302 dpurdie 169
            if ( $pkg_subdir ) {
1129 dpurdie 170
                ReportError ("ManifestFiles:--PkgSubdir option is only allowed once");
1125 alewis 171
                next;
172
            }
173
            $pkg_subdir = $1;
174
 
1129 dpurdie 175
        } elsif ( m/^--ImportManifest=(.+)/i ) {
6302 dpurdie 176
            my $import_info = _ImportManifest($1, $tier, $name);
1129 dpurdie 177
#DebugDumpData("ImportInfo", $import_info );
178
            push @files, {'manifest' => $import_info };
179
 
180
            #
181
            #   Fill in details unless already provided
182
            #
183
            $tier = $import_info->{'tier'} unless ( defined $tier );
184
            $name = $import_info->{'name'} unless ( defined $name );
185
            $imported_manifest = 1;
186
 
5649 dpurdie 187
        } elsif (m/^--Md5/i) {
6314 dpurdie 188
            $include_md5 = 1;
189
            $useDefaultLineWidth = 0;
5649 dpurdie 190
 
5767 alewis 191
        } elsif (m/^--Dmf/i) {
192
            $generate_dmf = 1
193
 
194
        } elsif ( m/^--DmfVersion=(.+)/ ) {
195
            $generate_dmf = 1;
196
            $dmf_version = $1;
197
 
6314 dpurdie 198
        } elsif ( m/^--LineLength=(\d+)$/i ) {
199
            $ManifestLineWidth = $1;
200
            $useDefaultLineWidth = 0;
201
 
6364 dpurdie 202
        } elsif (m/^--SubManifest/i) {
203
            $is_sub_manifest = 1;
204
            $Manifest_has_version = 0;
205
            $name = $::ScmPlatform
206
                unless $name;
207
            $pkg_subdir = $name
208
                unless $pkg_subdir;
209
            $tier = 0
210
                unless defined($tier);
211
 
1119 dpurdie 212
        } else {
213
            ReportError ("ManifestFiles: Unknown option or argument: $_");
214
 
215
        }
216
    }
217
 
218
    #
219
    #   Sanity test the user options
220
    #
221
    ReportError ("ManifestFiles: No name specified")
222
        unless $name;
223
    ReportError ("ManifestFiles: No tier specified")
1129 dpurdie 224
        unless defined ($tier);
6302 dpurdie 225
    ReportError ("ManifestFiles: Cannot mix --Debian/-Apk/--SrcFile with --MugPackage in one directive")
1129 dpurdie 226
        if ( $mug_dir && (@files || $imported_manifest) );
1119 dpurdie 227
    ReportError ("ManifestFiles: Must specify files to add to Manifest")
1129 dpurdie 228
        unless ( $mug_dir ||  @files || $imported_manifest);
1119 dpurdie 229
    ErrorDoExit();
230
 
231
    #
6314 dpurdie 232
    #   Set ManifestLineWidth
233
    #   The default is largely historical - for MOS
234
    #   
235
    unless (defined $ManifestLineWidth) {
236
        $ManifestLineWidth = $useDefaultLineWidth ? 79 : 0;
237
    }
238
    Verbose("ManifestLineWidth:$ManifestLineWidth");
239
 
240
    #
1119 dpurdie 241
    #   Save information for processing at the end of the parsing phase
242
    #   Data collected from ALL the ManifestFiles directives will be collected
243
    #   and processed into one Manifest file
244
    #
245
    my %data;
246
    $data{tier} = $tier;
247
    $data{name} = $name;
248
    $data{files} = \@files;
6306 dpurdie 249
    $data{fileVersions} = \%fileVersions;
1119 dpurdie 250
    $data{mugdir} = $mug_dir;
1125 alewis 251
    $data{pkgsubdir} = $pkg_subdir;
5649 dpurdie 252
    $data{md5} = $include_md5;
5767 alewis 253
    $data{dmf} = $generate_dmf;
254
    $data{arch} = $default_arch;
255
    $data{dmf_version} = $dmf_version;
6364 dpurdie 256
    $data{is_sub_manifest} = $is_sub_manifest;
5767 alewis 257
 
1129 dpurdie 258
#DebugDumpData("DirectiveData", \%data );
1119 dpurdie 259
 
260
    push @Manifests, \%data;
261
    return;
6302 dpurdie 262
}
1119 dpurdie 263
 
6302 dpurdie 264
#-------------------------------------------------------------------------------
265
# Function        : _LocateDebianFile
266
#
267
# Description     : Locate a debian file
268
#                   Internal Function
269
#
270
#                   Scan packages for the Debian package specified
271
#                   The user provides the base name of the package
272
#                   A Debian Package name has several fields
273
#                   These are:
274
#                       1) Base Name - Provided by the user
275
#                       2) Version - Version will be wildcarded
276
#                       3) Architecture - Wildcarded. Uses bin/arch directory
277
#
278
#                   Expect to find Debian Packages in the bin/PLATFORM subdir
279
#
280
# Inputs          : Debian base name, complete with suboptions
281
#
282
# Returns         : Full path of the file
283
#
284
sub _LocateDebianFile
285
{
286
    my ($arg, $arch, $product) = @_;
287
    Verbose("LocateDebianFile: Processing: $arg");
288
 
289
    my @type = qw( P D );
290
    my @debian_file_path;
6306 dpurdie 291
    my @searchPath;
6302 dpurdie 292
 
1119 dpurdie 293
    #
6302 dpurdie 294
    #   Extract sub-options
295
    #       --Prod[uction]
296
    #       --Debug
297
    #       --Arch[itecture]=yyy
298
    #       --Product=yyy
1119 dpurdie 299
    #
6302 dpurdie 300
    my ($base_name, @opts) = split( ',', $arg );
301
    foreach ( @opts )
302
    {
303
        if ( m/^--Arch(.*)=(.+)/ ) {
304
            $arch=$2;
305
        } elsif ( m/^--Product=(.+)/ ) {
306
            $product=$1;
307
        } elsif ( m/^--Prod/ ) {
308
            @type = 'P';
309
        } elsif ( m/^--Debug/ ) {
310
            @type = 'D';
311
        } else {
312
            Warning ('--Debian: Unknown Option: ' . $_);
313
        }
314
    }
315
 
5649 dpurdie 316
    #
6302 dpurdie 317
    #   Create a list of products
318
    #   ie: PRODUCT_ARCH
1119 dpurdie 319
    #
6302 dpurdie 320
    my @products;
321
    push @products, $product . '_' . $arch if ( $product );
322
    push @products, $arch;
323
 
1119 dpurdie 324
    #
6302 dpurdie 325
    #   Scan all packages for the specified debian package
1119 dpurdie 326
    #
6302 dpurdie 327
    foreach my $package_dir ( getPackagePaths ('--All') )
1119 dpurdie 328
    {
6302 dpurdie 329
        foreach my $type ( @type )
1119 dpurdie 330
        {
6302 dpurdie 331
            foreach my $prd ( @products )
1119 dpurdie 332
            {
6302 dpurdie 333
                foreach my $joiner ( qw(/ .) )
1119 dpurdie 334
                {
6302 dpurdie 335
                    my $dir = "$package_dir/bin$joiner$prd$type";
6306 dpurdie 336
                    UniquePush(\@searchPath, $dir);
5873 acammell 337
                    next unless ( -d $dir );
6302 dpurdie 338
                    my @files = glob ( "$dir/${base_name}_*.deb" );
5873 acammell 339
                    next unless ( @files );
340
                    push @debian_file_path, @files;
341
                    $package_dirs{$package_dir}{used} = 1;
342
                }
343
            }
1119 dpurdie 344
        }
6302 dpurdie 345
        foreach my $type ( @type )
346
        {
347
            foreach my $prd ( @products )
348
            {
349
                my $dir = "$package_dir";
6306 dpurdie 350
                UniquePush(\@searchPath, $dir);
6302 dpurdie 351
                next unless ( -d $dir );
352
                my @files = glob ( "$dir/${base_name}_*_${prd}_${type}.deb" );
353
                next unless ( @files );
354
                push @debian_file_path, @files;
355
                $package_dirs{$package_dir}{used} = 1;
356
            }
357
        }
1119 dpurdie 358
    }
359
 
6306 dpurdie 360
    #
361
    #   Keep user informed
362
    #   Report errors and provide useful information
363
    #
364
    if (IsVerbose(1) || IsDebug(1) || $#debian_file_path != 0)
365
    {
366
        Message ("Search for ($base_name). In search Path", @searchPath);
367
    }
368
 
6302 dpurdie 369
    ReportError ("Required Debian package not found: $base_name") unless @debian_file_path;
370
    ReportError ("Multiple matching Debian Packages located: $base_name", @debian_file_path ) if ( $#debian_file_path > 0 );
371
    return $debian_file_path[0];
372
}
373
 
374
#-------------------------------------------------------------------------------
375
# Function        : _LocateApkFile
376
#
377
# Description     : Locate a APK file
378
#                   Internal Function
379
#
380
#                   Scan packages for the APK package specified
381
#                   The user provides the base name of the package
382
#                   APK ( Android Packages )
383
#                   Expect to have a '-release' or '-debug' suffix, except those provided via a
384
#                   3rd party SDK.
385
#                   Expect to find APK Packages in the bin/PLATFORM(P/D) subdir
386
#                   Expect to find -debug in the <PLATFORM>D directory
387
#                   Expect to find -release' in the <PLATFORM>P directory
388
#                   
389
#                   Allow for:
390
#                       Full path to .apk file
391
#                       .apk in package root directory
392
#
393
# Inputs          : Apk base name, complete with suboptions
394
#
6306 dpurdie 395
# Returns         : Full path of the file $; PackageVersion
396
#                   apk packages do not appear to have version numbers in the file name
397
#                   Retain package version number for later processing
6302 dpurdie 398
#
399
sub _LocateApkFile
400
{
401
    my ($arg, $arch) = @_;
402
    Verbose("LocateApkFile: Processing: $arg");
403
 
404
    my @type = qw( P );
405
    my @apk_file_path;
406
    my %type = ('P' => '-release', 'D' => '-debug' );
6306 dpurdie 407
    my @searchPath;
6302 dpurdie 408
 
1119 dpurdie 409
    #
6302 dpurdie 410
    #   Extract sub-options
411
    #       --Prod[uction]
412
    #       --Debug
413
    #       --Architecture=yyy
1119 dpurdie 414
    #
6302 dpurdie 415
    my ($base_name, @opts) = split( ',', $arg );
416
    foreach ( @opts )
1119 dpurdie 417
    {
6302 dpurdie 418
        if ( m/^--Arch(.*)=(.+)/ ) {
419
            $arch=$2;
420
        } elsif ( m/^--Prod/ ) {
421
            @type = 'P';
422
        } elsif ( m/^--Debug/ ) {
423
            @type = 'D';
424
        } else {
425
            Warning ('--Apk: Unknown Option: ' . $_);
1119 dpurdie 426
        }
6302 dpurdie 427
    }
1119 dpurdie 428
 
6302 dpurdie 429
    #
430
    #   Scan all packages for the specified APK package
431
    #   Try:
432
    #       Raw name - for apks from the SDK or 3rd parties
433
    #       PLATFORM(P|D)/baseName-(release|debug) - Expected
434
    #       baseName-(release|debug) - Repackaged badly
6306 dpurdie 435
    # 
436
    foreach my $pkgEntry ( getPackageList() )
6302 dpurdie 437
    {
6306 dpurdie 438
        next if ($pkgEntry->getType() eq 'interface');
439
        my $pkgVersion = $pkgEntry->getVersion();
440
 
441
        my $pkgLocal = $pkgEntry->getBase(2);
442
        my $pkgRoot = $pkgEntry->getDir();
1119 dpurdie 443
 
6306 dpurdie 444
        #
445
        #   Helper function
446
        #   Uses closure
447
        #   Notes: Test the package in dpkg_archive so that we can retain the package-version
448
        #          Use the version in the interface directory if BuildPkgArchive
449
        #   $pkgLocal - Local base of the package. May in the interface directory
450
        #   $pkgRoot  - Directory in dpkg_achive. Will have version info
451
        #   $subdir   - subdir within the package
452
        #   $fname    - File to look for
453
        #   
454
        #   Returns: Nothing
455
        #   Maintains: apk_file_path. Tupple: filename, PackageVersion
456
        #
457
        my $testOneFile = sub {
458
            my ( $subdir, $fname) = @_;
459
            my $testFile = "$pkgRoot/$subdir";
460
            $testFile =~ s~//~/~g;
461
            $testFile =~ s~/$~~;
462
            UniquePush(\@searchPath, $testFile);
463
            return unless (-d $testFile);
6302 dpurdie 464
 
6306 dpurdie 465
            $testFile .= '/' . $fname;
466
            if (-f $testFile ) {
467
                if ($pkgLocal ne $pkgRoot) {
468
                    my $testFile2 = "$pkgLocal/$subdir/$fname";
469
                    $testFile2 =~ s~//~/~g;
470
                    if ( -f $testFile2 ) {
471
                        $testFile = $testFile2;
472
                    }
473
                }
474
 
475
             $testFile = join($;, $testFile, $pkgVersion);
476
             push @apk_file_path, $testFile;
477
            }
478
        };
479
 
480
        #
481
        #   Test for the specified file in the package root
482
        #
483
        $testOneFile->("", "${base_name}.apk");
484
 
485
        #
486
        #   Test for BIN/PLATFORM
487
        #   
6302 dpurdie 488
        foreach my $type ( @type )
1119 dpurdie 489
        {
6302 dpurdie 490
            my $typeSuffix = $type{$type};
6306 dpurdie 491
            foreach my $joiner ( qw(/ .) ) {
492
                $testOneFile->("bin$joiner$arch$type","${base_name}${typeSuffix}.apk");
1119 dpurdie 493
            }
494
        }
6306 dpurdie 495
 
6302 dpurdie 496
        foreach my $type ( @type )
497
        {
498
            my $typeSuffix = $type{$type};
6306 dpurdie 499
            $testOneFile->("","${base_name}${typeSuffix}.apk");
6302 dpurdie 500
        }
6306 dpurdie 501
        $package_dirs{$pkgRoot}{used} = 1 if (@apk_file_path) ;
1119 dpurdie 502
    }
1129 dpurdie 503
 
6306 dpurdie 504
    #
505
    #   Keep user informed
506
    #   Report errors and provide useful information
507
    #
508
    if (IsVerbose(1) || IsDebug(1) || $#apk_file_path != 0)
509
    {
510
        Message ("Search for ($base_name). In search Path", @searchPath);
511
    }
512
 
6302 dpurdie 513
    ReportError ("Required APK package not found: $base_name") unless @apk_file_path;
514
    ReportError ("Multiple matching APK Packages located: $base_name", @apk_file_path ) if ( $#apk_file_path > 0 );
6306 dpurdie 515
 
516
#DebugDumpData("apk_file_path", \@apk_file_path);
6302 dpurdie 517
    return $apk_file_path[0];
518
}
519
 
520
#-------------------------------------------------------------------------------
521
# Function        : _LocateMugDir
522
#
523
# Description     : Locate the directory containing the mugfiles
524
#                   Internal Function
525
#
526
# Inputs          : Mufile package, with embedded options
527
#
528
# Returns         : Full path
529
#
530
sub _LocateMugDir
531
{
532
    my ($mug_package) = @_;
533
 
1129 dpurdie 534
    #
6302 dpurdie 535
    #   Locate the mugfile subdir
1129 dpurdie 536
    #
6302 dpurdie 537
    my $package_name = $mug_package;
538
    my @dirs = 'mug';
539
    my $mug_dir;
540
 
1129 dpurdie 541
    #
6302 dpurdie 542
    #   Extract sub options
543
    #       --Subdir=xxxx,yyyy,zzzz
1129 dpurdie 544
    #
6302 dpurdie 545
    if ( $package_name =~ m/(.*?),--Subdir=(.*)/ )
1129 dpurdie 546
    {
6302 dpurdie 547
        $package_name = $1;
548
        @dirs = split( ',', $2 );
549
    }
1129 dpurdie 550
 
6302 dpurdie 551
    my $package = GetPackageEntry( $package_name );
552
    unless ( $package )
553
    {
554
        ReportError ("ManifestFiles: Package not known to build: $package_name");
555
        return undef;
556
    }
1129 dpurdie 557
 
6302 dpurdie 558
    foreach my $subdir ( @dirs )
559
    {
560
        my $dir = "$package->{'ROOT'}/$subdir";
561
        if ( -d $dir )
1129 dpurdie 562
        {
6302 dpurdie 563
            Warning ("Multiple Mugfile directories located. Only the first will be used",
564
                     "Ignoring: $subdir" )if ( $mug_dir );
565
            $mug_dir = $dir;
566
        }
567
    }
568
    ReportError ("Mugfile directory not found in package: $package_name")
569
        unless $mug_dir;
5105 dpurdie 570
 
6302 dpurdie 571
    return $mug_dir;
572
}
5105 dpurdie 573
 
1129 dpurdie 574
 
6302 dpurdie 575
#-------------------------------------------------------------------------------
576
# Function        : _ImportManifest
577
#
578
# Description     : Import an existing manifest
579
#
580
# Inputs          : Args    - PackageName[,Subdir=name,--ReWrite]
581
#                   tier    - May be null
582
#                   name    - May be null
583
#
584
# Returns         : A hash of data to be used later
585
#
586
sub _ImportManifest
587
{
588
    my ($args, $tier, $name) = @_;
589
    my @file_contents;
6364 dpurdie 590
    my @item_list;
1129 dpurdie 591
 
6302 dpurdie 592
    #
593
    #   Locate the mugfile subdir
594
    #
595
    my $package_name = $args;
596
    my @dirs = 'mug';
597
    my $pkg_dir;
598
    my $pkg_root;
599
    my $manifest;
600
    my $first_tier;
601
    my $first_name;
602
    my $rewrite;
603
 
604
    #
605
    #   Extract sub options
606
    #       --Subdir=xxxx,yyyy,zzzz
607
    #       --ReWrite
608
    #
609
    if ( $package_name =~ m/(.*?)(,.*)/ )
610
    {
611
        $package_name = $1;
612
        my @subargs = split(',--', $2);
613
        foreach ( @subargs)
5105 dpurdie 614
        {
6302 dpurdie 615
            next unless (length($_) > 0);
616
            if (m~^Subdir=(.*)~i){
617
                @dirs = split( ',', $1 );
5105 dpurdie 618
 
6302 dpurdie 619
            } elsif (m~^ReWrite~i) {
620
                $rewrite = 1;
621
 
622
            } else {
623
                ReportError("ManifestFiles: Unknown suboption to ImportManifest:" . $_);
1129 dpurdie 624
            }
625
        }
6302 dpurdie 626
    }
1129 dpurdie 627
 
6302 dpurdie 628
    my $package = GetPackageEntry( $package_name );
629
    unless ( $package )
630
    {
631
        ReportError ("ManifestFiles: Package not known to build: $package_name");
632
        return undef;
633
    }
5105 dpurdie 634
 
6302 dpurdie 635
    if (defined ($rewrite) && ( !defined($tier) || !defined($name)))
636
    {
637
        ReportError ("ManifestFiles: ImportManifest. --ReWrite cannot be used unless tier and name are specified");
638
        return undef;
639
    }
1129 dpurdie 640
 
6302 dpurdie 641
    foreach my $subdir ( @dirs )
642
    {
643
        my $dir = "$package->{'ROOT'}/$subdir";
644
        my $root = $package->{'ROOT'};
645
        if ( -d $dir )
5105 dpurdie 646
        {
6302 dpurdie 647
            Warning ("Multiple Package directories located. Only the first will be used",
648
                     "Ignoring: $subdir" )if ( $pkg_dir );
649
            $pkg_dir = $dir;
650
            $pkg_root = $root;
5105 dpurdie 651
        }
6302 dpurdie 652
    }
1129 dpurdie 653
 
6302 dpurdie 654
    unless ($pkg_dir)
655
    {
656
        ReportError ("Package directory not found in package: $package_name");
657
        return undef;
658
    }
5105 dpurdie 659
 
6302 dpurdie 660
    #
661
    #   Determine Manifest File name
662
    #
663
    foreach my $file ( glob ($pkg_dir . '/Manifest*' ) )
664
    {
665
            next unless ( -f $file );
666
            Warning ("Multiple Manifest Files find. Only the first will be used",
667
                     "Using: $manifest",
668
                     "Ignoring: $file" ) if ( $manifest );
669
            $manifest = $file;
670
    }
671
 
672
    unless ($manifest)
673
    {
674
        ReportError ("ImportManifest. No Manifest found: $package_name");
675
        return undef;
676
    }
677
 
678
 
679
    #
680
    #
681
    #
682
    open (MF, '<', $manifest ) || Error ("Cannot open the Manifest file: $manifest", $!);
683
    while ( <MF> )
684
    {
1129 dpurdie 685
        #
6302 dpurdie 686
        #   Clean trailing whitespace ( line-feed and new lines )
687
        #   Comment out [Version] data
1129 dpurdie 688
        #
6302 dpurdie 689
        s~\s+$~~;
690
        s~(\s*\[Version])~#$1~;
691
 
5649 dpurdie 692
        #
6302 dpurdie 693
        #   Part lines and determine files
694
        #
695
        next unless ( $_ );
6364 dpurdie 696
        if (( m~\s*#~ ) || ( m~\s*\[~ )) {
697
            push @item_list, { 'comment' => $_ };
698
            next;
699
        }
700
        my( $aname, $atier, $afile, @additionnal_info) = split(/\s*\,\s*/, $_);
1129 dpurdie 701
#            print "---------- $_\n";
702
#            print "T: $atier, N:$aname, F:$afile\n";
6364 dpurdie 703
        my $file =  { 'file_name' => $afile
704
                    , 'file_info' => \@additionnal_info
705
                    };
706
        push @item_list, $file;
1129 dpurdie 707
 
6302 dpurdie 708
        #
709
        #   Rewrite the name and tier
710
        #
711
        if ($rewrite)
712
        {
713
            $_ = join(',', $name, $tier, $afile);
714
            $first_tier = $tier;
715
            $first_name = $name;
716
        }
717
        else
718
        {
1129 dpurdie 719
            #
6302 dpurdie 720
            #   Capture first tier and name
1129 dpurdie 721
            #
6302 dpurdie 722
            $first_tier = $atier unless ( defined $first_tier );
723
            $first_name = $aname unless ( defined $first_name );
1129 dpurdie 724
        }
6302 dpurdie 725
    }
726
    continue
727
    {
728
        push @file_contents, $_;
729
    }
730
    close MF;
1129 dpurdie 731
 
6302 dpurdie 732
    #
733
    #   Create a hash of data that describes the manifest that has
734
    #   just been read in.
735
    #
736
    $package_dirs{$pkg_root}{used} = 1;
737
    $manifest =~ s~.*/~~;
738
    return { 'contents' => \@file_contents,
6364 dpurdie 739
              'items' => \@item_list,
6302 dpurdie 740
              'file_base' => $pkg_dir,
741
              'manifest' => $manifest,
742
              'pkg_dir' => $pkg_root,
743
              'tier' => $first_tier,
744
              'name' => $first_name,
745
              'rewrite' => $rewrite,
746
            };
1119 dpurdie 747
}
748
 
749
#-------------------------------------------------------------------------------
750
# Function        : ManifestFiles_Generate
751
#
752
# Description     : Internal Function
753
#                   Process all the collected data and create directives
754
#                   for the creation of the manifest
755
#
756
#                   This function will be called, just before the Makefile
757
#                   is created. The function will:
758
#                       1) Create the Manifest File
759
#                       2) Package the Manifest File
760
#                       3) Package the manifest file contents
761
#
762
#                   using (mostly) normal makefile.pl directives.
763
#
764
# Inputs          : None
765
#
766
# Returns         : Nothing
767
#
768
sub ManifestFiles_Generate
769
{
770
    Debug ("ManifestFiles_Generate");
771
    Message ("Generating Manifest File");
1123 dpurdie 772
 
773
    #
774
    #   Need at least one Manifest Entry
775
    #
776
    return unless ( @Manifests );
1119 dpurdie 777
#DebugDumpData ( "Manifests", \@Manifests );
778
 
779
    #
1125 alewis 780
    #   Determine the target packaging directory
781
    #   Default is .../mug
782
    #
783
    my $pkgdir = 'mug';
1129 dpurdie 784
    if ( exists $Manifests[0]->{pkgsubdir} && defined $Manifests[0]->{pkgsubdir} )
1125 alewis 785
    {
786
        my $subdir = $Manifests[0]->{pkgsubdir};
787
        $pkgdir .= '/' . $subdir;
788
        $pkgdir =~ s~^mug/mug~mug~;
789
    }
790
 
791
    #
1119 dpurdie 792
    #   Create the Manifest File as we process the lists
1125 alewis 793
    #   Place this in the 'lib' directory:
1119 dpurdie 794
    #       - So that it will be deleted on clobber
1123 dpurdie 795
    #       - So that it can be placed in a target-specific subdir
1125 alewis 796
    #       - So that we can have one per makefile.pl
1119 dpurdie 797
    #
798
    Error ("ManifestFiles: Needs local directory specified in build.pl") unless ( $::ScmLocal );
799
 
1125 alewis 800
    my $manifest_dir = "$::ScmPlatform.LIB";
1119 dpurdie 801
    System( "$::GBE_BIN/mkdir -p $manifest_dir" );
802
 
1125 alewis 803
    my $manifest_file = $manifest_dir . '/Manifest';
804
    $manifest_file .= '_' . $::ScmBuildVersion if ( $Manifest_has_version );
805
    ToolsetGenerate( $manifest_file );
1119 dpurdie 806
    Verbose ("ManifestFiles_Generate: File: $manifest_file");
5649 dpurdie 807
 
1125 alewis 808
    PackageFile ('*', $manifest_file, '--Subdir=' . $pkgdir, '--Strip' );
1119 dpurdie 809
 
810
    open (MF, '>', $manifest_file ) || Error ("Cannot create the Manifest file: $manifest_file");
811
 
5711 kspencer 812
    binmode (MF);
5767 alewis 813
 
6364 dpurdie 814
    if ($Manifests[0]->{is_sub_manifest} == 1) {
815
        print_mf ("# Package $::ScmBuildPackage $::ScmBuildVersion built: $::CurrentTime");
816
    } else {
817
        print_mf ("# PackageName: $::ScmBuildPackage");
818
        print_mf ("# PackageVersion: $::ScmBuildVersion");
819
        print_mf ("# BuildDate: $::CurrentTime");
820
        print_mf ("#");
821
        print_mf ("[Version],$::ScmBuildVersion");
822
        print_mf ("#");
823
    }
1119 dpurdie 824
 
825
    #
1125 alewis 826
    #   Process each tier in the order presented in the source file
1119 dpurdie 827
    #
1123 dpurdie 828
    my $last_was_comment = 0;
1119 dpurdie 829
    foreach my $entry ( @Manifests )
830
    {
831
 
832
#DebugDumpData ( "Manifest Entry", $entry );
833
 
834
        my $tier = $entry->{tier};
835
        my $name = $entry->{name};
5649 dpurdie 836
        my $include_md5 = $entry->{md5};
1119 dpurdie 837
 
5767 alewis 838
        if ( $entry->{dmf} )
839
        {
6302 dpurdie 840
            DmfGenerate($entry);
5767 alewis 841
        }
842
 
1119 dpurdie 843
        #
844
        #   Insert all the files that have been specified
845
        #   The user specified order is preserved
846
        #
1123 dpurdie 847
        #   Entries may be either a file or a comment
848
        #   Comments: Merge multiple comments and create blocks
849
        #
850
        #
1119 dpurdie 851
        my @files = @{ $entry->{files} };
1123 dpurdie 852
        foreach my $fentry ( @files )
1119 dpurdie 853
        {
1123 dpurdie 854
            if ( my $cmt = $fentry->{'cmt'} )
855
            {
856
                print_mf ('') unless ( $last_was_comment ) ;
857
                print_mf ( map (('# ' . $_) , split ("\n", $cmt) ));
858
                $last_was_comment = 1;
859
                next;
860
            }
861
 
862
            print_mf ('#') if ( $last_was_comment );
863
            if ( my $file = $fentry->{'file'} )
864
            {
865
                my $base_file = StripDir( $file );
6314 dpurdie 866
                my @items = ($name, $tier, $base_file);
5649 dpurdie 867
                if ($include_md5) {
868
                    my $md5 = digest_file_hex($file, 'MD5');
6314 dpurdie 869
                    push @items, "MD5=$md5" ;
6306 dpurdie 870
                }
871
                if (exists $entry->{fileVersions} && exists $entry->{fileVersions}{$file} ) {
6314 dpurdie 872
                    push @items, "VERSION=" . $entry->{fileVersions}{$file};
6306 dpurdie 873
                }
6314 dpurdie 874
                print_mf (join (',', @items));
1125 alewis 875
                PackageFile ('*', $file, '--Subdir=' . $pkgdir, '--Strip' );
1123 dpurdie 876
                $last_was_comment = 0;
877
            }
1125 alewis 878
 
879
            if ( my $file = $fentry->{'filenocopy'} )
880
            {
881
                print_mf ("$name,$tier,$file");
882
                $last_was_comment = 0;
883
            }
1129 dpurdie 884
 
885
            if ( my $emf = $fentry->{'manifest'} )
886
            {
887
                $last_was_comment = 0;
888
                #
889
                #   Insert the entire manifest
890
                #   Items are:
891
                #        contents
6364 dpurdie 892
                #        items:
893
                #               file_name + arrays of file_info
894
                #           or  comment line to copy
1129 dpurdie 895
                #        file_base
896
                #        manifest
897
                #
898
#DebugDumpData ( "Embedded Manifest Entry", $emf );
6364 dpurdie 899
                if ($emf->{'rewrite'}) {
900
                    foreach my $item ( @{$emf->{'items'}}) {
901
                        if (defined($item->{'file_name'}))
902
                        {
903
                            my @items = ($name, $tier, $item->{'file_name'});
904
                            my $md5_added = 0;
905
                            foreach my $info (@{$item->{'file_info'}}) {
906
                                push @items, $info;
907
                                $md5_added = 1 if ($info =~ m~^MD5=~i);
908
                            }
909
                            if ($include_md5 && $md5_added == 0) { # add md5 if requested and not already added from submanifest
910
                                my $md5 = digest_file_hex($emf->{'file_base'} . '/' . $item->{'file_name'}, 'MD5');
911
                                push @items, "MD5=$md5";
912
                            }
913
                            print_mf (join (',', @items));
914
                            PackageFile ('*', $emf->{'file_base'}. '/' . $item->{'file_name'}, '--Subdir=' . $pkgdir, '--Strip' );
915
                        }
916
                        elsif (defined($item->{'comment'})) {
917
                            print_mf($item->{'comment'});
918
                        }
919
                    }
920
                    print_mf('#');
921
                }
922
                else {
923
                    print_mf ($_) foreach  ( @{$emf->{'contents'}} );
924
                    foreach my $item ( @{$emf->{'items'}}) {
925
                        PackageFile ('*', $emf->{'file_base'}. '/' . $item->{'file_name'}, '--Subdir=' . $pkgdir, '--Strip' )
926
                            if (defined($item->{'file_name'}));
927
                    }
928
                    print_mf('#');
929
                }
1129 dpurdie 930
            }
1119 dpurdie 931
        }
932
 
933
        #
934
        #   Expand out the entire MUG directory
935
        #   All .mug files in the MUG directory will be added to the manifest
936
        #   The assumption is that the MUG directory has been created by
937
        #   something that knows what its doing
938
        #
939
        if ( my $mugdir = $entry->{mugdir} )
940
        {
941
            foreach my $file ( glob ($mugdir . '/*.mug' ) )
942
            {
943
                next unless ( -f $file );
944
                my $base_file = StripDir($file);
6314 dpurdie 945
 
946
                my @items = ($name, $tier, $base_file);
947
 
5654 dpurdie 948
                if ($include_md5) {
949
                    my $md5 = digest_file_hex($file, 'MD5');
6314 dpurdie 950
                    push @items, "MD5=$md5" ;
5654 dpurdie 951
                }
6314 dpurdie 952
                print_mf (join (',', @items));
1119 dpurdie 953
                PackageFile ('*', $file, '--Subdir=mug', '--Strip' );
954
            }
955
        }
956
    }
957
 
958
    #
959
    #   Complete the creation of the Manifest File
960
    #
6364 dpurdie 961
    print_mf ("# end of $::ScmBuildPackage");
1119 dpurdie 962
    close MF;
963
    ErrorDoExit();
1121 dpurdie 964
 
965
    #
966
    #   Sanity test of packages that did not provide a debian file
967
    #   Just a hint that something may have been missed
968
    #
969
    my @not_used_packages;
970
    foreach my $package_dir ( getPackagePaths ('--All') )
971
    {
972
        next if ( $package_dir =~ m~/manifest-tool/~ );
973
        unless ( exists $package_dirs{$package_dir}{used} )
974
        {
975
            push @not_used_packages, $package_dir;
976
        }
977
    }
978
    if ( @not_used_packages )
979
    {
980
        Warning ("Packages that did not contribute packages to the manifest:",
981
                  @not_used_packages );
982
    }
983
 
1119 dpurdie 984
    return;
985
 
986
    #-------------------------------------------------------------------------------
987
    # Function        : print_mf
988
    #
989
    # Description     : Internal Function
990
    #                   Print one line to the Manifest File
991
    #                   Checks the length of the line being created
992
    #
993
    # Inputs          : $line
994
    #
5649 dpurdie 995
    # Returns         :
1119 dpurdie 996
    #
997
 
998
    sub print_mf
999
    {
1000
        foreach  ( @_ )
1001
        {
6314 dpurdie 1002
            my $ll = length ($_);
1003
            ReportError ( "Manifest line too long: $ll. Max is $ManifestLineWidth.",
1004
                    "Line: $_" ) if ( $ManifestLineWidth && $ll > $ManifestLineWidth);
1119 dpurdie 1005
            print MF $_ . "\n";
1006
        }
1007
    }
1008
}
1009
 
5767 alewis 1010
# Bring in the DMF build requirements.
1011
my $directory;
1012
BEGIN {
1013
    use File::Spec::Functions qw(rel2abs);
1014
    use File::Basename qw(dirname);
1015
 
1016
    my $path = rel2abs( __FILE__ );
1017
    $directory = dirname( $path );
1018
}
1019
use lib $directory;
1020
 
1021
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
1022
use JSON;
1023
 
1024
#-------------------------------------------------------------------------------
1025
# Function        : DmfGenerate
1026
#
1027
# Description     : Import an existing manifest
1028
#
1029
# Inputs          : entry   - The manifest that is being processed.
1030
#
1031
# Returns         : Nothing
1032
#
1033
sub DmfGenerate
1034
{
1035
    my ($entry) = @_;
1036
 
1037
    # Get the generation time.
1038
    my $gen_time = time();
1039
 
1040
    my $work_dir = "$::ScmPlatform.BIN/";
1041
    System( "$::GBE_BIN/mkdir -p $work_dir" );
1042
 
1043
    my $name = $entry->{name};
1044
    my $version = $entry->{dmf_version};
1045
 
1046
    # Configure base manifest information.
1047
    my %manifest;
5771 alewis 1048
    $manifest{'mugsetId'} = $name . '_' . $version;
5767 alewis 1049
    $manifest{'name'} = $name;
1050
    $manifest{'version'} = $version;
5771 alewis 1051
    $manifest{'packageName'} = $::ScmBuildPackage;
1052
    $manifest{'packageVersion'} = $::ScmBuildVersionFull;
5767 alewis 1053
    $manifest{'datetime'} = localtime($gen_time);
1054
    $gen_time *= 1000;  # Make to milliseconds
1055
    $manifest{'timestamp'} = $gen_time;
1056
    $manifest{'tier'} = $entry->{tier};
1057
 
1058
    # Process each file.
1059
    my @files = @{ $entry->{files} };
1060
    my $zip = Archive::Zip->new();
1061
    my $i = 0;
1062
    foreach my $fentry ( @files )
1063
    {
1064
        if ( my $file = $fentry->{'file'} )
1065
        {
6302 dpurdie 1066
            my $order = $i + 1;
5767 alewis 1067
            my $base_file = StripDir( $file );
1068
            my $publish_file = $name . '_' . $version . '_' . $order . '.aup';
1069
            my $aup_file = $work_dir . $publish_file;
1070
 
1071
            GenerateCesFile($file, $aup_file, 0x3, $gen_time, $publish_file);
1072
 
1073
            my $file_member = $zip->addFile( $aup_file, $publish_file );
1074
 
1075
            $manifest{'tasks'}[$i]{'order'} = 1 * $order;
1076
            $manifest{'tasks'}[$i]{'filename'} = $base_file;
1077
            $manifest{'tasks'}[$i]{'download'} = $publish_file;
5771 alewis 1078
            $manifest{'tasks'}[$i]{'sha256'} = digest_file_base64($file, 'SHA-256');
1079
            $manifest{'tasks'}[$i]{'size'} = -s $file;
1080
 
5767 alewis 1081
            if ($base_file =~ /\.sh$/)
1082
            {
1083
                $manifest{'tasks'}[$i]{'action'} = 'exec-shell';
1084
            }
1085
            elsif ($base_file =~ /\.deb$/)
1086
            {
1087
                $manifest{'tasks'}[$i]{'action'} = 'dpkg-install';
5771 alewis 1088
 
1089
                my ($pkg_name, $pkg_version, $pkg_arch) = ($base_file =~ /([^_]*)_([^_]*)_(.*)/);
1090
                $manifest{'tasks'}[$i]{'arch'} = $pkg_arch;
1091
                $manifest{'tasks'}[$i]{'name'} = $pkg_name;
1092
                $manifest{'tasks'}[$i]{'version'} = $pkg_version;
5767 alewis 1093
            }
1094
            else
1095
            {
1096
                ReportError ("Manifest entry $base_file does not have a supported DMF install action");
1097
            }
1098
 
1099
            $i = $i + 1;
1100
        }
1101
    }
1102
 
1103
    # Encode and commit the JSON.
1104
    my $json_encoder = JSON->new->allow_nonref;
1105
    my $json = $json_encoder->pretty->encode( \%manifest );
1106
 
1107
    my $manifest_filename = $name . '_' . $version;
1108
    my $aum_filename = $manifest_filename . '_0.aum';
1109
    my $manifest_file = $work_dir . $manifest_filename . '.json';
1110
    my $aum_file = $work_dir . $aum_filename;
1111
 
1112
    # Save our manifest.
1113
    open (J, '>', $manifest_file ) || Error ("Cannot create the DMF Manifest file");
1114
    binmode (J);
1115
    print J $json;
1116
 
1117
    close J;
1118
 
1119
    GenerateCesFile($manifest_file, $aum_file, 0x2, $gen_time, $aum_filename);
1120
 
1121
    $zip->addFile($aum_file, $aum_filename);
1122
 
1123
    my $zip_filename = $work_dir . $name . '_' . $version . '.zip';
1124
    if ( $zip->writeToFileNamed($zip_filename) != AZ_OK )
1125
    {
1126
        ReportError("DMF ZIP file creation failed");
1127
    }
1128
    PackageFile('*', $zip_filename, '--Strip');
1129
    PackageFile('*', $manifest_file, '--Strip');
1130
 
1131
}
1132
 
1133
#-------------------------------------------------------------------------------
1134
# Function        : DmfGenerate
1135
#
1136
# Description     : Import an existing manifest
1137
#
1138
# Inputs          : src_file     - The input file.
1139
#                   dst_file     - The output CES file.
1140
#                   content_type - The content type to report.
1141
#                   gen_time     - The generation time for the file.
1142
#                   filename     - The filename to embed in the CES file.
1143
#
1144
#
1145
# Returns         : Nothing
1146
#
1147
sub GenerateCesFile
1148
{
1149
    my ($src_file, $dst_file, $content_type, $gen_time, $filename) = @_;
1150
 
1151
    open (INF, '<', $src_file ) || Error ("Cannot open file $src_file for reading");
1152
    binmode (INF);
1153
 
1154
    open (OUTF, '>', $dst_file ) || Error ("Cannot open file $dst_file for writing");
1155
    binmode (OUTF);
1156
 
1157
    my $signing_key_name = "";
1158
    my $signature_size = 0;
1159
    my $format_version = 0xCE500000;
1160
    my $compression_method = 0;
1161
    my $encryption_method = 0;
1162
    my $kek_name = "";
1163
    my $encryption_key_size = 0;
1164
    my $filename_size = length($filename);
1165
 
1166
    print OUTF pack("Z32", $signing_key_name);
1167
    print OUTF pack("n", $signature_size);
1168
    print OUTF pack("N", $format_version);
1169
    print OUTF pack("N", $content_type);
1170
    print OUTF pack("Q>", $gen_time);
1171
    print OUTF pack("N", $compression_method);
1172
    print OUTF pack("N", $encryption_method);
1173
    print OUTF pack("Z32", $kek_name);
1174
    print OUTF pack("n", $encryption_key_size);
1175
    print OUTF pack("n", $filename_size);
1176
    # Encryption key HERE
1177
    print OUTF pack("A$filename_size", $filename);
1178
 
1179
    my $buf;
1180
    while (read(INF,$buf,65536))
1181
    {
1182
        print OUTF $buf;
1183
    }
1184
    print OUTF $buf;
1185
    close INF;
1186
 
1187
    # Signature HERE
1188
 
1189
    # Finish with file.
1190
    close OUTF;
1191
}
1192
 
1119 dpurdie 1193
1;