Subversion Repositories DevTools

Rev

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

Rev 361 Rev 3987
Line 19... Line 19...
19
use warnings;
19
use warnings;
20
use JatsEnv;
20
use JatsEnv;
21
use JatsError;
21
use JatsError;
22
use JatsSystem;
22
use JatsSystem;
23
use JatsRmApi;
23
use JatsRmApi;
-
 
24
use ArrayHashUtils;
24
use DBI;
25
use DBI;
25
use Getopt::Long;
26
use Getopt::Long;
26
use Pod::Usage;                             # required for help support
27
use Pod::Usage;                             # required for help support
27
use Storable qw (dclone);
28
use Storable qw (dclone);
28
 
29
 
Line 36... Line 37...
36
my $opt_rootdir;
37
my $opt_rootdir;
37
my @opt_filters;
38
my @opt_filters;
38
my $opt_projectdir;
39
my $opt_projectdir;
39
my $opt_releasedir;
40
my $opt_releasedir;
40
my $opt_test;
41
my $opt_test;
41
 
-
 
-
 
42
my @opt_addFilters;
-
 
43
my @opt_delFilters;
42
 
44
 
43
#
45
#
44
#   Constants
46
#   Constants
45
#
47
#
46
my $CONFFILE = ".updateRelease";
48
my $CONFFILE = ".updateRelease";
Line 54... Line 56...
54
#
56
#
55
#   The directory we copy to.
57
#   The directory we copy to.
56
#
58
#
57
my $projectDestDir;
59
my $projectDestDir;
58
 
60
 
59
 
-
 
60
#
61
#
61
#   Configuration file vars
62
#   Configuration file vars
62
#
63
#
63
my @confFilters;
64
my @confFilters;
64
my $writeConf = 0;
65
my $writeConf = 0;
65
 
-
 
-
 
66
my %filtersUsed;
66
 
67
 
67
# -------------------------------------------------------------------------
68
# -------------------------------------------------------------------------
68
sub GetYesNo
69
sub GetYesNo
69
#
70
#
70
# -------------------------------------------------------------------------
71
# -------------------------------------------------------------------------
Line 187... Line 188...
187
                "help:+"            => \$opt_help,              # flag, multiple use allowed
188
                "help:+"            => \$opt_help,              # flag, multiple use allowed
188
                "manual:3"          => \$opt_help,              # flag, multiple use allowed
189
                "manual:3"          => \$opt_help,              # flag, multiple use allowed
189
                "verbose:+"         => \$opt_verbose,           # flag
190
                "verbose:+"         => \$opt_verbose,           # flag
190
                "sbomid|sbom_id=s"  => \@opt_sbom_ids,          # multiple numbers
191
                "sbomid|sbom_id=s"  => \@opt_sbom_ids,          # multiple numbers
191
                "filter=s"          => \@opt_filters,           # multiple strings
192
                "filter=s"          => \@opt_filters,           # multiple strings
-
 
193
                "addfilter=s"       => \@opt_addFilters,        # multiple strings
-
 
194
                "delfilter=s"       => \@opt_delFilters,        # multiple strings
192
                "rootdir=s"         => \$opt_rootdir,           # string
195
                "rootdir=s"         => \$opt_rootdir,           # string
193
                "projectdir=s"      => \$opt_projectdir,        # string
196
                "projectdir=s"      => \$opt_projectdir,        # string
194
                "releasedir=s"      => \$opt_releasedir,        # string
197
                "releasedir=s"      => \$opt_releasedir,        # string
195
                "test"              => \$opt_test,              # flag
198
                "test"              => \$opt_test,              # flag
196
                );
199
                );
Line 287... Line 290...
287
# validate config and command line options
290
# validate config and command line options
288
if ( $#opt_filters > -1 && $#confFilters > -1 )
291
if ( $#opt_filters > -1 && $#confFilters > -1 )
289
{
292
{
290
    Message("Filters supplied on Command line", @opt_filters);
293
    Message("Filters supplied on Command line", @opt_filters);
291
    Message("Filters in release configuration file", @confFilters);
294
    Message("Filters in release configuration file", @confFilters);
292
    if ( !GetYesNo("Replace Config Filters with command line Filters, be carefull as this may change the copy rules") )
295
    if ( !GetYesNo("Replace Config Filters with command line Filters, be careful as this may change the copy rules") )
293
    {
296
    {
294
        Error("Script terminated by user.");
297
        Error("Script terminated by user.");
295
    }
298
    }
296
    @confFilters = @opt_filters;
299
    @confFilters = ();
-
 
300
    foreach my $element (@opt_filters) {
-
 
301
        UniquePush (\@confFilters, $_ ) foreach  ( split(/,/, $element));
-
 
302
    }
297
    $writeConf = 1;
303
    $writeConf = 1;
298
}
304
}
299
elsif ( $#opt_filters > -1 && $#confFilters == -1 )
305
elsif ( $#opt_filters > -1 && $#confFilters == -1 )
300
{
306
{
301
    Message("Filters supplied on Command line will be written to config file for release", @opt_filters);
307
    Message("Filters supplied on Command line will be written to config file for release", @opt_filters);
302
    @confFilters = @opt_filters;
308
    @confFilters = ();
-
 
309
    foreach my $element (@opt_filters) {
-
 
310
        UniquePush (\@confFilters, $_ ) foreach  ( split(/,/, $element));
-
 
311
    }
303
    $writeConf = 1;
312
    $writeConf = 1;
304
}
313
}
305
elsif ( $#opt_filters == -1 && $#confFilters > -1 )
314
elsif ( $#opt_filters == -1 && $#confFilters > -1 )
306
{
315
{
307
    Message("Filters loaded from config file for release will be used", @confFilters) if ( IsVerbose(1) );
316
    Message("Filters loaded from config file for release will be used", @confFilters) if ( IsVerbose(1) );
Line 309... Line 318...
309
elsif ( $#opt_filters == -1 && $#confFilters == -1 )
318
elsif ( $#opt_filters == -1 && $#confFilters == -1 )
310
{
319
{
311
    Error("No Filters supplied on command line or release config file");
320
    Error("No Filters supplied on command line or release config file");
312
}
321
}
313
 
322
 
-
 
323
if ( @opt_addFilters )
-
 
324
{
-
 
325
    Message ("Adding command line filters to the release config file");
-
 
326
    foreach my $element (@opt_addFilters) {
-
 
327
        UniquePush (\@confFilters, $_ ) foreach  ( split(/,/, $element));
-
 
328
    }
-
 
329
    $writeConf = 1;
-
 
330
}
-
 
331
 
-
 
332
if ( @opt_delFilters )
-
 
333
{
-
 
334
    Message ("Deleting command line filters to the release config file");
-
 
335
    foreach my $element (@opt_delFilters) {
-
 
336
        ArrayDelete (\@confFilters, $_ ) foreach  ( split(/,/, $element));
-
 
337
    }
-
 
338
    $writeConf = 1;
-
 
339
}
-
 
340
 
314
Message("Copying packages from $ENV{GBE_DPKG} to $projectDestDir");
341
Message("Copying packages from $ENV{GBE_DPKG} to $projectDestDir");
315
 
342
 
316
if ( ! -d $projectDestDir )
343
if ( ! -d $projectDestDir )
317
{
344
{
318
    if ( defined($opt_test) )
345
    if ( defined($opt_test) )
Line 367... Line 394...
367
                    # the filelist array of files to copy
394
                    # the filelist array of files to copy
368
                    foreach my $filter ( @confFilters )
395
                    foreach my $filter ( @confFilters )
369
                    {
396
                    {
370
                        foreach my $srcPath ( glob("$srcDir/$filter") )
397
                        foreach my $srcPath ( glob("$srcDir/$filter") )
371
                        {
398
                        {
-
 
399
                            next unless ( -f $srcPath );
372
                            $foundFiltered = 1;
400
                            $foundFiltered = 1;
-
 
401
                            $filtersUsed{$filter} = 1;
373
                            my $srcFile = basename($srcPath);
402
                            my $dstFile = basename($srcPath);
-
 
403
                            my $srcFile = $srcPath;
-
 
404
                            $srcFile =~ s~^$srcDir/~~;
374
                            push(@filelist, $srcFile) if ( ! -f "$dstDir/$srcFile" )
405
                            push(@filelist, $srcFile) if ( ! -f "$dstDir/$dstFile" );
375
                        }
406
                        }
376
                    }
407
                    }
377
                    
408
                    
378
                    # if no files found using filters then issue warning
409
                    # if no files found using filters then issue warning
379
                    if ( $foundFiltered == 0 )
410
                    if ( $foundFiltered == 0 )
380
                    {
411
                    {
381
                        Warning("No Files found for Package Version $PKG_NAME/$PKG_VERSION using supplied filters");
412
                        Warning("No Files found for Package Version $PKG_NAME/$PKG_VERSION using supplied filters");
382
                    }
413
                    }
383
                    #else we have found filtered files but they may already exist and if so filelist may be empty, so check it b4 doing anything
414
                    # else we have found filtered files but they may already exist
-
 
415
                    # if so filelist may be empty, so check it b4 doing anything
384
                    elsif ( $#filelist > -1 )
416
                    elsif ( $#filelist > -1 )
385
                    {
417
                    {
386
                        Message("Copying files for package $PKG_NAME version $PKG_VERSION");
418
                        Message("Copying files for package $PKG_NAME version $PKG_VERSION");
387
                        if ( defined($opt_test) )
419
                        if ( defined($opt_test) )
388
                        {
420
                        {
Line 412... Line 444...
412
                {
444
                {
413
                    # However if srcDir does not exist but pkgDir does exist then the package version is missing which maybe an issue
445
                    # However if srcDir does not exist but pkgDir does exist then the package version is missing which maybe an issue
414
                    Warning("Missing Version $PKG_VERSION for Package $PKG_NAME in dpkg_archive");
446
                    Warning("Missing Version $PKG_VERSION for Package $PKG_NAME in dpkg_archive");
415
                }
447
                }
416
            }
448
            }
-
 
449
 
-
 
450
            #
-
 
451
            #   Report filter elements that where not used.
-
 
452
            #
-
 
453
            my @notUsed;
-
 
454
            foreach my $filter ( @confFilters )
-
 
455
            {
-
 
456
                next if ( exists $filtersUsed{$filter} );
-
 
457
                push @notUsed, $filter
-
 
458
            }
-
 
459
            Warning ("Unused filter rules:", @notUsed )
-
 
460
                if ( @notUsed );
-
 
461
 
417
        }
462
        }
418
        else
463
        else
419
        {
464
        {
420
            Error("No Boms found for Deployment Manager SBomId(s) " . join(",", @opt_sbom_ids) );
465
            Error("No Boms found for Deployment Manager SBomId(s) " . join(",", @opt_sbom_ids) );
421
        }
466
        }
Line 466... Line 511...
466
                       - from the Deployment Manager Project Name
511
                       - from the Deployment Manager Project Name
467
    -releasedir=xxx    - Override the project release directory name that normally 
512
    -releasedir=xxx    - Override the project release directory name that normally 
468
                       - comes from the Deployment Manager Project Release Name
513
                       - comes from the Deployment Manager Project Release Name
469
    -filter=xxx        - Specifies a shell wildcard used to filter package files to copy
514
    -filter=xxx        - Specifies a shell wildcard used to filter package files to copy
470
                       - Can be specified multiple times to use multiple filters
515
                       - Can be specified multiple times to use multiple filters
-
 
516
    -addfilter=xxx     - Add a new filter to the existing filter set
-
 
517
    -delfilter=xxx     - Delete a filter from the existing filter set
471
    -test              - Just log actions without copying files.
518
    -test              - Just log actions without copying files.
472
    -verbose           - Enable verbose output
519
    -verbose           - Enable verbose output
473
 
520
 
474
=head1 OPTIONS
521
=head1 OPTIONS
475
 
522
 
Line 527... Line 574...
527
 
574
 
528
If the option is specified it must be used with the -projectdir option and must be a directory 
575
If the option is specified it must be used with the -projectdir option and must be a directory 
529
name that exists in the projectdir.
576
name that exists in the projectdir.
530
Additionally if used to populate a release then it must always be used to update the release.
577
Additionally if used to populate a release then it must always be used to update the release.
531
 
578
 
532
=item B<-filter=xxx>
579
=item B<-filter=xxx[,yyy]>
533
 
580
 
534
This option specifies a shell wildcard filter rule that is used to determine which files are
581
This option specifies a comma separated list of shell wildcard filter rule that
535
copied from package version directory in GBE_DPKG to the release directory.  This can be 
582
is used to determine which files are copied from package version directory in
-
 
583
GBE_DPKG to the release directory. This can be supplied multiple times to
536
supplied multiple times to specify rules for copying.
584
specify rules for copying.
537
 
585
 
538
This must be specified on the command line the first time this command is run against a release 
586
This must be specified on the command line the first time this command is run against a release 
539
and packages are copied to the project/release directory.  These values are then written to a 
587
and packages are copied to the project/release directory.  These values are then written to a 
540
config file in the project/release directory so the same values can be used on subsequent runs.  
588
config file in the project/release directory so the same values can be used on subsequent runs.  
541
In these subsequent runs this option need not be specified as the config items will be used, however
589
In these subsequent runs this option need not be specified as the config items will be used, however
Line 544... Line 592...
544
The values of these will depend on what builds are required for each project.  Some examples are
592
The values of these will depend on what builds are required for each project.  Some examples are
545
--filter='*-SOLARIS10_SPARC64-[DP].pkg.gz'
593
--filter='*-SOLARIS10_SPARC64-[DP].pkg.gz'
546
--filter='*-SOLARIS10_SPARC86-[DP].pkg.gz'
594
--filter='*-SOLARIS10_SPARC86-[DP].pkg.gz'
547
--filter='*-SOLARIS10_X64-[DP].pkg.gz'
595
--filter='*-SOLARIS10_X64-[DP].pkg.gz'
548
--filter='*-SOLARIS10_X86-[DP].pkg.gz'
596
--filter='*-SOLARIS10_X86-[DP].pkg.gz'
549
--filter='*-WIN32.exe'
597
--filter='*-WIN32.exe,*.deb'
-
 
598
--filter='scripts/*.sh'
-
 
599
 
-
 
600
=item B<-addFilter=xxx[,yyy]>
-
 
601
 
-
 
602
This option allows new filters to be added to an existing set of filters. This
-
 
603
option can be specified multiple times.
-
 
604
 
-
 
605
=item B<-delFilter=xxx[,yyy]>
-
 
606
 
-
 
607
This option deletes one or more filter rules from an existing set of filters. This
-
 
608
option can be specified multiple times.
550
 
609
 
551
=item B<-test>
610
=item B<-test>
552
 
611
 
553
This option will display what would be copied without actually copying anything
612
This option will display what would be copied without actually copying anything
554
 
613