Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
227 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
227 dpurdie 3
#
263 dpurdie 4
# Module name   : jats_sandbox.pl
5
# Module type   : JATS Utility
6
# Compiler(s)   : Perl
7
# Environment(s): JATS
227 dpurdie 8
#
9
# Description   : A script to build a collection of packages in the
10
#                 same sandbox. This script will:
11
#
12
#                   Determine the packages in the sandbox
13
#                   Determine the build order of the packages
14
#                   Build the packages in the correct order
15
#                   Make the packages in the correct order
16
#
17
#                 The script will allow for:
18
#                   The creation of a sandbox
19
#                   The addition of packages to the sandbox
20
#                   Removal of packages from the sandbox
21
#
22
#
23
#                 Command syntax (basic)
24
#                   jats sandbox <command> (options | actions)@
25
#
26
#                 Commands include:
27
#                   create              - Create a sandbox
28
#                   delete              - Delete a sandbox
337 dpurdie 29
#                   info                - Show sandbox info
227 dpurdie 30
#
31
#                   build               - Build all packages in the sandbox
32
#                   make                - make all packages in the sandbox
33
#
34
#......................................................................#
35
 
263 dpurdie 36
require 5.008_002;
227 dpurdie 37
use strict;
38
use warnings;
39
use JatsError;
40
use JatsSystem;
41
use FileUtils;
245 dpurdie 42
use JatsBuildFiles;
227 dpurdie 43
use JatsVersionUtils;
4197 dpurdie 44
use ArrayHashUtils;
6133 dpurdie 45
use ToolsetFiles;
227 dpurdie 46
 
47
use Pod::Usage;                             # required for help support
48
use Getopt::Long qw(:config require_order); # Stop on non-option
6133 dpurdie 49
use Digest;
50
 
227 dpurdie 51
my $VERSION = "1.0.0";                      # Update this
6192 dpurdie 52
my $SCANDEPTH = 3;                          # Almost a constant
227 dpurdie 53
 
54
#
55
#   Options
56
#
57
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
58
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
359 dpurdie 59
my $opt_help = 0;                           # Help level
60
my $opt_exact = 0;                          # Exact (escrow) build
1329 dpurdie 61
my $opt_toPackage;                          # Control recursion
62
my $opt_fromPackage;                        # Control recursion
63
my @opt_justPackage;                        # Control recursion
64
my @opt_ignorePackage;                      # Control recursion
6133 dpurdie 65
my $opt_allSandbox;                         # Extend scope to entire sandbox
66
my $opt_processUsedBy;                      # Process dependants(consumers) not dependents(children)
67
my $opt_keepgoing;                          # Ignore errors
68
my $opt_reScan;                             # Rescan for buildfiles
6198 dpurdie 69
my $opt_multiBuilders = 0;                  # How handle packages with multiple bulders: 0:Error, 1:Report, 2:Ignore
6276 dpurdie 70
my $opt_onlyLevel = 0;                      # Single level processing
227 dpurdie 71
 
72
#
73
#   Globals - Provided by the JATS environment
74
#
4688 dpurdie 75
my $USER            = $ENV{'USER'};
76
my $UNIX            = $ENV{'GBE_UNIX'};
77
my $HOME            = $ENV{'HOME'};
78
my $GBE_SANDBOX     = $ENV{'GBE_SANDBOX'};
79
my $GBE_DPKG_SBOX   = $ENV{'GBE_DPKG_SBOX'};
80
my $GBE_MACHTYPE    = $ENV{'GBE_MACHTYPE'};
3559 dpurdie 81
my $GBE_BUILDFILTER = $ENV{'GBE_BUILDFILTER'};
335 dpurdie 82
 
4688 dpurdie 83
my $GBE_DPKG_LOCAL      = $ENV{'GBE_DPKG_LOCAL'};
84
my $GBE_DPKG_CACHE      = $ENV{'GBE_DPKG_CACHE'};
85
my $GBE_DPKG            = $ENV{'GBE_DPKG'};
86
my $GBE_DPLY            = $ENV{'GBE_DPLY'};
87
my $GBE_DPKG_STORE      = $ENV{'GBE_DPKG_STORE'};
88
my $GBE_DPKG_REPLICA    = $ENV{'GBE_DPKG_REPLICA'};
6276 dpurdie 89
my $GBE_DPKG_ESCROW     = $ENV{'GBE_DPKG_ESCROW'};
4688 dpurdie 90
 
227 dpurdie 91
#
92
#   Globals
93
#
6192 dpurdie 94
my @stopped = ();                               # Stopped entries
95
my @build_order = ();                           # Build Ordered list of entries
96
my %extern_deps;                                # Hash of external dependencies
97
my %packages;                                   # Hash of packages
98
my $currentPkgTag;                              # Tag of the current package - if any                                          
99
my $scanDepth;                                  # Depth for build file scan
6198 dpurdie 100
my $maxDname = 0;                               # Pretty display
227 dpurdie 101
 
6192 dpurdie 102
#
103
#   Known files
104
#
6276 dpurdie 105
$GBE_DPKG_SBOX = '' unless defined $GBE_DPKG_SBOX;
6192 dpurdie 106
my $cacheFile  = $GBE_DPKG_SBOX . '/location_cache';
107
my $depthFile  = $GBE_DPKG_SBOX . '/scanDepth';
6198 dpurdie 108
my $filterFile = $GBE_DPKG_SBOX . '/buildfilter';
6192 dpurdie 109
 
227 dpurdie 110
#-------------------------------------------------------------------------------
111
# Function        : Mainline Entry Point
112
#
113
# Description     :
114
#
115
# Inputs          :
116
#
117
 
118
#
119
#   Process help and manual options
120
#
1329 dpurdie 121
my $result = getOptionsFromArray ( \@ARGV );
227 dpurdie 122
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
123
pod2usage(-verbose => 1)  if ($opt_help == 2 );
299 dpurdie 124
pod2usage(-verbose => 2)  if ($opt_help > 2 );
227 dpurdie 125
 
126
#
127
#   Configure the error reporting process now that we have the user options
128
#
129
ErrorConfig( 'name'    => 'SANDBOX',
130
             'verbose' => $opt_verbose );
131
 
132
#
359 dpurdie 133
#   Reconfigure the options parser to allow subcommands to parse options
227 dpurdie 134
#
359 dpurdie 135
Getopt::Long::Configure('permute');
227 dpurdie 136
 
137
#
359 dpurdie 138
#   Determine Sandbox type. Exact or local
139
#
140
$opt_exact = (-f  $GBE_SANDBOX . '/sandbox_dpkg_archive/.exact' )
141
    if ( $GBE_SANDBOX );
142
 
7266 dpurdie 143
#   Flag to subcommands that the build is occuring within a SANDBOX
144
#   Example usage: Prevent gradle subproject inclusion
145
$ENV{'GBE_SANDBOX_BUILD'} = 1;
146
 
359 dpurdie 147
#
227 dpurdie 148
#   Parse the user command and decide what to do
149
#
359 dpurdie 150
#   Remove user command from the command line. This will leave command options
151
#   in @ARGV so that they can be parsed by the subcommand.
227 dpurdie 152
#
153
my $cmd = shift @ARGV || "";
154
help(1)                                 if ( $cmd =~ m/^help$/ || $cmd eq "" );
359 dpurdie 155
buildcmd($cmd, @ARGV )                  if ( $cmd =~ m/(^all$)|(^build$)/  );
156
cache(@ARGV)                            if ( $cmd =~ m/^cache$/  );
157
clean($cmd, @ARGV)                      if ( $cmd =~ m/(^clobber$)|(^clean$)/  );
158
cmd('make', $cmd, @ARGV )               if ( $cmd =~ m/(^make$)/  );
159
cmd('cmd', @ARGV)                       if ( $cmd =~ m/^cmd$/ );
160
create_sandbox()                        if ( $cmd =~ m/^create$/ );
299 dpurdie 161
delete_sandbox()                        if ( $cmd =~ m/^delete$/ );
227 dpurdie 162
info(@ARGV)                             if ( $cmd =~ m/^info$/ );
359 dpurdie 163
populate(@ARGV)                         if ( $cmd =~ m/^populate$/  );
4197 dpurdie 164
buildfilter(@ARGV)                      if ( $cmd =~ m/^buildfilter$/  );
6133 dpurdie 165
skipBuild(0, @ARGV)                     if ( $cmd =~ m/^skip$/  );
166
skipBuild(1, @ARGV)                     if ( $cmd =~ m/^unskip$/  );
167
fingerPrintPkg(@ARGV)                   if ( $cmd =~ m/^finger/i );
6192 dpurdie 168
testLinks(@ARGV)                        if ( $cmd =~ m/^testlinks/i );
169
setScanDepth(@ARGV)                     if ( $cmd =~ m/^scandepth/i );
227 dpurdie 170
 
171
Error ("Unknown sandbox command: $cmd");
172
exit 1;
173
 
174
 
175
#-------------------------------------------------------------------------------
176
#
177
#   Give the user a clue
178
#
179
sub help
180
{
181
    my ($level) = @_;
182
    $level = $opt_help unless ( $level );
183
 
184
    pod2usage(-verbose => 0, -message => "Version: ". $VERSION)  if ($level == 1 );
185
    pod2usage(-verbose => $level -1 );
186
}
187
 
188
#-------------------------------------------------------------------------------
189
# Function        : create_sandbox
190
#
191
# Description     : create a sandbox in the current current directory
192
#
193
# Inputs          : None
194
#
195
#
196
sub create_sandbox
197
{
6619 dpurdie 198
    my  $opt_force;
359 dpurdie 199
    GetOptions (
200
                "help:+"        => \$opt_help,
201
                "manual:3"      => \$opt_help,
202
                "exact"         => \$opt_exact,
6619 dpurdie 203
                "force!"        => \$opt_force,
359 dpurdie 204
                ) || Error ("Invalid command line" );
205
 
206
    SubCommandHelp( $opt_help, "Create Sandbox") if ($opt_help || $#ARGV >= 0 );
207
 
227 dpurdie 208
    Error ("Cannot create a sandbox within a sandbox",
6619 dpurdie 209
           "Sandbox base is: $GBE_SANDBOX" ) if ( $GBE_SANDBOX && !$opt_force );
359 dpurdie 210
 
227 dpurdie 211
    mkdir ('sandbox_dpkg_archive') || Error ("Cannot create the directory: sandbox_dpkg_archive") ;
359 dpurdie 212
 
213
    TouchFile( 'sandbox_dpkg_archive/.exact', 'Sandbox marker file')
214
        if ($opt_exact);
215
 
216
    Message ('Sandbox created' . ($opt_exact ? ' - With exact version number processing' : ''));
227 dpurdie 217
    exit  0;
218
}
219
 
220
#-------------------------------------------------------------------------------
299 dpurdie 221
# Function        : delete_sandbox
222
#
223
# Description     : Delete a sandbox
224
#                   Its up to the user the delete the components in the sandbox
225
#
226
# Inputs          : None
227
#
361 dpurdie 228
# Returns         :
299 dpurdie 229
#
230
sub delete_sandbox
231
{
359 dpurdie 232
    GetOptions (
233
                "help:+"        => \$opt_help,
234
                "manual:3"      => \$opt_help,
235
                ) || Error ("Invalid command line" );
236
 
237
    SubCommandHelp( $opt_help, "Delete Sandbox") if ($opt_help || $#ARGV >= 0 );
238
 
299 dpurdie 239
    unless ( $GBE_SANDBOX )
240
    {
241
        Warning("No sandbox found to delete");
242
    }
243
    else
244
    {
365 dpurdie 245
        Error ("Sandbox directory not completely removed")
361 dpurdie 246
            if RmDirTree( "$GBE_SANDBOX/sandbox_dpkg_archive" );
299 dpurdie 247
 
248
        Message("Sandbox information deleted",
249
                "Sandbox components must be manually deleted");
250
    }
251
    exit 0;
252
}
253
 
254
#-------------------------------------------------------------------------------
6133 dpurdie 255
# Function        : skipBuild 
256
#
257
# Description     : Mark the building of a package for skipping
258
#
259
# Inputs          : Mode -: Skip, 1:Unskip
260
#                   User commaand line 
261
#
262
# Returns         : Nothing
263
#
264
sub skipBuild
265
{
266
    my ($mode, @cmd_opts ) = @_;
267
    my $machine;
268
 
269
    Getopt::Long::Configure('pass_through');
270
    getOptionsFromArray ( \@cmd_opts,
271
                        'machine!' => \$machine,
272
                        ) || Error ("Invalid command line" );
273
 
274
    SubCommandHelp( $opt_help, "Skip Build") if ($opt_help );
275
    Error ("Command must be executed from within a Sandbox") unless ( $GBE_SANDBOX );
276
 
277
    #
278
    #   Determine Sandbox information
279
    #   Populate global variables
280
    #
281
    calc_sandbox_info(1);
282
 
283
    #
284
    #   Display only
285
    #   
286
    unless( @cmd_opts)
287
    {
288
        foreach my $pkg (keys %packages)
289
        {
290
            my $fe = $packages{$pkg};
291
            next unless $fe->{buildSkip};
292
 
293
            my $skipMsg = ($fe->{buildSkip}) ? ' (Build Skipped)' : ' (Build Suppressed)';
294
            if ($fe->{buildCurrent}) {
295
                $skipMsg .= ' (Current Package)';
296
            }
297
 
298
            Message( ' Name: ' . $fe->{dname} . $skipMsg );
299
 
300
        }
301
        exit 0;
302
    }
303
 
304
    foreach ( @cmd_opts )
305
    {
306
        #
307
        #   Locate the package
308
        #
309
        my $pe;
310
        if ($currentPkgTag && ($_ eq '.'))
311
        {
312
            if (exists $packages{$currentPkgTag})
313
            {
314
                $pe = $packages{$currentPkgTag}; 
315
            }
316
        }
317
        unless ($pe) {
318
            foreach my $pkg (keys %packages)
319
            {
320
                my $entry = $packages{$pkg};
321
                if ($entry->{dname} eq $_ || $entry->{fname} eq $_ )
322
                {
323
                    $pe = $entry;
324
                    last;
325
                }
326
            }
327
        }
328
 
329
        unless ($pe) {
330
            Warning("No package found matching: $_");
331
            next;
332
        }
333
 
334
        my $skipFile;
335
        if ($machine) {
336
            $skipFile = catdir($GBE_SANDBOX, 'sandbox_dpkg_archive', '_skip.' . $GBE_MACHTYPE . '.' . $pe->{dname});
337
        } else {
338
            $skipFile = catdir($GBE_SANDBOX, 'sandbox_dpkg_archive', '_skip.'. $pe->{dname});
339
        }
340
        Verbose("SkipFile: $skipFile");
341
        if ($mode)
342
        {
343
            unlink $skipFile;
344
        }
345
        else
346
        {
347
            TouchFile($skipFile);
348
        }
349
    }
350
    exit 0;
351
}
352
 
353
#-------------------------------------------------------------------------------
227 dpurdie 354
# Function        : info
355
#
356
# Description     : Display Sandbox information
357
#
358
# Inputs          : Command line args
359
#                   -v  - Be more verbose
360
#
361
# Returns         : Will exit
362
#
363
sub info
364
{
1329 dpurdie 365
    my (@cmd_opts ) = @_;
366
    my $show = 0;
6133 dpurdie 367
    my $showUsage = 0;
368
    my $showFingerPrint = 0;
6192 dpurdie 369
    my $showDependencies = 1;
370
    my $showOrder = 1;
6198 dpurdie 371
    my $showPath = 0;
227 dpurdie 372
 
1329 dpurdie 373
    Getopt::Long::Configure('pass_through');
374
    getOptionsFromArray ( \@cmd_opts,
6192 dpurdie 375
                          'verbose:+'       => \$show,
376
                          'usedby'          => \$showUsage,
377
                          'fingerprint!'    => \$showFingerPrint,
378
                          'dependencies!'   => \$showDependencies,
379
                          'buildorder!'     => \$showOrder,
6198 dpurdie 380
                          'path!'           => \$showPath,
1329 dpurdie 381
                        ) || Error ("Invalid command line" );
382
    SubCommandHelp( $opt_help, "Sandbox Information") if ($opt_help || $#cmd_opts >=0 );
6133 dpurdie 383
    $showUsage = 1 if ($show >= 2);
361 dpurdie 384
 
227 dpurdie 385
    #
386
    #   Determine Sandbox information
387
    #   Populate global variables
388
    #
6133 dpurdie 389
    calc_sandbox_info();
227 dpurdie 390
 
391
    #
392
    #   Display information
393
    #
3559 dpurdie 394
    Message ("Type       : " . ($opt_exact ? 'Exact' : 'Development') );
6133 dpurdie 395
    Message ("Scope      : " . ($opt_allSandbox ? 'Entire Sandbox' : $packages{$currentPkgTag}{dname} ));
3559 dpurdie 396
    Message ("Base       : $GBE_SANDBOX");
397
    Message ("Archive    : $GBE_DPKG_SBOX");
6192 dpurdie 398
    Message ("BuildFilter: $GBE_BUILDFILTER" . ( (-f $filterFile)  ? ' - Local to sandbox' : ''));
227 dpurdie 399
 
6192 dpurdie 400
    if ($showOrder)
1329 dpurdie 401
    {
6192 dpurdie 402
        Message ("Build Order");
6198 dpurdie 403
        foreach my $pname ( @stopped ) {
6192 dpurdie 404
            Message( "    Level:" . "--"  . " [---] Name: " . $pname . ' (Stopped)');
405
        }
6198 dpurdie 406
 
6192 dpurdie 407
        foreach my $fe ( @build_order )
408
        {
6198 dpurdie 409
            displayHeader($fe, { indent => '    ', testFingerPrint =>  $showFingerPrint, showSimplePath => $showPath });
227 dpurdie 410
 
6192 dpurdie 411
            if ( $show )
227 dpurdie 412
            {
6192 dpurdie 413
                Message( DisplayPath ("        Path: $fe->{dir}" ));
414
                foreach my $idep ( sort values %{$fe->{'ideps'}} )
415
                {
416
                    Message ("        I:$idep");
417
                }
227 dpurdie 418
 
6192 dpurdie 419
                foreach my $edep ( sort keys %{$fe->{'edeps'}} )
420
                {
421
                    my ($ppn,$ppv) = split( $; , $edep);
422
                    Message ("        E:$ppn $ppv");
423
                }
227 dpurdie 424
            }
361 dpurdie 425
 
6192 dpurdie 426
            if ($showUsage && exists($fe->{'usedBy'}))
6133 dpurdie 427
            {
6192 dpurdie 428
                foreach my $edep ( sort {uc($a) cmp uc($b)} @{$fe->{'usedBy'}} )
429
                {
430
                    Message ("        U:$packages{$edep}{dname}");
431
                }
6133 dpurdie 432
            }
227 dpurdie 433
        }
434
    }
435
 
359 dpurdie 436
    #
437
    #   External dependencies flags
438
    #       * - Package does not exist in dpkg_archive
439
    #       + - Multiple versions of this package are used
440
 
6192 dpurdie 441
    if ($showDependencies)
227 dpurdie 442
    {
6192 dpurdie 443
        Message("External Dependencies");
444
        foreach my $de ( sort {uc($a) cmp uc($b)} keys %extern_deps )
227 dpurdie 445
        {
6192 dpurdie 446
            my @vlist = keys %{$extern_deps{$de}};
447
            my $flag = $#vlist ? '+' : '';
448
            foreach my $pve ( sort {uc($a) cmp uc($b)} @vlist )
227 dpurdie 449
            {
6192 dpurdie 450
                my ($pn,$pv) = split( $; , $pve );
451
                my $exists = check_package_existance($pn,$pv  ) ? '' : '*';
452
                my $flags = sprintf ("%4.4s", $flag . $exists);
453
                Message ("${flags}${pn} ${pv}");
454
                if ( $show || $showUsage )
227 dpurdie 455
                {
6192 dpurdie 456
                    foreach my $pkg ( sort {uc($a) cmp uc($b)} @{$extern_deps{$de}{$pve}} )
457
                    {
458
                        my $ppn = join ('.', split( $; , $pkg));
459
                        Message ("        U:$ppn");
460
                    }
227 dpurdie 461
                }
6192 dpurdie 462
 
227 dpurdie 463
            }
464
        }
465
    }
466
 
1329 dpurdie 467
    if ( $show > 2 || $opt_verbose > 2 )
227 dpurdie 468
    {
469
        DebugDumpData( "extern_deps", \%extern_deps);
470
        DebugDumpData( "build_order", \@build_order);
471
        DebugDumpData( "packages", \%packages);
472
    }
473
    exit (0);
474
}
475
 
476
#-------------------------------------------------------------------------------
6133 dpurdie 477
# Function        : fingerPrintPkg 
478
#
479
# Description     : Various finger print operations on the current package
480
#
481
# Inputs          : @ARGV   - Arguments
482
#
483
# Returns         : WIll not return
484
#
485
sub fingerPrintPkg
486
{
487
    my ( @cmd_opts ) = @_;
488
    my $opt_generate;
489
    my $opt_delete;
490
 
491
    Getopt::Long::Configure('pass_through');
492
    getOptionsFromArray ( \@cmd_opts,
493
                          'generate!' => \$opt_generate,
494
                          'delete!'   => \$opt_delete,
495
                        ) || Error ("Invalid command line" );
496
 
497
    SubCommandHelp( $opt_help, "Sandbox Finger Print") if ($opt_help );
498
    Error ("Command must be executed from within a Sandbox") unless ( $GBE_SANDBOX );
499
 
500
    #
501
    #   Determine Sandbox information
502
    #   Populate global variables
503
    #
504
    calc_sandbox_info(1);
505
 
506
    #
507
    #   Determine the named packages, or use the current package
508
    #
509
    my @pkgList;
510
    if (@cmd_opts)
511
    {
512
        @pkgList = @cmd_opts;
513
    }
514
    else
515
    {
516
        if ( $currentPkgTag )
517
        {
518
            if (exists $packages{$currentPkgTag})
519
            {
520
                push @pkgList, $packages{$currentPkgTag}{fname};
521
            }
522
        }
523
    }
524
    Error ("Command must be used within a package, or with named packages.") 
525
        unless @pkgList;
526
 
527
 
528
    #
529
    #   Process all required packages
530
    #
531
    foreach my $pkgName ( @pkgList)
532
    {
533
        #
534
        #   Locate the package
535
        #
536
        my $pe;
537
        foreach my $pkg (keys %packages)
538
        {
539
            my $entry = $packages{$pkg};
540
            if ($entry->{dname} eq $pkgName || $entry->{fname} eq $pkgName )
541
            {
542
                $pe = $entry;
543
                last;
544
            }
545
        }
546
 
547
        unless ( $pe ) {
548
            Warning ("Cannot locate package: $pkgName");
549
            next;
550
        }
551
 
552
        #
553
        #   Recalculate finger print
554
        #
555
        my $tagFile = getPkgFingerPrintFile($pe);
556
        if ($opt_generate)
557
        {
558
            my $ifaceDir = getpkgInterface($pe);
559
            if ($ifaceDir)
560
            {
561
                Message ("Generate Fingerprint");
6198 dpurdie 562
                Verbose ("Fingerprint file: $tagFile");
6133 dpurdie 563
                FileCreate( $tagFile, genPkgFingerPrint($pe,'Generation') );
564
            }
565
            else
566
            {
567
                Warning("Package has not been built. Cannot generate fingerprint: $pkgName");
568
            }
569
        }
570
        elsif ($opt_delete)
571
        {
572
            unlink $tagFile;
573
            Message ("Fingerprint file removed");
574
        }
575
        else
576
        {
577
            #
578
            #   Test the finger print on the current package
579
            #
580
            if ( -e $tagFile )
581
            {
582
                if ( TagFileMatch($tagFile, genPkgFingerPrint($pe, 'Test')) )
583
                {
584
                    Message ("Fingerprint match");
585
                }
586
                else
587
                {
588
                    Message("Fingerprint missmatch");
589
                }
590
            }
591
            else
592
            {
593
                Message ("Package does not have a fingerprint file");
594
            }
595
        }
596
    }
597
 
598
    exit (0);
599
}
600
 
6192 dpurdie 601
#-------------------------------------------------------------------------------
602
# Function        : testLinks 
603
#
604
# Description     : Test the lnk files in the sandbox directory
605
#                   These may be stake after packages are deleted
606
#
607
# Inputs          : 
608
#
609
# Returns         : This function will not return
610
#
611
sub testLinks
612
{
613
    my ( @cmd_opts ) = @_;
614
    my $opt_delete;
6133 dpurdie 615
 
6192 dpurdie 616
    GetOptions (
617
                "help:+"        => \$opt_help,
618
                "manual:3"      => \$opt_help,
619
                'delete!'       => \$opt_delete,
620
                ) || Error ("Invalid command line" );
621
 
622
    SubCommandHelp( $opt_help, "Sandbox Test Links") if ($opt_help || ($#ARGV >= 0) );
623
    Error ("Command must be executed from within a Sandbox") unless ( $GBE_SANDBOX );
624
 
625
    #
626
    #   Process all packages in the sandbox
627
    #
628
    foreach my $linkFile ( glob "$GBE_DPKG_SBOX/*/*.lnk")
629
    {
6276 dpurdie 630
        my $pkg = getPackageLink( TagFileRead($linkFile) );
6192 dpurdie 631
        unless ( -d $pkg )
632
        {
633
            if ($opt_delete)
634
            {
635
                Message ("Delete: $linkFile");
636
                unlink $linkFile;
637
            } 
638
            else
639
            {
640
                Message ("Broken link: $pkg", "Source link: $linkFile" );
641
            }
642
        }
643
 
644
    }
645
 
646
    exit (0);
647
}
648
 
6133 dpurdie 649
#-------------------------------------------------------------------------------
6276 dpurdie 650
# Function        : getPackageLink 
651
#
652
# Description     : Read a package link file and process the data to generate 
653
#                   the link to the package
654
#
655
# Inputs          : $linkFile   - File that contains the link
656
#
657
# Returns         : The resolved link
658
#
659
sub getPackageLink
660
{
661
    my ($linkFile) = @_;
662
    my $pkg = TagFileRead($linkFile);
663
    $pkg =~ s~\\~/~g;
664
    if ($pkg =~ s~^GBE_SANDBOX/~$GBE_SANDBOX/~)
665
    {
666
            # If the target sandbox is in the 'deploymode' then the package
667
            # will not be in the expected location. It will be in a 'build/deploy'
668
            # subdir. Remove the pkg/name dir to get to the root of the package
669
            my @dirs = File::Spec->splitdir( $pkg );
670
            splice(@dirs, -2);
671
            my $deployBox = catdir(@dirs, 'build', 'deploy');
672
            $pkg = $deployBox if ( -d $deployBox);
673
    }
674
 
675
    return $pkg;
676
}
677
 
678
 
679
#-------------------------------------------------------------------------------
6192 dpurdie 680
# Function        : setScanDepth 
681
#
682
# Description     : Set the depth of the build file scan usd in this sandbox 
683
#
684
# Inputs          : Command line arguments
685
#
686
# Returns         : This function will not return
687
#
688
sub setScanDepth
689
{
690
    my ( @cmd_opts ) = @_;
691
    GetOptions (
692
                "help:+"        => \$opt_help,
693
                "manual:3"      => \$opt_help,
694
                ) || Error ("Invalid command line" );
695
 
696
    SubCommandHelp( $opt_help, "Sandbox Scan Depth") if ($opt_help || ($#ARGV > 0 ));
697
    Error ("Command must be executed from within a Sandbox") unless ( $GBE_SANDBOX );
698
 
699
    if (defined $ARGV[0])
700
    {
701
        FileCreate($depthFile, $ARGV[0]);
702
 
703
        #
704
        #   Force a rescan of the cached information
705
        #
706
        unlink $cacheFile;
707
        exit 0;
708
    }
709
 
710
    #
711
    #   Report the current scan depth
712
    #
713
    getScanDepth();
714
    Information ("Build File scan depth: ". $scanDepth);
715
    exit (0);
716
 
717
}
718
 
719
#-------------------------------------------------------------------------------
720
# Function        : getScanDepth  
721
#
722
# Description     : Determine the build file scan depth for the current sandbox
723
#                   Non-default data is maintained in a data file    
724
#
725
# Inputs          : None
726
#
727
# Returns         : Nothing
728
#
729
 
730
sub getScanDepth
731
{
732
    my $depth = $SCANDEPTH;
733
    if ( -f $depthFile)
734
    {
735
        $depth = TagFileRead($depthFile);
736
        my $invalid = 0;
737
        if ($depth !~ m~^\d+$~) {
738
            $invalid = 1;
739
        } elsif ( $depth lt 0) {
740
            $invalid = 1;
741
        }
742
 
743
        if ($invalid)
744
        {
745
            unlink $depthFile;
746
            Warning ("Invalid scandepth file. File deleted.");
747
            $depth = $SCANDEPTH;
748
        }
749
    }
750
    $scanDepth = $depth;
751
}
752
 
753
 
754
#-------------------------------------------------------------------------------
335 dpurdie 755
# Function        : check_package_existance
756
#
757
# Description     : Determine if a given package-version exists
758
#
759
# Inputs          : $name           - Package Name
760
#                   $ver            - Package Version
761
#
762
# Returns         : true            - Package exists
763
#
764
sub check_package_existance
765
{
766
    my ($name, $ver) = @_;
767
    #
768
    #   Look in each package archive directory
769
    #
770
    foreach my $dpkg ( $GBE_DPKG_SBOX,
771
                       $GBE_DPKG_LOCAL,
772
                       $GBE_DPKG_CACHE,
6276 dpurdie 773
                       $GBE_DPKG_ESCROW,
774
                       '--NotEscrow',
4688 dpurdie 775
                       $GBE_DPKG_REPLICA,
335 dpurdie 776
                       $GBE_DPKG,
777
                       $GBE_DPLY,
778
                       $GBE_DPKG_STORE )
779
    {
780
        next unless ( $dpkg );
6276 dpurdie 781
        if ( $dpkg eq '--NotEscrow' )
782
        {
783
            last if ($GBE_DPKG_ESCROW);
784
            next;
785
        }
786
 
335 dpurdie 787
        if ( -d "$dpkg/$name/$ver" )
788
        {
7009 dpurdie 789
            Verbose("Exists: $dpkg/$name/$ver");
335 dpurdie 790
            return 1;
791
        }
792
    }
793
   return 0;
794
}
795
 
6133 dpurdie 796
#-------------------------------------------------------------------------------
797
# Function        : getpkgInterface 
798
#
799
# Description     : Locate the packages interface directory 
800
#
801
# Inputs          : $fe     - Package Entry 
802
#
803
# Returns         : Undef if not found
804
#                   Path to the packages interface directory
805
#
806
sub getpkgInterface
807
{
808
    my ($fe) = @_;
335 dpurdie 809
 
6133 dpurdie 810
    #
811
    #   Determine the packages 'interface' directory
812
    #
813
    my $pSuffix = ($fe->{prj}) ? ( '.' . $fe->{prj}) : '';
814
    my $ifaceDir = catdir($GBE_SANDBOX, 'sandbox_dpkg_archive', $fe->{name}, 'sandbox' . $pSuffix . '.int');
815
    return unless -f $ifaceDir; 
816
    $ifaceDir = TagFileRead($ifaceDir);
817
    $ifaceDir =~ s~\\~/~g;
818
    $ifaceDir =~ s~GBE_SANDBOX/~$GBE_SANDBOX/~;
819
    return $ifaceDir; 
820
}
821
 
822
 
335 dpurdie 823
#-------------------------------------------------------------------------------
227 dpurdie 824
# Function        : calc_sandbox_info
825
#
826
# Description     : Examine the sandbox and determine all the important
827
#                   information
828
#
1329 dpurdie 829
#                   Operation will be modified by
830
#                       $opt_toPackage
831
#                       $opt_fromPackage
832
#                       @opt_justPackage
833
#                       @opt_ignorePackage
6276 dpurdie 834
#                       $opt_onlyLevel
227 dpurdie 835
#
6133 dpurdie 836
# Inputs          : quiet       undef - noisy
837
#                               1 - quiet           
1329 dpurdie 838
#
227 dpurdie 839
# Returns         : Will exit if not in a sandbox
840
#                   Populates global variables
841
#                       @build_order - build ordered array of build entries
842
#
843
sub calc_sandbox_info
844
{
6133 dpurdie 845
    my ($quiet) = @_;
6198 dpurdie 846
    my $buildFileDepth = 0;
6192 dpurdie 847
    getScanDepth();
848
 
227 dpurdie 849
    #
850
    #   Start from the root of the sandbox
851
    #
852
    Error ("Command must be executed from within a Sandbox") unless ( $GBE_SANDBOX );
6133 dpurdie 853
    my $startDir = Getcwd();
227 dpurdie 854
    chdir ($GBE_SANDBOX) || Error ("Cannot chdir to $GBE_SANDBOX");
855
 
856
    #
6133 dpurdie 857
    #   Retain subdir so we can figure out a starting package
858
    # 
859
    $startDir = '' unless ($startDir =~ s~^$GBE_SANDBOX/~~);
860
 
861
    #
227 dpurdie 862
    #   Locate all packages within the sandbox
863
    #   These will be top-level directories - one per package
864
    #
865
    my @build_list;
6133 dpurdie 866
    my $currentRootFingerPrint = calc_rootFingerPrint();
867
 
868
    if (-f $cacheFile && !$opt_reScan) 
227 dpurdie 869
    {
6133 dpurdie 870
        #
871
        #   Read in the location cache
872
        #   Greatly speeds up the location process
873
        #
874
        open( my $lf, '<', $cacheFile) || Error ("Read error: $cacheFile. $!");
275 dpurdie 875
 
6133 dpurdie 876
        #
877
        #   Check root directory signature
878
        #       Has the user added or removed packages from the sandbox
879
        #
880
        my $rootFingerPrint = <$lf>;
881
        $rootFingerPrint =~ s~\s*$~~;
882
 
883
        if ($rootFingerPrint eq $currentRootFingerPrint )
275 dpurdie 884
        {
6133 dpurdie 885
            while (<$lf>)
886
            {
6192 dpurdie 887
                s~\s+$~~;
6133 dpurdie 888
                my @locationEntry = split($;, $_);
889
                my $pname = $locationEntry[0];
6192 dpurdie 890
                if ($locationEntry[1] eq ':STOP:') {
891
                    push @stopped, $pname;
892
                    Verbose("Package contains stop file: $pname");
893
                    next;
894
                }
6133 dpurdie 895
 
896
                #
897
                #   Locate the build files in each package
898
                #   Scan the build files and extract dependancy information
899
                #
900
                my $bscanner = BuildFileScanner( $pname, 'build.pl',
901
                                                         '--LocateAll',
6192 dpurdie 902
                                                         '--LimitDepth=' . $scanDepth,
7213 dpurdie 903
                                                         '--ScanDependencies', 
904
                                                         '--Stop' );
6133 dpurdie 905
                unless ($bscanner->setLocation($_)) {
906
                    Verbose("Build file missing: Force full scan");
907
                    @build_list = ();
908
                    last;
909
                }
910
                $bscanner->scan();
911
                my @blist = $bscanner->getInfo();
912
                unless ($quiet) {
913
                    Warning ("Package does not have build files: $pname") unless ( @blist );
914
                    Warning ("Package has multiple build files: $pname") if ( $#blist > 0 );
915
                }
916
                push @build_list, @blist;
917
            }
275 dpurdie 918
        }
6133 dpurdie 919
        close $lf;
920
    }
275 dpurdie 921
 
6133 dpurdie 922
    unless (@build_list)
923
    {
924
        Message ("Scanning sandbox for build files");
925
        FileCreate($cacheFile, $currentRootFingerPrint );
227 dpurdie 926
 
6133 dpurdie 927
        my @locationData;
928
        foreach my $pname ( glob("*") )
929
        {
930
            next if ( $pname =~ m~^\.~ );
931
            next if ( $pname =~ m~dpkg_archive$~ );
6177 dpurdie 932
            next if ( $pname eq 'CSV' );
933
            next if ( $pname eq 'lost+found' );
6133 dpurdie 934
            next unless ( -d $pname );
6276 dpurdie 935
            if ( -d $pname . '/sandbox_dpkg_archive' ) {
936
                Warning("Nested sandbox ignored: $pname");
937
                next ;
938
            }
6133 dpurdie 939
            Verbose ("Package discovered: $pname");
940
 
941
            if ( -f "$pname/stop" || -f "$pname/stop.$GBE_MACHTYPE" )
942
            {
943
                push @stopped, $pname;
944
                Warning("Package contains stop file: $pname");
6192 dpurdie 945
                push @locationData, join($;, $pname, ':STOP:');
6133 dpurdie 946
                next;
947
            }
948
 
949
            #
950
            #   Locate the build files in each package
951
            #   Scan the build files and extract dependancy information
952
            #
953
            my $bscanner = BuildFileScanner( $pname, 'build.pl',
954
                                                     '--LocateAll',
6192 dpurdie 955
                                                     '--LimitDepth=' . $scanDepth,
7213 dpurdie 956
                                                     '--ScanDependencies',
957
                                                     '--Stop' );
6133 dpurdie 958
            $bscanner->scan();
959
            my @blist = $bscanner->getInfo();
960
            unless ($quiet) {
961
                Warning ("Package does not have build files: $pname") unless ( @blist );
962
                Warning ("Package has multiple build files: $pname") if ( $#blist > 0 );
963
            }
964
            push @build_list, @blist;
965
            push @locationData, $bscanner->getLocation();
6198 dpurdie 966
 
967
            #
968
            #   Determine max build file depth - just to show user
969
            #
970
            foreach ( @blist)
971
            {
972
                my $count = () = $_->{dir} =~ m~/~g;
973
                $buildFileDepth = $count if ($count > $buildFileDepth)
974
            }
975
 
976
 
6133 dpurdie 977
        }
6198 dpurdie 978
        Message ("Max Build File Depth : " . ($buildFileDepth + 1));
979
        Message ("Build File Scan Depth: ". $scanDepth) if ($SCANDEPTH ne $scanDepth);
6133 dpurdie 980
 
6198 dpurdie 981
 
227 dpurdie 982
        #
6133 dpurdie 983
        #   Save (cache) location information
227 dpurdie 984
        #
6133 dpurdie 985
        FileAppend($cacheFile, @locationData);
227 dpurdie 986
    }
987
 
988
    #
989
    #   Process each build file and extract
990
    #       Name of the Package
991
    #       Dependency list
992
    #   Build up a hash of dependence information
993
    #
994
 
995
    my %depends;
299 dpurdie 996
    my %multi;
245 dpurdie 997
    foreach my $be ( @build_list )
227 dpurdie 998
    {
245 dpurdie 999
        Verbose( DisplayPath ("Build file: " . $be->{dir} . " Name: " . $be->{file} ));
359 dpurdie 1000
        #
1001
        #   Sandbox vs Exact processing
1002
        #       Set a suitable display name
1003
        #       Set a suitable tag
1004
        #
1005
        $be->{dname} = $opt_exact ? $be->{full}    : $be->{mname};
1006
        $be->{tag}   = $opt_exact ? $be->{fullTag} : $be->{package};
4184 dpurdie 1007
        $be->{fname} = join ('_', $be->{name}, $be->{version});
6198 dpurdie 1008
        if (length ($be->{dname}) > $maxDname ) {
1009
             $maxDname = length ($be->{dname});
1010
        }
359 dpurdie 1011
 
245 dpurdie 1012
#        DebugDumpData ("be", $be );
227 dpurdie 1013
 
1014
        #
299 dpurdie 1015
        #   Catch multiple builds for the same package
1016
        #   Report later - when we have all
1017
        #
359 dpurdie 1018
        next unless ( $be->{dname} );
6198 dpurdie 1019
        push @{$multi{$be->{dname}}},$be;
227 dpurdie 1020
    }
1021
 
6198 dpurdie 1022
    #
1023
    #   Detect, process and report packages that have multiple builders
1024
    #       An error that can be ignored
1025
    #
359 dpurdie 1026
    foreach my $dname ( sort keys %multi )
299 dpurdie 1027
    {
6198 dpurdie 1028
        my $errFn = $opt_multiBuilders ? \&Warning : \&ReportError;
1029
        if ( scalar @{$multi{$dname}} > 1 )
1030
        {
1031
            my @dirList;
1032
            foreach my $be (@{$multi{$dname}}) {
1033
                push @dirList, $be->{dir};
1034
            }           
1035
            &$errFn("Multiple builders for : $dname", @dirList ) unless $opt_multiBuilders > 1;
1036
        }
1037
        else
1038
        {
1039
            #
1040
            #   Add into dependency struct
1041
            #
1042
            foreach my $be (@{$multi{$dname}}) {
1043
                $depends{$be->{tag}} = $be;
1044
            }
1045
        }
299 dpurdie 1046
    }
6198 dpurdie 1047
    %multi = ();
299 dpurdie 1048
    ErrorDoExit();
1049
 
245 dpurdie 1050
#DebugDumpData ("depends", \%depends );
1051
 
227 dpurdie 1052
    #
255 dpurdie 1053
    #   Remove any dependencies to 'external' packages
227 dpurdie 1054
    #   These will not be met internally and can be regarded as constant
1055
    #
1329 dpurdie 1056
    #   Split 'depends' into internal (ideps) and external (edeps)
1057
    #       edeps : External Dependencies
1058
    #               Key:        Name;Version
1059
    #               Value:      'tag' - index into packages
1060
    #       ideps : Internal Dependencies
1061
    #               Key:        'tag'   - Index into packages
1062
    #               Value:      'dname' - Display Name
1063
    #
227 dpurdie 1064
    foreach my $key ( keys %depends )
1065
    {
1066
        foreach my $build ( keys( %{$depends{$key}{depends}} ))
1067
        {
1068
            unless (exists $depends{$build})
1069
            {
1329 dpurdie 1070
                $depends{$key}{'edeps'}{$depends{$key}{depends}{$build}} = $build;
227 dpurdie 1071
                delete ($depends{$key}{depends}{$build}) ;
1072
                Verbose2( "Not in set: $build");
1073
            }
1074
            else
1075
            {
1329 dpurdie 1076
                $depends{$key}{'ideps'}{$build} = $depends{$build}{dname};
227 dpurdie 1077
            }
1078
        }
1079
    }
359 dpurdie 1080
 
1081
#DebugDumpData ("depends", \%depends );
1082
 
1083
    #
1084
    #   Determine package build order
1085
    #       Scan the list of packages in the build set and determine
1086
    #       those with no dependencies. These can be built.
1087
    #       Remove those packages as dependents from all packages
1088
    #       Repeat.
1089
    #
6133 dpurdie 1090
    #
1091
    #   Determine the build order
1092
    #
1093
    @build_order = ();
1094
    my $more = 1;
1095
    my $level = 0;
1329 dpurdie 1096
    my %found    = map { $_ => 1 } @opt_ignorePackage;
1097
    my %notFound = map { $_ => 1 } @opt_justPackage;
1098
    my $scan_start = 0;
1099
    my $scan_stop = 0;
1100
    my $scan_active = ($opt_fromPackage) ? 0 : 1;
1101
    $scan_active = 0 if ( !$opt_fromPackage && !$opt_fromPackage && !@opt_ignorePackage && @opt_justPackage );
1102
 
227 dpurdie 1103
    while ( $more )
1104
    {
1105
        $more = 0;
1106
        $level++;
1107
        my @build;
1108
 
1109
        #
1110
        #   Locate packages with no dependencies
1111
        #
6133 dpurdie 1112
        foreach my $key ( sort {lc($a) cmp lc($b)} keys %depends )
227 dpurdie 1113
        {
1114
            next if ( keys( %{$depends{$key}{depends}} ) );
1115
            push @build, $key;
1116
        }
1117
 
1118
        foreach my $build ( @build )
1119
        {
1120
            $more = 1;
1329 dpurdie 1121
            my $fe = $depends{$build};
1122
            my $scan_add = $scan_active ? 1 : 0;
1123
 
4184 dpurdie 1124
            if ( $opt_fromPackage && (($fe->{mname} eq $opt_fromPackage) || ($fe->{name} eq $opt_fromPackage) || ($fe->{fname} eq $opt_fromPackage)))
1329 dpurdie 1125
            {
1126
                $scan_add = 1;
1127
                $scan_active = 1;
1128
                $scan_start = 1;
1129
            }
1130
 
4184 dpurdie 1131
            if ( $opt_toPackage && (($fe->{mname} eq $opt_toPackage) || ($fe->{name} eq $opt_toPackage) || ($fe->{fname} eq $opt_toPackage)))
1329 dpurdie 1132
            {
1133
                $scan_add = 0;
1134
                $scan_active = 0;
1135
                $scan_stop = 1;
1136
            }
1137
 
1138
            if ( @opt_justPackage )
1139
            {
1140
                foreach my $pname ( @opt_justPackage )
1141
                {
4184 dpurdie 1142
                    if ( (($fe->{mname} eq $pname) || ($fe->{name} eq $pname) || ($fe->{fname} eq $pname)))
1329 dpurdie 1143
                    {
1144
                        $scan_add = 1;
1145
                        delete $notFound{$pname};
1146
                    }
1147
                }
1148
            }
1149
 
1150
            if ( @opt_ignorePackage )
1151
            {
1152
                foreach my $pname ( @opt_ignorePackage )
1153
                {
4184 dpurdie 1154
                    if ( (($fe->{mname} eq $pname) || ($fe->{name} eq $pname) || ($fe->{fname} eq $pname)))
1329 dpurdie 1155
                    {
1156
                        $scan_add = 0;
1157
                        delete $found{$pname};
1158
                    }
1159
                }
1160
            }
1161
 
6133 dpurdie 1162
            #
1163
            #   Test for a skip marker
1164
            #
1165
            my $skipFile = catdir($GBE_SANDBOX, 'sandbox_dpkg_archive', '_skip.'. $fe->{dname});
1166
            my $skipMachFile = catdir($GBE_SANDBOX, 'sandbox_dpkg_archive', '_skip.' . $GBE_MACHTYPE . '.' . $fe->{dname});
1167
            if ( -f $skipFile || -f $skipMachFile )
1168
            {
1169
                Warning("Package marked for skip: $fe->{dname}, $fe->{dir}") unless $quiet;
1170
                $scan_add = 0;
1171
                $fe->{buildSkip} = 1;
1172
            }
1173
 
6276 dpurdie 1174
            #
1175
            #   Select one level
1176
            #
1177
            if ($opt_onlyLevel && $opt_onlyLevel != $level) {
1178
                $scan_add = 0;
1179
            }
1180
 
227 dpurdie 1181
            $fe->{level} = $level;
1329 dpurdie 1182
            $fe->{buildActive} = $scan_add;
227 dpurdie 1183
            $packages{$build} = $fe;
6133 dpurdie 1184
            push (@build_order, $fe);
227 dpurdie 1185
            delete $depends{$build};
1186
            delete $fe->{depends};                          # remove now its not needed
1187
        }
1188
 
1189
        foreach my $key ( keys %depends )
1190
        {
1191
            foreach my $build ( @build )
1192
            {
1193
                delete $depends{$key}{depends}{$build};
1194
            }
1195
        }
1196
    }
1197
 
1198
    #
1329 dpurdie 1199
    #   Detect bad user specifications
1200
    #
1201
    ReportError ("Specified FromPackage not found: $opt_fromPackage") if ( $opt_fromPackage && !$scan_start );
1202
    ReportError ("Specified ToPackage not found: $opt_toPackage") if ( $opt_toPackage && !$scan_stop );
1203
    ReportError ("Specified ExactPackages not found: ", keys( %notFound) ) if ( %notFound );
1204
    ReportError ("Specified IgnorePackages not found: ", keys( %found) ) if ( %found );
1205
    ErrorDoExit();
1206
 
1207
    #
6133 dpurdie 1208
    #   Just to be sure to be sure
1209
    #
1210
    if ( keys %depends )
1211
    {
1212
        #DebugDumpData ("depends", \%depends );
1213
        Error( "Internal algorithm error: Bad dependancy walk",
1214
               "Possible circular dependency");
1215
    }
1216
 
1217
    #
1218
    #   Determine FULL internal dependency list for each package
1219
    #       Walk packages in build order so that we can leverage the calculations
1220
    #       already done.
1221
    # 
1222
    foreach my $fe ( @build_order )
1223
    {
1224
        my @pkgBuildOrder;
1225
        my %pkgSeen;
1226
        my $key = $fe->{tag};
1227
        if (exists $packages{$key}{'ideps'})
1228
        {
1229
            foreach ( keys %{$packages{$key}{'ideps'}} )
1230
            {
1231
                foreach my $ikey (@{$packages{$_}{'AllIdepsOrder'}})
1232
                {
1233
                    push @pkgBuildOrder, $ikey unless $pkgSeen{$ikey};
1234
                    $pkgSeen{$ikey} = 1;
1235
                }
1236
            }
1237
        }
1238
        push @pkgBuildOrder, $key;
1239
        $fe->{'AllIdepsOrder'} = \@pkgBuildOrder;
1240
 
1241
        #
1242
        #   Is this package in the current directory
1243
        #
1244
        if ($startDir)
1245
        {
1246
            my $matchBase = $startDir . '/'; 
1247
            if ($matchBase =~ m~^$fe->{dir}/~)
1248
            {
1249
                $fe->{buildCurrent} = 1;
1250
                $currentPkgTag = $key;
1251
            }
1252
        }
1253
    }
1254
 
1255
    #
1256
    #   Now that we have a full dependency list for each package we can calculate a full
1257
    #   usage list. This is a complete list of all package that depend on a package both directly 
1258
    #   and inderectly. Useful for regression testing
1259
    #   
1260
    foreach my $fe ( @build_order )
1261
    {
1262
        foreach my $itag (@{$fe->{'AllIdepsOrder'}})
1263
        {
1264
            next if ($itag eq $fe->{tag});
1265
            push @{$packages{$itag}{usedBy}}, $fe->{tag};
1266
        }
1267
    }
1268
 
1269
    #
1270
    #   If the CWD is within a package then limit the build to that package and
1271
    #   its dependents, unless user specifies entire sandbox.
1272
    #   
1273
    if ($currentPkgTag && ! $opt_allSandbox )
1274
    {
1275
        if (!$opt_processUsedBy )
1276
        {
1277
            #
1278
            #   Reform the build_order to reflect the current sandbox
1279
            #   The @build_order is an array of package entries
1280
            #   The per-package build order is an array of keys
1281
            #
1282
            my @pkgOrder;
1283
            foreach ( @{$packages{$currentPkgTag}{AllIdepsOrder}})
1284
            {
1285
                push @pkgOrder,  $packages{$_} ;
1286
            }
1287
 
1288
            # Reform the build order based on original level
1289
            #   Simply done to look pretty - and be consistient when compared with the entire sandbox
1290
            @build_order = sort {$a->{level} <=> $b->{level}} @pkgOrder;
1291
 
1292
        }
1293
        else
1294
        {
1295
            #
1296
            #   Reform the build order to reflect the consumers of the current package
1297
            #   This does not include the current package. The assumption is that the package
1298
            #   has been built. 
1299
            #
1300
            #   The @build_order is an array of package entries
1301
            #   The per-package build order is an array of keys
1302
            #
1303
            my @pkgOrder;
1304
            foreach ( @{$packages{$currentPkgTag}{'usedBy'}})
1305
            {
1306
                push @pkgOrder,  $packages{$_} ;
1307
            }
1308
 
1309
            # Reform the build order based on original level
1310
            #   Simply done to look pretty - and be consistient when compared with the entire sandbox
1311
            @build_order = sort {$a->{level} <=> $b->{level}} @pkgOrder;
1312
        }
1313
    }
1314
    else
1315
    {
1316
        $opt_allSandbox = 1;
1317
    }
1318
 
1319
    #
1329 dpurdie 1320
    #   Calculate the external dependencies
1321
    #       Only process packages that are a part of the build
1322
    #
1323
    #   extern_deps structure
1324
    #       Hash key: 'tag'   - Index into packages
1325
    #          Value: Hash of:
1326
    #                 Key  : Name;Version
1327
    #                 Value: Array of: 'tags' (Index into packages)
1328
    #                                   of packages that use the external
1329
    #                                   component.
1330
    {
6133 dpurdie 1331
        Verbose ("Calculate external dependencies on packages in build");
1329 dpurdie 1332
        %extern_deps = ();
1333
 
6133 dpurdie 1334
        foreach my $pe (@build_order)
1329 dpurdie 1335
        {
6133 dpurdie 1336
                next unless ( $pe->{buildActive} );
1337
                next unless ( $pe->{'edeps'} );
1338
                foreach ( keys %{$pe->{'edeps'}} )
1329 dpurdie 1339
                {
6133 dpurdie 1340
                    push @{$extern_deps{$pe->{'edeps'}{$_}} {$_} }, $pe->{tag};
1329 dpurdie 1341
                }
1342
        }
1343
    }
1344
 
227 dpurdie 1345
 
1329 dpurdie 1346
#   DebugDumpData("Packages", \%packages);
359 dpurdie 1347
#   DebugDumpData ("Order", \@build_order);
1348
#   DebugDumpData("External Depends", \%extern_deps );
227 dpurdie 1349
}
1350
 
1351
#-------------------------------------------------------------------------------
6133 dpurdie 1352
# Function        : calc_rootFingerPrint 
1353
#
1354
# Description     : Calculate a finger print of all the directories in the
1355
#                   sandbox root.
1356
#                   
1357
#                   Used to determine if the user has added or remove a package
1358
#                   from the sandbox
1359
#
1360
# Inputs          : None
1361
#
1362
# Returns         : SHA1 hash
1363
#
1364
sub calc_rootFingerPrint
1365
{
1366
    my $fpSha1 = Digest->new("SHA-1");
1367
 
1368
    foreach my $pname ( glob("*") )
1369
    {
1370
        next if ( $pname =~ m~^\.~ );
1371
        next if ( $pname =~ m~dpkg_archive$~ );
1372
        next if ( $pname =~ m~^CVS$~ );
1373
        next unless ( -d $pname );
1374
 
1375
        $fpSha1->add($pname);
1376
 
1377
        #
1378
        #   Include stop files in fingerprint too
1379
        #
1380
        $fpSha1->add("$pname/stop" ) if ( -f "$pname/stop" ); 
1381
        $fpSha1->add("$pname/stop.$GBE_MACHTYPE" ) if ( -f "$pname/stop.$GBE_MACHTYPE" ); 
1382
 
1383
    }
1384
    return $fpSha1->hexdigest;
1385
}
1386
 
1387
#-------------------------------------------------------------------------------
227 dpurdie 1388
# Function        : cmd
1389
#
1390
# Description     : Execute a command in all the sandboxes
1391
#                       Locate the base of the sandbox
1392
#                       Locate all packages in the sandbox
1393
#                       Locate all build files in each sandbox
1394
#                       Determine build order
1395
#                       Issue commands for each sandbox in order
1396
#
255 dpurdie 1397
# Inputs          : Arguments passed to jats build
227 dpurdie 1398
#
1399
# Returns         : Will exit
1400
#
1401
sub cmd
1402
{
1329 dpurdie 1403
    my ($hcmd, @cmd_opts ) = @_;
6198 dpurdie 1404
    my $opt_reverse;
359 dpurdie 1405
 
1406
    Getopt::Long::Configure('pass_through');
6198 dpurdie 1407
    getOptionsFromArray ( \@cmd_opts,
1408
                          'reverse!' => \$opt_reverse,
1409
                          ) || Error ("Invalid command line" );
359 dpurdie 1410
    SubCommandHelp( $opt_help, $hcmd) if ($opt_help  );
1411
 
227 dpurdie 1412
    #
1413
    #   Determine Sandbox information
1414
    #   Populate global variables
1415
    #
1416
    calc_sandbox_info();
6198 dpurdie 1417
    if ($opt_reverse) {
1418
        @build_order = reverse @build_order;
1419
    }
227 dpurdie 1420
    foreach my $fe ( @build_order )
1421
    {
6133 dpurdie 1422
        my $active = displayHeader($fe, { showPath => 1 });
227 dpurdie 1423
 
6133 dpurdie 1424
        if ($active)
1425
        {
1426
            my $dir = $fe->{dir};
1427
            my $result = JatsCmd( "-cd=$dir", @cmd_opts);
1428
            if ( $result ) {
1429
                if ( $opt_keepgoing ) {
1430
                    Warning ("Cmd failure");
1431
                } else {
1432
                    Error   ("Cmd failure");
1433
                }
2054 dpurdie 1434
            }
1435
        }
227 dpurdie 1436
    }
1437
 
1438
    exit 0;
1439
}
1440
 
1441
#-------------------------------------------------------------------------------
331 dpurdie 1442
# Function        : buildcmd
1443
#
1444
# Description     : Build the entire sandbox
1445
#                   The all and the build are similar.
1446
#                   Its not really useful to do a build without a make
1447
#                   so we don't try
1448
#
1449
# Inputs          : Arguments passed to jats make
1450
#
1451
#
1452
# Returns         : Will exit
1453
#
1454
 
1455
sub buildcmd
1456
{
337 dpurdie 1457
    my ($cmd, @cmd_opts) = @_;
331 dpurdie 1458
    my @build_opts;
337 dpurdie 1459
    my @make_opts;
6133 dpurdie 1460
    my $opt_skip = 1;
1461
    my $opt_clean = 0;
331 dpurdie 1462
 
1463
    #
359 dpurdie 1464
    #   Extract and options
1465
    #
1466
    Getopt::Long::Configure('pass_through');
6133 dpurdie 1467
    getOptionsFromArray ( \@cmd_opts,
1468
                          'skip!' => \$opt_skip,
1469
                          'clean!' => \$opt_clean,
1470
    ) || Error ("Invalid command line" );
359 dpurdie 1471
    SubCommandHelp( $opt_help, "Command $cmd") if ($opt_help );
361 dpurdie 1472
 
359 dpurdie 1473
    #
331 dpurdie 1474
    #   Insert default options
1475
    #
1476
    push @build_opts, '-noforce' if ( $cmd eq 'all' );
6133 dpurdie 1477
    push @build_opts, '-force'   if ( $cmd ne 'all' );
331 dpurdie 1478
 
337 dpurdie 1479
    #
1480
    #   Attempt to split the options into build and make options
1481
    #   Only handle the often used options to build.
1482
    #
1483
    foreach  ( @cmd_opts )
1484
    {
1485
        if ( m/^-cache/ || m/^-package/ || m/^-forcebuildpkg/ || m/-expert/) {
1486
            push @build_opts, $_;
1487
        } else {
1488
            push @make_opts, $_;
1489
        }
1490
    }
1491
 
6133 dpurdie 1492
    push @make_opts, 'all'  unless ( @make_opts );
331 dpurdie 1493
 
1494
    #
1495
    #   Determine Sandbox information
1496
    #   Populate global variables
1497
    #
1498
    calc_sandbox_info();
1499
    foreach my $fe ( @build_order )
1500
    {
6133 dpurdie 1501
        my $active = displayHeader($fe, { showPath => 1 });
1502
        if ($active) {
331 dpurdie 1503
 
6133 dpurdie 1504
            #
1505
            #   Determine build success tag file
1506
            #   If the tag file exists, then see if any files in the files in the package source are more
1507
            #   recent than the tag file
1508
            #
1509
            my $mustBuild = 1;
1510
            my $sigMatch = 0;
1511
            my $tagFile = getPkgFingerPrintFile($fe);
1512
 
1513
            if ( -e $tagFile ) {
1514
                if ( TagFileMatch($tagFile, genPkgFingerPrint($fe, 'Test')) ) {
1515
                    $sigMatch = 1;
1516
                    if ($opt_skip) {
1517
                        $mustBuild = 0;
1518
                    } else {
1519
                        $mustBuild = 2;
1520
                    }
1521
                } else {
1522
                }
1523
            } else {
1524
                    $mustBuild = 2;
1525
                    $sigMatch = -1;
1526
            }
1527
 
1528
#Debug0("Skip: $opt_skip, sigMatch: $sigMatch, Build: $mustBuild, Opts: @make_opts",);
1529
            if ($mustBuild)
1530
            {
1531
                if (1)
1532
                {
1533
                    unlink $tagFile;
1534
                    my $dir = $fe->{dir};
1535
                    my $result;
1536
 
1537
                    $result = JatsCmd( "-cd=$dir", 'build', @build_opts);
1538
                    if ($result)
1539
                    {
1540
                        if ($opt_keepgoing)
1541
                        {
1542
                            Warning( "Build Cmd failure - Keep going");
1543
                            next;
1544
                        }
6198 dpurdie 1545
                        Error ("Build Cmd failure: $dir");
6133 dpurdie 1546
                    }
1547
 
1548
                    #
1549
                    #   Skip make if we have a prebuilt package
1550
                    #
1551
                    my $mustMake = 1;
1552
 
1553
                    if ($mustMake)
1554
                    {
1555
                        JatsCmd( "-cd=$dir", 'make', 'clean') if $opt_clean;
1556
                        $result = JatsCmd( "-cd=$dir", 'make',  @make_opts);
1557
                        if ($result)
1558
                        {
1559
                            if ($opt_keepgoing)
1560
                            {
1561
                                Warning( "Make Cmd failure - Keep going");
1562
                                next;
1563
                            }
6198 dpurdie 1564
                            Error ("Make Cmd failure: $dir");
6133 dpurdie 1565
                        }
1566
                    }
1567
                }
1568
 
6198 dpurdie 1569
                Verbose ("Save fingerprint: $tagFile");
6133 dpurdie 1570
                FileCreate( $tagFile, genPkgFingerPrint($fe,'Generation') );
1571
            }
1572
            else
1573
            {
1574
                Message ("No file changes since last build. Skipping")
1575
            }
1576
        }
331 dpurdie 1577
    }
1578
 
1579
    exit 0;
1580
}
1581
 
1582
#-------------------------------------------------------------------------------
273 dpurdie 1583
# Function        : clean
1584
#
1585
# Description     : Execute a command in all the sandboxes
1586
#                       Locate the base of the sandbox
1587
#                       Locate all packages in the sandbox
1588
#                       Locate all build files in each sandbox
1589
#                       Determine build order
1590
#                       Issue commands for each sandbox in order
1591
#
1592
# Inputs          : Arguments passed to jats build
1593
#
1594
# Returns         : Will exit
1595
#
1596
sub clean
1597
{
1329 dpurdie 1598
    my ($mode, @cmd_opts ) = @_;
359 dpurdie 1599
 
273 dpurdie 1600
    #
359 dpurdie 1601
    #   Extract and options
1602
    #
1603
    Getopt::Long::Configure('pass_through');
1329 dpurdie 1604
    getOptionsFromArray ( \@cmd_opts ) || Error ("Invalid command line" );
359 dpurdie 1605
    SubCommandHelp( $opt_help, "Clean") if ($opt_help );
1606
 
1607
    #
273 dpurdie 1608
    #   Determine Sandbox information
1609
    #   Populate global variables
1610
    #
1611
    calc_sandbox_info();
1612
 
1613
    my @cmd = $mode eq 'clobber' ? ('clobber') : ('make', 'clean' );
1614
 
1615
    #
1616
    #   Clobber and clean need to be done in the reverse order
1617
    #
1618
    foreach my $fe ( reverse @build_order )
1619
    {
6133 dpurdie 1620
        my $active = displayHeader($fe, { showPath => 1 });
1621
        if ($active)
1622
        {
1623
            my $dir = $fe->{dir};
1624
            my $result = JatsCmd( "-cd=$dir", @cmd, @cmd_opts);
1625
            if ($result)
1626
            {
1627
                if ($opt_keepgoing)
1628
                {
1629
                    Warning("Command Failure");
1630
                }
1631
                else
1632
                {
1633
                    Error ("Cmd failure") if ( $result );
1634
                }
1635
            }
1636
        }
273 dpurdie 1637
    }
1638
 
1639
    exit 0;
1640
}
1641
 
1642
 
1643
#-------------------------------------------------------------------------------
337 dpurdie 1644
# Function        : cache
1645
#
1646
# Description     : Cache external packages into the sandbox
1647
#
1648
# Inputs          : @opts                   - User options
1649
#
1650
# Returns         : Nothing
1651
#
1652
sub cache
1653
{
1329 dpurdie 1654
    my (@cmd_opts) = @_;
337 dpurdie 1655
 
1329 dpurdie 1656
    getOptionsFromArray ( \@cmd_opts ) || Error ("Invalid command line" );
1657
    SubCommandHelp( $opt_help, "Cache") if ($opt_help || $#cmd_opts >= 0 );
359 dpurdie 1658
 
337 dpurdie 1659
    #
1660
    #   Determine Sandbox information
1661
    #   Populate global variables
1662
    #
1663
    Message("Cache External Dependencies");
6133 dpurdie 1664
    Error ("GBE_DPKG_CACHE not defined") unless $GBE_DPKG_CACHE;
337 dpurdie 1665
    calc_sandbox_info();
1666
 
6133 dpurdie 1667
    JatsTool ('cache_dpkg', "core_devl/jats2_current" );
1668
 
337 dpurdie 1669
    #
1329 dpurdie 1670
    #   Walk the list of external dependencies and cache each one
337 dpurdie 1671
    #
1672
    foreach my $de ( sort keys %extern_deps )
1673
    {
1674
        my @vlist = keys %{$extern_deps{$de}};
359 dpurdie 1675
        foreach my $pve ( @vlist )
337 dpurdie 1676
        {
359 dpurdie 1677
            my ($pn,$pv) = split( $; , $pve );
1678
            Message ("Cache ${pn} ${pv}");
1679
            JatsTool ('cache_dpkg', "${pn}/${pv}" );
337 dpurdie 1680
        }
1681
    }
361 dpurdie 1682
 
337 dpurdie 1683
    exit 0;
361 dpurdie 1684
 
337 dpurdie 1685
}
1686
 
359 dpurdie 1687
#-------------------------------------------------------------------------------
1688
# Function        : populate
1689
#
1690
# Description     : Populate the sandbox with package versions
1691
#
1692
#
1693
# Inputs          : commands            - Array of command line arguments
1694
#                   Mode-0:
1695
#
1696
#                       pkg_name pkg_version        - Import files for named package
1697
#                       options:
1698
#                           -recurse                - Import dependent packages too
1699
#                           -missing                - Import dependencies not in dpkg_archive
1700
#                           -test                   - Show what would be done
1701
#                           -extractfiles           - Extract file, no view
1702
#
1703
#
1704
#
1705
#
1706
# Returns         : Does not return
1707
#
1708
use JatsRmApi;
1709
use DBI;
337 dpurdie 1710
 
359 dpurdie 1711
#
1712
#   Data Base Interface
1713
#
1714
my $RM_DB;
1715
my $PopLevel = 0;
1716
my %PopPackage;
1717
my @StrayPackages;
1718
my @PopBase;
1719
 
1720
sub populate
1721
{
1329 dpurdie 1722
    my (@cmd_opts ) = @_;
359 dpurdie 1723
    my $opt_missing = 0;
1724
    my $opt_recurse = 0;
1725
    my $opt_test = 0;
1329 dpurdie 1726
    my $opt_show = 0;
359 dpurdie 1727
    my $opt_extractfiles;
1728
    my @opt_extract = qw(-extract);
1729
    my @opt_fnames;
1329 dpurdie 1730
    my @opt_exclude;
1731
    my $opt_all;
359 dpurdie 1732
 
1329 dpurdie 1733
 
359 dpurdie 1734
    Getopt::Long::Configure('pass_through');
1329 dpurdie 1735
    getOptionsFromArray ( \@cmd_opts,
1736
                "all"               => \$opt_all,
1737
                "missing"           => \$opt_missing,
1738
                "test"              => \$opt_test,
1739
                "show"              => \$opt_show,
1740
                "recurse:100"       => \$opt_recurse,
1741
                'excludePackage:s'  => sub{ opts_add2List( \@opt_exclude, @_ )},
359 dpurdie 1742
                ) || Error ("Invalid command line" );
1743
 
1744
    SubCommandHelp( $opt_help, "Populate Sandbox") if ($opt_help );
1745
 
1746
    #
1329 dpurdie 1747
    #   Sanity tests
1748
    #
1749
    Error ("Populate: -missing and -all options are mutually exclusive")
1750
        if ( $opt_missing && $opt_all );
1751
 
1752
    #
359 dpurdie 1753
    #   Extract options for the jats extract utility
1754
    #
1329 dpurdie 1755
    foreach ( @cmd_opts )
359 dpurdie 1756
    {
1757
        if ( m~^-~ ) {
1758
            push ( @opt_extract, $_);
1759
        } else {
1760
            push ( @opt_fnames, $_);
1761
        }
1762
    }
1763
 
1764
    #
1765
    #   Allow exactly zero or two 'bare' arguments
1766
    #   Create an array of package-versions to be processed.
1767
    #
1768
    if ( $#opt_fnames >= 0 )
1769
    {
365 dpurdie 1770
        Error ("Populate: Must specify both a package name and version")
359 dpurdie 1771
            if ( $#opt_fnames != 1 );
1772
        push @PopBase, join( $;, @opt_fnames );
1773
    }
1329 dpurdie 1774
    elsif ( $opt_missing || $opt_all )
359 dpurdie 1775
    {
1776
        #
1777
        #   User has not provided a package name to extract
1329 dpurdie 1778
        #   Assume that the user will want all or missing dependencies
359 dpurdie 1779
        #
1780
        #   Determine packages that are not present
1781
        #
1782
        calc_sandbox_info();
1783
 
1784
        #
1785
        # Scan for missing dependencies
1786
        #
1787
        foreach my $de ( sort keys %extern_deps )
1788
        {
1789
            my @vlist = keys %{$extern_deps{$de}};
1790
            foreach my $pve ( @vlist )
1791
            {
1792
                my ($pn,$pv) = split( $; , $pve );
1329 dpurdie 1793
                unless ($opt_missing && check_package_existance( $pn, $pv ))
359 dpurdie 1794
                {
1795
                    push @PopBase, join( $;, $pn , $pv );
1796
                }
1797
            }
1798
        }
1799
    }
1800
    else
1801
    {
1802
        Error ("No command or option specified. See help for command usage");
1803
    }
1804
 
1805
    #
1806
    #   Process the list of package-versions
1807
    #   These are top level packages. Get details from Release Manager
1808
    #
1809
    #DebugDumpData("Data", \@PopBase );
1810
    $PopLevel = 0;
1811
    foreach my $entry ( @PopBase )
1812
    {
1813
        my ($pname, $pver ) = split( $; , $entry);
1814
 
1815
        my $pv_id = getPkgDetailsByName($pname, $pver);
1816
        Error ("populate: $pname, $pver not found in Release Manager" )
1817
            unless ( $pv_id );
1818
        getPkgDetailsByPV_ID($pv_id);
1819
    }
1820
    #
1821
    #   If recursing then process packages that have yet to
1822
    #   be processed. At the start there will be the initial user specified
1823
    #   packages on the list. Place a marker at the end so that we can
1824
    #   determine how far we are recursing down the dependency tree.
1825
    #
1329 dpurdie 1826
    $opt_recurse = ($opt_all ? 100 : $opt_recurse);
359 dpurdie 1827
    if ( $opt_recurse )
1828
    {
1829
        my $marker = join($; , '_NEXT_LEVEL_', 0, 0 );
1830
        push @StrayPackages, $marker;
1831
        $PopLevel++;
1832
 
1833
        while ( $#StrayPackages >= 0 )
1834
        {
1835
            my ($name, $ver, $pv_id) = split($;, shift @StrayPackages);
1836
 
1837
            #
1838
            #   Marker.
1839
            #   Increment the level of recursion
1840
            #   Detect end conditions
1841
            #
1842
            if ( $name eq '_NEXT_LEVEL_' )
1843
            {
1844
                last unless ($#StrayPackages >= 0 );
1845
                $PopLevel++;
1846
                last if ( $PopLevel > $opt_recurse );
1847
                push @StrayPackages, $marker;
1848
                next;
1849
            }
1850
 
1851
            next if ( exists $PopPackage{$name}{$ver}{done} );
1852
            getPkgDetailsByPV_ID ( $pv_id );
1853
            #print "Stray: $pv_id, $name, $ver\n";
1854
        }
1855
    }
1856
    #DebugDumpData("Data", \%PopPackage );
1857
 
1858
    #
1859
    #   Determine packages that need to be extracted
1329 dpurdie 1860
    #   Sort alphabetically - case insensitive
359 dpurdie 1861
    #
1329 dpurdie 1862
    foreach my $pname ( sort {lc($a) cmp lc($b)} keys %PopPackage )
359 dpurdie 1863
    {
1329 dpurdie 1864
        pkgscan:
359 dpurdie 1865
        foreach my $pver ( sort keys %{$PopPackage{$pname}} )
1866
        {
1867
            #
1868
            #   Create a nice view name for the extraction
365 dpurdie 1869
            #   Will also be used to test for package existence
359 dpurdie 1870
            #
1871
            my $vname = "$pname $pver";
1872
            $vname =~ s~ ~_~g;
1873
            $vname =~ s~__~~g;
1874
 
1875
            if ( -d "$GBE_SANDBOX/$vname" )
1876
            {
1877
                Warning("Package already in sandbox: $pname, $pver");
1878
                next;
1879
            }
1880
 
1881
            #
1882
            #   If scanning for missing packages, then examine archives
1883
            #   for the packages existence. Don't do this on level-0 packages
1884
            #   These have been user specified.
1885
            #
1886
            if ( $opt_missing && $PopPackage{$pname}{$pver}{level}  )
1887
            {
1888
                my $found = check_package_existance( $pname, $pver );
1889
                if ( $found )
1890
                {
1891
                    Verbose ("Package found in archive - skipped: $pname, $pver");
1892
                    next;
1893
                }
1894
            }
1895
 
1896
            #
1329 dpurdie 1897
            #   Has the user specifically excluded this package
1898
            #   Allow three forms
1899
            #       packageName
1900
            #       packageName_Version
1901
            #       packageName.projectName
1902
            #
1903
            my $excluded;
1904
            foreach my $ename ( @opt_exclude )
1905
            {
1906
                if ( $ename eq $pname ) {
1907
                    $excluded = 1;
1908
                } elsif ($ename eq $pname .'_' . $pver ) {
1909
                    $excluded = 1;
1910
                } else {
1911
                    if ( $pver =~ m~(\.[a-z]{2,4})$~ )
1912
                    {
1913
                        $excluded = ($ename eq $pname . $1 );
1914
                    }
1915
                }
1916
 
1917
                if ( $excluded )
1918
                {
1919
                    Message ("Package excluded by user - skipped: $pname, $pver");
1920
                    next pkgscan;
1921
                }
1922
            }
1923
 
1924
            #
359 dpurdie 1925
            #   Generate commands to extract the package
1926
            #
1927
            my $vcstag = $PopPackage{$pname}{$pver}{vcstag};
1928
            my @cmd = qw(jats_vcsrelease);
1929
            push @cmd, "-view=$vname", "-label=$vcstag", @opt_extract;
1329 dpurdie 1930
            if ( $opt_show )
359 dpurdie 1931
            {
1329 dpurdie 1932
                Message ("$pname $pver");
1933
            }
1934
            elsif ( $opt_test )
1935
            {
359 dpurdie 1936
                Message "jats " . QuoteCommand (@cmd );
1937
            }
1938
            else
1939
            {
1940
                Message "Extracting: $pname $pver";
1941
                my $rv = JatsCmd (@cmd);
1942
                Error ("Package version not extracted")
1943
                    if ( $rv );
1944
            }
1945
        }
1946
    }
1947
 
1948
    #
1949
    # This command does not return
1950
    #
1951
    exit (0);
1952
}
1953
 
337 dpurdie 1954
#-------------------------------------------------------------------------------
4197 dpurdie 1955
# Function        : buildfilter 
1956
#
1957
# Description     : Manipulate the sandbox build filter
1958
#
1959
# Inputs          : Optional filter names
1960
#                       +NAME - will add filter
1961
#                       -NAME will remove it
1962
#                       NAME will set it
1963
#                   No args will just display the build filter
1964
#
1965
# Returns         : Does not return
1966
#
1967
sub buildfilter
1968
{
1969
    my (@cmd_opts ) = @_;
1970
    my @filter_list;
1971
    my $first_arg = 1;
1972
    my $modified;
1973
 
1974
    Getopt::Long::Configure('pass_through');
1975
    getOptionsFromArray ( \@cmd_opts ) || Error ("Invalid command line" );
1976
 
1977
    SubCommandHelp( $opt_help, "Buildfilter") if ($opt_help );
1978
 
1979
    #
1980
    #   Set the initial filter list
1981
    #   This will have been parsed by JATS before we get here
1982
    #
1983
    @filter_list = split( /[,\s]+/, join(',', $GBE_BUILDFILTER));
1984
 
1985
    #
1986
    #   Extract options for the jats extract utility
1987
    #
1988
    foreach ( @cmd_opts )
1989
    {
1990
        if (m~^\+(.*)~)
1991
        {
1992
            UniquePush( \@filter_list, $1);
1993
        }
1994
        elsif (m~^\-(.*)~)
1995
        {
1996
            ArrayDelete( \@filter_list, $1);
1997
        }
1998
        else
1999
        {
2000
            @filter_list = () if ($first_arg);
2001
            UniquePush( \@filter_list, $_);
2002
        }
2003
        $first_arg = 0;
2004
        $modified = 1;
2005
    }
2006
 
2007
    #
2008
    #   Display the results to the user
2009
    #
2010
    Message('BuildFilter:', @filter_list);
2011
 
2012
    #
2013
    #   Write out a new file
2014
    #
2015
    if ($modified)
2016
    {
6192 dpurdie 2017
        FileCreate($filterFile, @filter_list);
4197 dpurdie 2018
    }
2019
 
2020
    #
2021
    # This command does not return
2022
    #
2023
    exit (0);
2024
}
2025
 
2026
 
2027
#-------------------------------------------------------------------------------
359 dpurdie 2028
# Function        : getPkgDetailsByName
2029
#
2030
# Description     : Determine the PVID for a given package name and version
2031
#
2032
# Inputs          : $pname          - Package name
2033
#                   $pver           - Package Version
2034
#
361 dpurdie 2035
# Returns         :
359 dpurdie 2036
#
2037
 
2038
sub getPkgDetailsByName
2039
{
2040
    my ($pname, $pver) = @_;
2041
    my $pv_id;
2042
    my (@row);
2043
 
2044
    connectRM(\$RM_DB) unless ($RM_DB);
2045
 
2046
    # First get details for a given package version
2047
 
2048
    my $m_sqlstr = "SELECT pv.PV_ID, pkg.PKG_NAME, pv.PKG_VERSION" .
2049
                    " FROM RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGES pkg" .
2050
                    " WHERE pkg.PKG_NAME = \'$pname\' AND pv.PKG_VERSION = \'$pver\' AND pv.PKG_ID = pkg.PKG_ID";
2051
    my $sth = $RM_DB->prepare($m_sqlstr);
2052
    if ( defined($sth) )
2053
    {
2054
        if ( $sth->execute( ) )
2055
        {
2056
            if ( $sth->rows )
2057
            {
2058
                while ( @row = $sth->fetchrow_array )
2059
                {
2060
                    $pv_id = $row[0];
2061
                    my $name = $row[1];
2062
                    my $ver = $row[2];
2063
                    Verbose( "getPkgDetailsByName :PV_ID= $pv_id");
2064
                }
2065
            }
2066
            $sth->finish();
2067
        }
2068
    }
2069
    else
2070
    {
2071
        Error("Prepare failure" );
2072
    }
2073
    return $pv_id;
2074
}
2075
 
2076
#-------------------------------------------------------------------------------
2077
# Function        : getPkgDetailsByPV_ID
2078
#
2079
# Description     : Populate the Packages structure given a PV_ID
2080
#                   Called for each package in the SBOM
2081
#
2082
# Inputs          : PV_ID           - Package Unique Identifier
2083
#
2084
# Returns         : Populates Package
2085
#
2086
sub getPkgDetailsByPV_ID
2087
{
2088
    my ($PV_ID) = @_;
2089
    my $foundDetails = 0;
2090
    my (@row);
2091
 
2092
    connectRM(\$RM_DB) unless ($RM_DB);
2093
 
2094
    # First get details from pv_id
2095
 
2096
    my $m_sqlstr = "SELECT pv.PV_ID, pkg.PKG_NAME, pv.PKG_VERSION, release_manager.PK_RMAPI.return_vcs_tag($PV_ID)" .
2097
                    " FROM RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGES pkg " .
2098
                    " WHERE pv.PV_ID = \'$PV_ID\' AND pv.PKG_ID = pkg.PKG_ID";
2099
 
2100
    my $sth = $RM_DB->prepare($m_sqlstr);
2101
    if ( defined($sth) )
2102
    {
2103
        if ( $sth->execute( ) )
2104
        {
2105
            if ( $sth->rows )
2106
            {
2107
                while ( @row = $sth->fetchrow_array )
2108
                {
2109
                    my $pv_id       = $row[0];
2110
                    my $name        = $row[1];
2111
                    my $ver         = $row[2];
2112
                    my $vcstag      = $row[3] || '';
2113
 
2114
                    $vcstag =~ tr~\\/~/~;
2115
                    Verbose ("getPkgDetailsByPV_ID: $PV_ID, $name, $ver, $vcstag");
2116
 
2117
                    $PopPackage{$name}{$ver}{pvid} = $PV_ID;
2118
                    $PopPackage{$name}{$ver}{done} = 1;
2119
                    $PopPackage{$name}{$ver}{vcstag} = $vcstag;
2120
                    $PopPackage{$name}{$ver}{level} = $PopLevel;
2121
                    getDependsByPV_ID( $pv_id, $name, $ver );
2122
                }
2123
            }
2124
            else
2125
            {
2126
                Warning ("No Package details for: PVID: $PV_ID");
2127
            }
2128
            $sth->finish();
2129
        }
2130
        else
2131
        {
2132
            Error("getPkgDetailsByPV_ID: Execute failure", $m_sqlstr );
2133
        }
2134
    }
2135
    else
2136
    {
2137
        Error("Prepare failure" );
2138
    }
2139
}
2140
 
2141
#-------------------------------------------------------------------------------
2142
# Function        : getDependsByPV_ID
2143
#
2144
# Description     : Extract the dependancies for a given package version
2145
#
2146
# Inputs          : $pvid
2147
#
2148
# Returns         :
2149
#
2150
sub getDependsByPV_ID
2151
{
2152
    my ($pv_id, $pname, $pver) = @_;
2153
 
2154
    connectRM(\$RM_DB) unless ($RM_DB);
2155
 
2156
    #
365 dpurdie 2157
    #   Now extract the package dependencies
359 dpurdie 2158
    #
2159
    my $m_sqlstr = "SELECT pkg.PKG_NAME, pv.PKG_VERSION, pd.DPV_ID" .
2160
                   " FROM RELEASE_MANAGER.PACKAGE_DEPENDENCIES pd, RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGES pkg" .
2161
                   " WHERE pd.PV_ID = \'$pv_id\' AND pd.DPV_ID = pv.PV_ID AND pv.PKG_ID = pkg.PKG_ID";
2162
    my $sth = $RM_DB->prepare($m_sqlstr);
2163
    if ( defined($sth) )
2164
    {
2165
        if ( $sth->execute( ) )
2166
        {
2167
            if ( $sth->rows )
2168
            {
2169
                while ( my @row = $sth->fetchrow_array )
2170
                {
2171
                    my $name = $row[0];
2172
                    my $ver = $row[1];
2173
 
2174
                    Verbose2( "       Depends: $name, $ver");
2175
                    unless ( exists $PopPackage{$name} && exists $PopPackage{$name}{$ver} && exists $PopPackage{$name}{$ver}{done} )
2176
                    {
2177
                        push @StrayPackages, join($;, $name, $ver, $row[2] );
2178
                    }
2179
                }
2180
            }
2181
            $sth->finish();
2182
        }
2183
    }
2184
    else
2185
    {
2186
        Error("GetDepends:Prepare failure" );
2187
    }
2188
}
2189
 
2190
#-------------------------------------------------------------------------------
1329 dpurdie 2191
# Function        : getOptionsFromArray
2192
#
2193
# Description     : Like getOptions, but handles an array
2194
#                   Provided as the version of Perl used does not have one
2195
#
2196
# Inputs          : pArray                  - Ref to array
2197
#                   ....                    - GetOptions arguments
2198
#
2199
# Returns         : 
2200
#
2201
sub getOptionsFromArray
2202
{
2203
    my ($pArray, %args) = @_;
2204
 
2205
    #
6198 dpurdie 2206
    #   Helper to parse --multiBuilders
2207
    #
2208
    my $parseMulti = sub {
2209
        my ($ref, $value) = @_;
2210
        $value = 'error' unless length($value);
2211
        my %valid = (error => 0, report => 1, ignore => 2);
2212
        unless (exists $valid{lc $value}) {
2213
            die ("Invalid option for  --$ref->{name}\n");
2214
        };
2215
        $opt_multiBuilders = $valid{lc $value};
2216
    };
2217
 
2218
 
2219
    #
1329 dpurdie 2220
    #   Common arguments
2221
    #
2222
    my %commonOptions = (
2223
        'help|h:+'          => \$opt_help,
2224
        'manual:3'          => \$opt_help,
2225
        'verbose:+'         => \$opt_verbose,
2226
        'topackage:s'       => \$opt_toPackage,
2227
        'frompackage:s'     => \$opt_fromPackage,
2228
        'justpackage:s'     => sub{ opts_add2List( \@opt_justPackage, @_ )},
2229
        'ignorepackage:s'   => sub{ opts_add2List( \@opt_ignorePackage, @_ )},
6133 dpurdie 2230
        'entireSandBox!'    => \$opt_allSandbox,
2231
        'users!'            => \$opt_processUsedBy,
2232
        'keepgoing!'        => \$opt_keepgoing,
2233
        'rescan!'           => \$opt_reScan,
6198 dpurdie 2234
        'multiBuilders:s'   => $parseMulti, 
6276 dpurdie 2235
        'onlylevel:i'       => \$opt_onlyLevel,
1329 dpurdie 2236
        );
2237
 
2238
    #
2239
    #   Merge in the user options
2240
    #
2241
    @commonOptions{keys %args} = values %args;
2242
 
2243
    local ( @ARGV );
2244
    @ARGV = @$pArray;
2245
    my $rv = GetOptions ( %commonOptions );
2246
    @$pArray = @ARGV;
2247
 
2248
    ErrorConfig('verbose' => $opt_verbose );
2249
    return $rv;
2250
}
2251
 
2252
#-------------------------------------------------------------------------------
6133 dpurdie 2253
# Function        : displayHeader 
2254
#
6198 dpurdie 2255
# Description     : Display a build header, if the entry is active
2256
#                   ie: Between a --From and --To
6133 dpurdie 2257
#
2258
# Inputs          : $fe             - Build entry
6198 dpurdie 2259
#                   Hash of options
2260
#                       indent          => Text       - Indent text
2261
#                       showPath        => Bool
2262
#                       showSimplePath  => Bool
2263
#                       testFingerPrint => Bool
6133 dpurdie 2264
#
2265
# Returns         : True if this entry is to be fully process
2266
#                   False if its being skipped 
2267
#
2268
sub displayHeader
2269
{
2270
    my $fe = shift @_;
6198 dpurdie 2271
    if ($fe->{buildActive} || $fe->{buildSkip})
2272
    {
2273
        my $args = pop @_ if (@_ > 0 and UNIVERSAL::isa($_[-1],'HASH'));
2274
        #    my ($fe, %args) = @_;
6133 dpurdie 2275
 
6198 dpurdie 2276
        my $indent = $args->{indent} || '';
2277
        my $showPath = $args->{showPath};
2278
        my $showSimplePath = $args->{showSimplePath};
6133 dpurdie 2279
 
6198 dpurdie 2280
        my ($status, $estatus) = addBuildInfo($fe, $args);
2281
        $estatus = '' if $showSimplePath;
2282
 
2283
        my $msg1 = $indent . sprintf('Level:%02d [%s] Name: %s', $fe->{level}, $status, $fe->{dname} . $estatus );
2284
        if ($showSimplePath) {
2285
            my $msg1Len = length($msg1);
2286
            $msg1 = sprintf("%-*s Path: %s", 26 + $maxDname ,$msg1, $fe->{dir}); 
6133 dpurdie 2287
        }
6198 dpurdie 2288
        if ( $showPath) {
2289
            my $msg1Len = length($msg1);
2290
            if ($msg1Len < 80) {
2291
                $msg1 .= ' ' . '=' x (79 - $msg1Len);
2292
            }
2293
        }
2294
        Message( $msg1 ,  $showPath ? DisplayPath ("        Path: $fe->{dir}" ) : undef);
6133 dpurdie 2295
    }
2296
 
2297
   return $fe->{buildActive};
2298
}
2299
 
2300
#-------------------------------------------------------------------------------
2301
# Function        : addBuildInfo 
2302
#
2303
# Description     : Add some build info status
2304
#                   It will have a .sig file if its been sucessfully built
6276 dpurdie 2305
#                   
2306
#                   StatusFlags
2307
#                   Position 1: S - Build Skipped, s - Build Suppressed
2308
#                   Position 2: Blank - Not processed  , - = NoBuild, B - Built * - Current package
2309
#                   Position 3: E - Exists in dPkg, L - Local, M - Both local and dPkg
2310
#                   Position 4: G - Good Fingerprint, b - Bad Fingerprint
6133 dpurdie 2311
#
2312
# Inputs          : $fe     - Package info 
2313
#
6276 dpurdie 2314
# Returns         : StatusFlags
2315
#                   StatusText
6133 dpurdie 2316
#
2317
sub addBuildInfo
2318
{
2319
    my ($fe, $args) = @_;
2320
    my $txt = '';
6276 dpurdie 2321
    my $statusS = ' ';
6133 dpurdie 2322
    my $statusB = ' ';
6276 dpurdie 2323
    my $statusP = ' ';
6133 dpurdie 2324
    my $statusF = ' ';
2325
 
2326
    unless ($fe->{buildActive}) {
2327
        $txt .= ($fe->{buildSkip}) ? ' (Build Skipped)' : ' (Build Suppressed)';
2328
        $statusS = ($fe->{buildSkip}) ? 'S' : 's';
2329
    }
2330
 
2331
    if ($fe->{buildCurrent})
2332
    {
2333
        $statusB = '*';
2334
        $txt .= ' (Current Package)';
2335
    }
2336
 
6276 dpurdie 2337
    my $fpFile = getPkgFingerPrintFile($fe);
2338
    if (-f $fpFile)
6133 dpurdie 2339
    {
6276 dpurdie 2340
        my $nobFile = $fpFile;
2341
        $nobFile =~ s~ffp$~nob~;
2342
        if (-f $nobFile) {
6133 dpurdie 2343
            $txt .= ' [NoBuild]';
2344
            $statusB = '-';
2345
        } else {
2346
            $txt .= ' [Built]';
2347
            $statusB = 'B';
2348
        }
2349
 
2350
        if ($args->{testFingerPrint})
2351
        {
6276 dpurdie 2352
            if ( TagFileMatch($fpFile, genPkgFingerPrint($fe, 'Test')) )
6133 dpurdie 2353
            {
2354
                $txt .= ' [GoodFinger]';
2355
                $statusF = 'G';
2356
            } else {
2357
                $txt .= ' [BadFinger]';
2358
                $statusF = 'b';
2359
            }
2360
        }
6276 dpurdie 2361
    }
6133 dpurdie 2362
 
6276 dpurdie 2363
    my $preBuilt = check_package_existance($fe->{name}, $fe->{version});
2364
    if ($preBuilt) {
2365
        $txt .= ' [dPkg]';
2366
        $statusP = 'E';
6133 dpurdie 2367
    }
6276 dpurdie 2368
 
2369
    my $plink = catdir( $GBE_DPKG_SBOX, $fe->{name}, 'sandbox.' . $fe->{prj} . '.lnk' );
2370
    my $linkTarget = getPackageLink ($plink);
6133 dpurdie 2371
 
6276 dpurdie 2372
    Verbose ("Sandbox link: $plink -> $linkTarget");
2373
    if (-d $linkTarget) {
2374
        $txt .= ' [Local]';
2375
        if ($preBuilt) {
2376
            $statusP = 'M';
2377
        } else {
2378
            $statusP = 'L';
2379
        }
2380
    }
2381
 
2382
    return "$statusS$statusB$statusP$statusF", $txt ;
2383
 
6133 dpurdie 2384
}
2385
 
2386
#-------------------------------------------------------------------------------
1329 dpurdie 2387
# Function        : opts_add2List
2388
#
2389
# Description     : Option processing helper
2390
#                   Add comma separated options to an array
2391
#                   User can then add items one at a time, or several at once
2392
#
2393
# Inputs          : aref        - Ref to an array to extent
2394
#                   arg2        - Option name
2395
#                   arg3        - Option value
2396
#
2397
# Returns         : 
2398
#
2399
sub opts_add2List
2400
{
2401
    my( $ref, $name, $value) = @_;
2402
    if ( $value )
2403
    {
2404
        foreach ( split(/\s*,\s*/,$value) )
2405
        {
2406
            push @{$ref}, $_;
2407
        }
2408
    }
2409
}
2410
 
2411
#-------------------------------------------------------------------------------
6133 dpurdie 2412
# Function        : genPkgFingerPrint 
2413
#
2414
# Description     : Generate a fingerprint over all files in the packages tree as
2415
#                   well as the package dependencies
2416
# 
2417
#                   Only used to detect changes to files in the subdir
2418
# 
2419
#                   This version does not actually generate a fingerprint over
2420
#                   the data file, rather the metadata of the file. This is much (much)
2421
#                   faster as there is no file i/o.
2422
#                   
2423
#                   It does assume that the file metadata will change if the file is changed
2424
#                   Will also detect the addition / deletion of files
2425
#                   
6276 dpurdie 2426
#                   Note: This signature is not machine - type safe
6133 dpurdie 2427
#                         It will vary between machines (windows/Linux/...)
6276 dpurdie 2428
#                         At the moment the Sandbox is really a single machine tool
6133 dpurdie 2429
#
2430
# Inputs          : $fe            - Package entry of the package to process
2431
#                   $mode          - Diagnostic: mode
2432
#
2433
# Returns         : A SHA1 hash over all the files
2434
#                   
2435
#
2436
sub genPkgFingerPrint
2437
{
2438
    my ($fe, $mode) = @_;
2439
    my $genPkgFingerPrintSha1;
2440
    my $genPkgFingerPrintCount;
2441
    my @fpdata;
2442
 
2443
    #
2444
    #   Get the package GbeFiles.cfg file
2445
    #       This is held in the interface directory and is created during the build
2446
    #       Since the fingerprint is only genertated AFTER a successful build the file will always
2447
    #       be available
2448
    #       
2449
    #       All we need from this file is a list of Src directories that were discovered during
2450
    #       the build. Unfortuanatley they are not always below the root of the package.
2451
    #
2452
    my $ifaceDir = getpkgInterface($fe);
2453
    return 0 unless defined $ifaceDir;
2454
    return 0 unless ToolsetFiles::GetDataFile($ifaceDir); 
2455
 
2456
    #
2457
    #   Generate a list of directories in the package
2458
    #   This is the root directory and all other Src directories discovered
2459
    #
2460
    my @dirList = ToolsetFiles::GetSubTrees($ifaceDir);
2461
    Error ("Internal:ToolsetFiles::GetDirList for $fe->{dname} not populated" ) unless @dirList;
2462
 
2463
    #
6276 dpurdie 2464
    #   Generate a hash of toolset files and toolset-internal directories
2465
    #       These won't be included in the finger print as they are subject
2466
    #       to change by a 'build'.
2467
    #
2468
    my %toolsetFiles = map { $_ => 1 } ToolsetFiles::GetFiles($ifaceDir, 1);
2469
    my %toolsetDirs  = map { $_ => 1 } ToolsetFiles::GetBuildDirs($ifaceDir);
2470
 
2471
    #
6133 dpurdie 2472
    #   Create the hash
2473
    #
2474
    $genPkgFingerPrintSha1 = Digest->new("SHA-1");
2475
    push @fpdata, $mode;
2476
 
2477
    #
2478
    #   Include all dependent packages in the fingerprint
2479
    #       We are using the sandbox fingerprint of dependent packages
2480
    #       This will ensure that a change in a package will ripple through
2481
    #
2482
    foreach my $idep ( sort keys %{$fe->{ideps}})
2483
    {
2484
        my $ipkg = $packages{$idep};
2485
        my $tagFile = getPkgFingerPrintFile($ipkg); 
2486
        my $tag = TagFileRead($tagFile);
2487
        my $text = "$tagFile: $tag";
2488
        $genPkgFingerPrintSha1->add($text);
2489
#Debug0("genPkgFingerPrint: $text, ", $genPkgFingerPrintSha1->clone->hexdigest() );
2490
        push @fpdata, $text . ':' . $genPkgFingerPrintSha1->clone->hexdigest();
2491
    }
2492
 
2493
    #
2494
    #   Anonymous sub: findFile wanted function
2495
    #   Unlike the generation of the package signature, we don't need to
2496
    #   exclude any files.
2497
    #
2498
    my $wanted = sub {
2499
        my $item = $File::Find::name;
2500
 
2501
        #
2502
        #   Get file info
2503
        #       Kill of the last access time - not useful
2504
        #       
2505
        #       Need to exclude files that change during a null build
2506
        #           /interface/GbeFiles.cfg
2507
        #           /build.log
6276 dpurdie 2508
        #           These files are tracked in GbeBuild.cfg
2509
        #       Need to directories that change during a null build
2510
        #           These files are tracked in GbeBuild.cfg
6133 dpurdie 2511
        #           
2512
        #       Symlinks present problems.
2513
        #       Some packages generate symlinks as they create file system images. The
2514
        #       links are not designed to be interpreted in the context of the current
2515
        #       computer. As a result.
2516
        #           Some may be broken - on the current machine
2517
        #           Some may address files that change - ie: /proc, /var, /dev
2518
        #           Some may address files that such as /afc, /root
2519
        #       Don't want to discard all symlinks. Many of them will address package
2520
        #       dependencies and we do want to detect changes, but those changes will
2521
        #       be picked up by the packages fingerprint.
2522
        #       
2523
        #       Directories also appear to be a problem
2524
        #       The created and modified date-times appear to be modified for no good reason
2525
        #       
2526
        #       Current solution: Do not include 'stat' data for ANY symlink or directory
2527
        #
2528
        my @data = stat($item);
2529
        my $text;
6276 dpurdie 2530
 
2531
        if ( exists $toolsetFiles{$item}) {
6133 dpurdie 2532
            $text = "$item : SKIPPED FILE : ";
2533
 
2534
        }  elsif (-d $item ) {
6276 dpurdie 2535
            $text = "$item : DIRECTORY";
2536
            if ( exists $toolsetDirs{$item}) {
2537
                $File::Find::prune = 1;
2538
                $text = "$item : SKIP INTERNAL DIRECTORY";
2539
            }
2540
 
6133 dpurdie 2541
        }  elsif (-l $item ) {
2542
            if ( ! @data) {
2543
                $text = "$item : BROKEN SYMLINK : ";
2544
            } else {
2545
                my $linkTarget = readlink($item) || 'Read Error';
2546
                $text = "$item :SYMLINK: $linkTarget";
2547
            }
2548
 
2549
        } else {
2550
            $data[8] = 0;               # atime - will change
2551
            $data[12] = '-';            # blocks - seen to change for unknown reasons
7040 dpurdie 2552
            for my $ii ( 0 .. $#data) {
2553
                unless (defined $data[$ii]) {
2554
                    $data[$ii] = 'xx';
2555
                }
2556
            }
6133 dpurdie 2557
            $text = "$item : @data";
2558
        }
2559
        $genPkgFingerPrintCount++;
2560
        $genPkgFingerPrintSha1->add($text);
2561
#Debug0("genPkgFingerPrint: $text, ", $genPkgFingerPrintSha1->clone->hexdigest() );
2562
        push @fpdata, $text . ':' . $genPkgFingerPrintSha1->clone->hexdigest();
2563
    };
2564
 
2565
    #
2566
    #   Process all files in the package
2567
    #
2568
    $genPkgFingerPrintCount = 0;
2569
    my $dir = $fe->{dir};
2570
    File::Find::find( { wanted => $wanted , no_chdir => 1}, @dirList );
2571
#Debug0("genPkgFingerPrint: $dir, $genPkgFingerPrintCount, ", $genPkgFingerPrintSha1->clone->hexdigest() );
2572
    push @fpdata, $dir . ':'. $genPkgFingerPrintCount . ':' . $genPkgFingerPrintSha1->clone->hexdigest();
2573
 
2574
    #
2575
    #   Debugging - delete later
2576
    #   Save FP data to a file
2577
    #
7040 dpurdie 2578
   #my $fpDebugFile = catdir($GBE_SANDBOX, 'sandbox_dpkg_archive', $fe->{name} . '.' . $fe->{prj} . '_' . time() . '.fpd');
2579
   #Debug0("fpDebugFile: $fpDebugFile");
2580
   #FileCreate($fpDebugFile, @fpdata);
6133 dpurdie 2581
 
2582
    return $genPkgFingerPrintSha1->hexdigest;
2583
}
2584
 
2585
 
2586
#-------------------------------------------------------------------------------
2587
# Function        : getPkgFingerPrintFile 
2588
#
2589
# Description     : Return the package file that contains the packages Fast Finger Print
2590
#
2591
# Inputs          : $fe     - Package entry 
2592
#
2593
# Returns         : Full path to the packages fingerprint tag file
2594
#
2595
sub getPkgFingerPrintFile
2596
{
2597
    my ($fe) = @_;
2598
    my $tagFile = catdir($GBE_SANDBOX, 'sandbox_dpkg_archive', $fe->{name}, 'sandbox.' . $fe->{prj} . '.ffp');
2599
    return $tagFile;
2600
}
2601
 
2602
 
2603
#-------------------------------------------------------------------------------
359 dpurdie 2604
# Function        : SubCommandHelp
2605
#
2606
# Description     : Provide help on a subcommand
2607
#
2608
# Inputs          : $help_level             - Help Level 1,2,3
2609
#                   $topic                  - Topic Name
2610
#
2611
# Returns         : This function does not return
2612
#
2613
sub SubCommandHelp
2614
{
2615
    my ($help_level, $topic) = @_;
2616
    my @sections;
2617
    #
2618
    #   Spell out the section we want to display
2619
    #
2620
    #   Note:
2621
    #   Due to bug in pod2usage can't use 'head1' by itself
2622
    #   Each one needs a subsection.
2623
    #
2624
    push @sections, qw( NAME SYNOPSIS ) ;
2625
    push @sections, qw( ARGUMENTS OPTIONS )     if ( $help_level > 1 );
2626
    push @sections, qw( DESCRIPTION EXAMPLES )  if ( $help_level > 2 );
2627
 
2628
    #
2629
    #   Extract section from the POD
2630
    #
2631
    pod2usage({-verbose => 99,
2632
               -noperldoc => 1,
2633
               -sections => $topic . '/' . join('|', @sections) } );
2634
}
2635
 
2636
#-------------------------------------------------------------------------------
227 dpurdie 2637
#   Documentation
359 dpurdie 2638
#   NOTE
227 dpurdie 2639
#
359 dpurdie 2640
#   Each subcommand MUST have
2641
#   head1 section as used by the subcommand
2642
#       This should be empty, as the contents will NOT be displayed
2643
#   head2 sections called
2644
#       NAME SYNOPSIS ARGUMENTS OPTIONS DESCRIPTION EXAMPLES
2645
#
2646
#=head1 xxxxxx
2647
#=head2 NAME
2648
#=head2 SYNOPSIS
2649
#=head2 ARGUMENTS
2650
#=head2 OPTIONS
2651
#=head2 DESCRIPTION
2652
#=head2 EXAMPLES
2653
#
227 dpurdie 2654
 
2655
=pod
2656
 
2657
=head1 NAME
2658
 
2659
jats_sandbox - Build in a Development Sandbox
2660
 
2661
=head1 SYNOPSIS
2662
 
361 dpurdie 2663
  jats sandbox [options] command [command options]
227 dpurdie 2664
 
2665
 Options:
1329 dpurdie 2666
    -help[=n]                  - Display help with specified detail
2667
    -help -help                - Detailed help message
2668
    -man                       - Full documentation
227 dpurdie 2669
 
1329 dpurdie 2670
 Options for recursion control:
6276 dpurdie 2671
    -onlyLevel=number          - Limit building to one level
1329 dpurdie 2672
    -toPackage=name            - Stop building after package
2673
    -fromPackage=name          - Start building from package
2674
    -justPackage=name[,name]   - Build named packages
2675
    -ignorePackage=name[,name] - Do not build named packages
6133 dpurdie 2676
    -entireSandbox             - Process the entire sandbox
2677
    -users                     - Process package users, not dependencies
6198 dpurdie 2678
 Options common to all commands:
6133 dpurdie 2679
    -[no]keepgoing             - Ignore errors
2680
    -[no]reScan                - Recalculate and cache sandbox structure
6198 dpurdie 2681
    -multiBuilders=mode        - Handle conflicting packages. error|report|ignore
1329 dpurdie 2682
 
227 dpurdie 2683
 Commands:
2684
    help                - Same as -help
2685
    create              - Create a sandbox in the current directory
359 dpurdie 2686
    populate            - Populate the sandbox with packages
299 dpurdie 2687
    delete              - Delete the sandbox
255 dpurdie 2688
    info [[-v]-v]       - Sandbox information. -v: Be more verbose
4197 dpurdie 2689
    buildfilter         - Modify and display sandbox buildfilter
6133 dpurdie 2690
    [un]skip            - Mark a package to be skipped during the build
2691
    fingerprint         - Various fingerprint operations
6192 dpurdie 2692
    testlinks           - Test / Delete broken package symlinks
2693
    scandepth           - Set/Display the build file scan depth
227 dpurdie 2694
    cmd                 - Do commands in all sandbox components
1329 dpurdie 2695
    all                 - Do 'build', if required, then a make in all components
331 dpurdie 2696
    build               - Force 'build and make' in all sandbox components
275 dpurdie 2697
    make                - Do 'make' in all sandbox components
273 dpurdie 2698
    clean               - Do 'make clean' in all sandbox components
2699
    clobber             - Do 'build clobber' is all sandbox components
337 dpurdie 2700
    cache               - Cache external dependent packages
227 dpurdie 2701
 
359 dpurdie 2702
 Use the command
2703
    jats sandbox 'command' -h
2704
 for command specific help
361 dpurdie 2705
 
227 dpurdie 2706
=head1 OPTIONS
2707
 
2708
=over 8
2709
 
299 dpurdie 2710
=item B<-help[=n]>
227 dpurdie 2711
 
2712
Print a brief help message and exits.
299 dpurdie 2713
There are three levels of help
227 dpurdie 2714
 
299 dpurdie 2715
=over 8
2716
 
361 dpurdie 2717
=item   1
299 dpurdie 2718
 
361 dpurdie 2719
Brief synopsis
299 dpurdie 2720
 
361 dpurdie 2721
=item   2
299 dpurdie 2722
 
361 dpurdie 2723
Synopsis and option summary
2724
 
2725
=item   3
2726
 
2727
Detailed help in man format
2728
 
299 dpurdie 2729
=back 8
2730
 
227 dpurdie 2731
=item B<-help -help>
2732
 
2733
Print a detailed help message with an explanation for each option.
2734
 
2735
=item B<-man>
2736
 
299 dpurdie 2737
Prints the manual page and exits. This is the same a -help=3
227 dpurdie 2738
 
6276 dpurdie 2739
=item B<-onlyLevel=number>
2740
 
2741
This option is available in all commands that process multiple packages.
2742
Package processing will be limited to the specified level. 
2743
 
2744
This can be used to perform a multi-machine build. Level-1 builds are performed 
2745
on all machines and the results merged into the common package store, then Level-2 builds 
2746
are performed on all machines.
2747
 
2748
Level-1 packages have no dependencies.
2749
 
2750
Level-2 packages only have dependancies on Level-1 packages
2751
 
2752
Level-N packages only have dependancies on packages below Level N-1
2753
 
1329 dpurdie 2754
=item B<-toPackage=name>
2755
 
2756
This option is available in all commands that process multiple packages.
2757
Package processing will stop at the named package.
2758
 
4688 dpurdie 2759
The package name can be specified in one of three forms:
1329 dpurdie 2760
 
4184 dpurdie 2761
=over 8
2762
 
2763
=item 1 
2764
 
2765
Just the package name. ie: MyPackage
2766
 
2767
=item 2 
2768
 
2769
The package name and the project suffix. ie: MyPackage.prj
2770
 
2771
=item 3 
2772
 
2773
The package name and version, joined with an underscore: ie: MyPackage_1.0.0000.prj
2774
 
2775
=back 8
2776
 
1329 dpurdie 2777
=item B<-fromPackage=name>
2778
 
2779
This option is available in all commands that process multiple packages.
2780
Package processing will start at the named package.
2781
 
4688 dpurdie 2782
The package name can be specified in one of the three forms described under the '-toPackage' option.
1329 dpurdie 2783
 
2784
=item B<-justPackage=name[,name]>
2785
 
2786
This option is available in all commands that process multiple packages. The
2787
named packages will be processed in the correct build order. Packages that are
2788
not named will be skipped, unless the package is being processed due to
2789
being in the 'fromPackage' to 'toPackage' range.
2790
 
2791
Multiple packages can be named either by separating names with a comma, or
2792
with multiple options.
2793
 
4688 dpurdie 2794
The package names can be specified as a mix of the three forms described under the '-toPackage' option.
4184 dpurdie 2795
 
1329 dpurdie 2796
=item B<-ignorePackage=name[,name]>
2797
 
2798
This option is available in all commands that process multiple packages. The
2799
named packages will not be processed.
2800
 
2801
Multiple packages can be named either by separating names with a comma, or
2802
with multiple options.
2803
 
2804
The exclusion of a package takes precedence over its inclusion.
2805
 
4688 dpurdie 2806
The package names can be specified as a mix of the three forms described under the '-toPackage' option.
4184 dpurdie 2807
 
6133 dpurdie 2808
=item B<-[no]entireSandbox>
2809
 
6198 dpurdie 2810
This option will override the automatic package localisation that will occur if the user starts the command
2811
within a subdirectory of a package within the sandbox and will process the entire sanbbox.
6133 dpurdie 2812
 
2813
If the user start the command within a subdirectory of a package then the sandbox commands will be localised
2814
to the current package and the dependencies of the package.
2815
 
2816
=item B<-[no]users>
2817
 
2818
This option will completely change the packages considered to be built. The normal operation is to consider
2819
the current package and all packages that it depends upon.
2820
 
2821
This option will consider all packages that 'use' the current package, either directly or indirectly. It does not 
2822
include the 'current' pakage in this list. The assumption is that the current package has been sucessfully built 
2823
and needs to tested.
2824
 
2825
This option will work when they is a current package to be processed and not the entire sandbox.
2826
 
2827
The intended purpose of this option is to simplify regression testing.
2828
 
2829
=item B<-[no]keepgoing>
2830
 
2831
This options controls the behaviour of the command when an error is encountered.
2832
 
2833
The default operation is to terminate the command on the package with the
2834
error. This can be modified so that errors are ignored.
2835
 
2836
=item B<-[no]reScan>
2837
 
2838
This option controls the process of locating build files within the sandbox.
2839
 
2840
The default operation is to scan the sandbox and to cache the location of the build files.
2841
 
2842
If a package is added or removed from the sandbox, then the sandbox will need to be rescanned.
2843
Jats will detect when a package has been added or removed, but if the internal structure of the
2844
packages has changed the cached data may be incorrect. 
2845
 
6198 dpurdie 2846
=item B<-multiBuilders=mode>
2847
 
2848
If a package-name can be built by multiple packages then the sandbox processing will
2849
normally report an error.
2850
 
2851
This option allow the error to be reported as a warning or to be ignored altogether. The named package will be 
2852
excluded from the build set.
2853
 
2854
Valid values for 'mode' are: error, report and ignore.  The default mode is 'error'.
2855
 
7213 dpurdie 2856
One workaround is to use a 'stop' file. Any directory that contains 'stop' file will not be scanned for
2857
build files. If a 'stop' file is added then it may defeat caching of build information. The information will 
2858
need to be refreshed with the '--rescan' option. The 'stop' file should not be version controlled.
2859
 
279 dpurdie 2860
=back
2861
 
227 dpurdie 2862
=head1 DESCRIPTION
2863
 
299 dpurdie 2864
This program is the primary tool for the maintenance of Development Sandboxes.
2865
 
227 dpurdie 2866
More documentation will follow.
2867
 
279 dpurdie 2868
=head2 SANDBOX DIRECTORY
2869
 
299 dpurdie 2870
The sandbox directory is marked as being a sandbox through the use of the
2871
'sandbox create' command. This will create a suitable structure within the
279 dpurdie 2872
current directory.
2873
 
2874
Several JATS commands operate differently within a sandbox. The 'extract' and
365 dpurdie 2875
'release' commands will create static views within the sandbox and not the
279 dpurdie 2876
normal directory. The 'sandbox' sub commands can only be used within a sandbox.
2877
 
2878
The sandbox directory contains sub directories, each should contain a single
359 dpurdie 2879
package. Sub directories may be created with the 'jats extract' command or with the
2880
'jats sandbox populate' command.
279 dpurdie 2881
 
6133 dpurdie 2882
Note: Symbolic links are not supported. They cannot work as the sandbox mechanism
365 dpurdie 2883
requires that all the packages be contained within a sub directory tree so
279 dpurdie 2884
that the root of the sandbox can be located by a simple scan of the directory
2885
tree.
2886
 
325 dpurdie 2887
If a package subdirectory contains a file called 'stop' or 'stop.
2888
<GBE_MACHTYPE>', then that package will not be considered as a part of the
6133 dpurdie 2889
build-set. A 'stop' file will prevent consideration for all build platforms. The 'stop.
325 dpurdie 2890
<GBE_MACHTYPE>' will only prevent consideration if being built on a GBE_MACHTYPE
2891
type of computer.
279 dpurdie 2892
 
3559 dpurdie 2893
If the sandbox contains a file called 'buildfilter', then the contents of the
2894
file will be read and used a buildfilter. The file is processed by reading each
2895
line and:
2896
 
2897
=over 4
2898
 
4184 dpurdie 2899
=item * 
3559 dpurdie 2900
 
4184 dpurdie 2901
Removing white space at both ends of the line
3559 dpurdie 2902
 
4184 dpurdie 2903
=item * 
3559 dpurdie 2904
 
4184 dpurdie 2905
Removing empty lines
3559 dpurdie 2906
 
4184 dpurdie 2907
=item * 
2908
 
2909
Lines that start with a # are comments and are removed
2910
 
2911
=item * 
2912
 
2913
Remaining lines are joined together to form a buildfilter
2914
 
3559 dpurdie 2915
=back
2916
 
359 dpurdie 2917
=head1 Create Sandbox
299 dpurdie 2918
 
359 dpurdie 2919
=head2 NAME
299 dpurdie 2920
 
359 dpurdie 2921
Create Sandbox
2922
 
2923
=head2 SYNOPSIS
2924
 
1329 dpurdie 2925
jats sandbox create [command options]
359 dpurdie 2926
 
2927
 Command Options
2928
    -help[=n]               - Command specific help, [n=1,2,3]
2929
    -verbose[=n]            - Verbose operation
2930
    -exact                  - Create sandbox to reproduce exact versions
6619 dpurdie 2931
    -[no]force              - Force creation of nested sandbox
359 dpurdie 2932
 
2933
=head2 OPTIONS
2934
 
2935
The 'create' command takes the following options:
2936
 
2937
=over 8
2938
 
2939
=item -exact
2940
 
2941
When this option is specified the sandbox is marked for exact processing of
2942
package versions. In this mode the version numbers of the packages in the
2943
sandbox are significant. This is ideal for recreating a package-version.
2944
 
2945
The default is for in-exact processing, in which the version numbers of packages
2946
within the sandbox are not significant. The is ideal for development.
2947
 
6619 dpurdie 2948
=item -[no]force
2949
 
2950
Normally a sandbox should not be created within another sandbox. 
2951
 
2952
The use of this option overrides this limitation.
2953
 
2954
A sandbox with a sandbox will be ignored by the parent sandbox.
2955
 
359 dpurdie 2956
=back
2957
 
2958
=head2 DESCRIPTION
2959
 
299 dpurdie 2960
The 'create' command will create a sandbox in the users current directory. It is
2961
not possible to create a sandbox within a sandbox.
2962
 
2963
A sandbox can be created in a directory that contains files and subdirectories.
2964
 
2965
The create command simply places a known directory in the current directory.
359 dpurdie 2966
This directory is used by the sandboxing process. It may be manually deleted, or
299 dpurdie 2967
deleted with the 'delete' command.
2968
 
359 dpurdie 2969
=head1 Populate Sandbox
2970
 
2971
=head2 NAME
2972
 
2973
Populate a Sandbox
2974
 
2975
=head2 SYNOPSIS
2976
 
1329 dpurdie 2977
jats sandbox populate [command options] [packageName packageVersion]
359 dpurdie 2978
 
6198 dpurdie 2979
 Common Options:
2980
    -help[=n], -man            - Command specific help, [n=1,2,3]
6276 dpurdie 2981
    -onlyLevel=number          - Limit building to one level
1329 dpurdie 2982
    -toPackage=name            - Stop building after package
2983
    -fromPackage=name          - Start building from package
2984
    -justPackage=name[,name]   - Build named packages
2985
    -ignorePackage=name[,name] - Do not build named packages
6133 dpurdie 2986
    -entireSandbox             - Process the entire sandbox
2987
    -users                     - Process package users, not dependencies
6198 dpurdie 2988
    -multiBuilders=mode        - Handle conflicting packages. error|report|ignore
2989
    -[no]keepgoing             - Ignore errors
2990
    -[no]reScan                - Recalculate and cache sandbox structure
2991
 Command Specific Options
1329 dpurdie 2992
    -excludePackage=name[,name]- Do not extract named package
2993
    -recurse[=n]               - Locate dependencies within packages
2994
    -all                       - Populate with all dependencies
2995
    -missing                   - Locate missing packages
2996
    -show                      - Show packages that would be extracted
2997
    -test                      - Do not extract packages
2998
    -<Other>                   - Pass options to jats extract
359 dpurdie 2999
 
3000
=head2 ARGUMENTS
3001
 
3002
The 'populate' command can take a package name and version as arguments. It will
3003
then populate the sandbox with this package. See 'DESCRIPTION' for details.
3004
 
3005
=head2 OPTIONS
3006
 
3007
The 'populate' command takes the following options:
3008
 
3009
=over 4
3010
 
1329 dpurdie 3011
=item -excludePackage=name[,name]
3012
 
3013
This option prevents one, or more, packages from populating the sandbox.
3014
Packages specified with this option will not be extracted from version control
3015
and added to the sandbox.
3016
 
4688 dpurdie 3017
Packages can be identified in three ways:
1329 dpurdie 3018
 
3019
=over 4
3020
 
3021
=item 1. Package Name
3022
 
3023
All package versions matching the named package will be excluded.
3024
 
3025
=item 2. Package Name and Version
3026
 
3027
Only the specified version of the named package will be excluded. The
3028
user specifies the package name and version as a single string separated with
3029
an underscore. ie: core_devl_2.100.5000.cr
3030
 
3031
=item 3. Package Name and Suffix
3032
 
3033
All packages matching the named package and project will be excluded. The
3034
user specifies the package name and project as a single string separated with
3035
a dot. ie: core_devl.cr
3036
 
3037
 
3038
=back
3039
 
359 dpurdie 3040
=item -recurse[=N]
3041
 
3042
This option will modify the operation of the command such that dependencies
3043
of named packages can also be extracted into the sandbox.
3044
 
3045
The default operation is to only extract named packages. If the option is
3046
specified then all dependent packages are processed. An optional numeric argument
3047
can be specified to limit the depth of the recursion.
3048
 
1329 dpurdie 3049
=item -all
3050
 
3051
This option will populate the sandbox will all dependencies of packages that are
3052
currently in the sandbox.
3053
 
3054
The global options that control recursion will affect the packages that are
3055
processed.
3056
 
3057
This option cannot be used with the '-missing' option.
3058
 
359 dpurdie 3059
=item -missing
3060
 
3061
This option will modify the operation of the dependency recursion scanning such
3062
that dependent packages that exist in a package archive will not be extracted.
3063
 
3064
Use of this option allows a sandbox to be populated with packages that are
3065
required by packages in the sandbox, but are not available in a package archive.
3066
 
1329 dpurdie 3067
The global options that control recursion will affect the packages that are
3068
processed.
3069
 
3070
This option cannot be used with the '-all' option.
3071
 
3072
=item -show
3073
 
3074
This option will prevent the command from performing the extraction. It will
3075
simply display the names of the packages that would be extracted.
3076
 
359 dpurdie 3077
=item -test
3078
 
3079
This option will prevent the command from performing the extraction. It will
3080
simply display the JATS commands that can be used to perform the extraction.
3081
 
3082
=item -<Other>
3083
 
3084
Options not understood by the 'populate' sub command will be passed through
3085
the package extraction program. Useful options include:
3086
 
363 dpurdie 3087
=over 4
359 dpurdie 3088
 
361 dpurdie 3089
=item *
359 dpurdie 3090
 
361 dpurdie 3091
-extractfiles
359 dpurdie 3092
 
361 dpurdie 3093
=item *
3094
 
3095
-branch=<branch name>
3096
 
359 dpurdie 3097
=back
3098
 
3099
=back
3100
 
3101
=head2 DESCRIPTION
3102
 
3103
The 'populate' command can be used to assist in populating the sandbox. It has
3104
two modes of operation.
3105
 
363 dpurdie 3106
=over 4
359 dpurdie 3107
 
361 dpurdie 3108
=item 1
359 dpurdie 3109
 
361 dpurdie 3110
Named Package
3111
 
363 dpurdie 3112
If the user specifies both a package name and a package version then the command
359 dpurdie 3113
will populate the sandbox with that package and optionally its dependencies.
3114
 
361 dpurdie 3115
=item 2
359 dpurdie 3116
 
361 dpurdie 3117
Determine missing dependencies
3118
 
359 dpurdie 3119
If the user does not specify a package name and version, but does specify
3120
the '-missing' option,  then the command will examine the current sandbox and
3121
determine missing dependent packages. It will then populate the sandbox with
3122
these packages and optionally there dependencies.
3123
 
3124
=back
3125
 
3126
=head2 EXAMPLES
3127
 
3128
=over 4
3129
 
361 dpurdie 3130
=item *
359 dpurdie 3131
 
361 dpurdie 3132
jats sandbox populate package1 version1
3133
 
359 dpurdie 3134
This command will populate the sandbox with version1 of package1, if it does not
3135
already exist in the sandbox.
3136
 
361 dpurdie 3137
=item *
359 dpurdie 3138
 
361 dpurdie 3139
jats sandbox populate package1 version1 -recurse -missing
3140
 
359 dpurdie 3141
This command will populate the sandbox with version1 of package1, if it does not
3142
already exist in the sandbox, together will all the packages dependencies that
3143
are not available in a package archive.
3144
 
361 dpurdie 3145
=item *
359 dpurdie 3146
 
361 dpurdie 3147
jats sandbox populate -recurse -missing
3148
 
359 dpurdie 3149
This command will examine the current sandbox and populate the sandbox with
3150
packages that are required to build the packages in the sandbox and the
3151
dependencies of these packages, provide the dependent package is not in a
3152
package archive.
3153
 
361 dpurdie 3154
=item *
359 dpurdie 3155
 
361 dpurdie 3156
jats sandbox populate
3157
 
359 dpurdie 3158
This command will examine the current sandbox and populate the sandbox with
3159
packages that are required to build the packages in the sandbox. It will not
3160
examine the dependents of these packages.
3161
 
3162
=back
3163
 
3164
=head1 Delete Sandbox
3165
 
3166
=head2 NAME
3167
 
4688 dpurdie 3168
Delete a sandbox
359 dpurdie 3169
 
3170
=head2 SYNOPSIS
3171
 
3172
jats sandbox [options] delete
3173
 
3174
 Options:
3175
    -help[=n]               - Help message, [n=1,2,3]
3176
    -man                    - Full documentation [-help=3]
3177
    -verbose[=n]            - Verbose command operation
3178
 
3179
=head2 DESCRIPTION
3180
 
299 dpurdie 3181
The 'delete' command will delete the sandbox's marker directory. The command may
3182
be executed anywhere within the sandbox.
3183
 
359 dpurdie 3184
Once the sandbox has been deleted, the user must remove the components within the
299 dpurdie 3185
sandbox.
3186
 
359 dpurdie 3187
=head1 Sandbox Information
299 dpurdie 3188
 
359 dpurdie 3189
=head2 NAME
3190
 
3191
Display Sandbox Information
3192
 
3193
=head2 SYNOPSIS
3194
 
1329 dpurdie 3195
jats sandbox info [command options]
359 dpurdie 3196
 
6198 dpurdie 3197
 Common Options:
3198
    -help[=n], -man            - Command specific help, [n=1,2,3]
6276 dpurdie 3199
    -onlyLevel=number          - Limit building to one level
1329 dpurdie 3200
    -toPackage=name            - Stop building after package
3201
    -fromPackage=name          - Start building from package
3202
    -justPackage=name[,name]   - Build named packages
3203
    -ignorePackage=name[,name] - Do not build named packages
6133 dpurdie 3204
    -entireSandbox             - Process the entire sandbox
3205
    -users                     - Process package users, not dependencies
6198 dpurdie 3206
    -multiBuilders=mode        - Handle conflicting packages. error|report|ignore
3207
    -[no]keepgoing             - Ignore errors
3208
    -[no]reScan                - Recalculate and cache sandbox structure
3209
 Command Specific Options
3210
    -verbose[=n]               - Display more information
3211
    -usedby                    - Display package usage information
6133 dpurdie 3212
    -fingerprint               - Display fingerprint information
6192 dpurdie 3213
    -[no]dependencies          - Display external dependencies (default)
3214
    -[no]buildorder            - Display build order (default)
6198 dpurdie 3215
    -[no]path                  - Display path to package
361 dpurdie 3216
 
359 dpurdie 3217
=head2 OPTIONS
3218
 
3219
=over
3220
 
3221
=item B<-verbose[=n]>
3222
 
3223
This options will increase the verbosity of the information being displayed.
3224
Values 1 and 2 are described in the detailed 'DESCRIPTION'. Other values are
3225
reserved for diagnostic use.
3226
 
6133 dpurdie 3227
=item B<-usedby>
3228
 
3229
This option will list all packages that use the current package, both directly and
3230
indirectly. These are packages that should be tested whan changes are made to the 
3231
package.
3232
 
3233
=item B<-fingerprint>
3234
 
3235
This option will cause the information display to include that status of each packages fingerprint.
3236
 
3237
This will slow down the display as the calculation can be time consuming.
3238
 
6192 dpurdie 3239
=item B<-[no]dependencies>
3240
 
3241
This option will cause the information display to include all the external dependencies.
3242
 
3243
=item B<-[no]buildorder>
3244
 
3245
This option will cause the information display to include all the build order.
3246
 
6198 dpurdie 3247
=item B<-[no]path>
3248
 
3249
This option will cause the information display to include all the path to the build file
3250
 
359 dpurdie 3251
=back
3252
 
3253
=head2 DESCRIPTION
3254
 
299 dpurdie 3255
The 'info' command will display information about the build order and the
359 dpurdie 3256
dependencies of packages that it finds within the sandbox.
299 dpurdie 3257
 
359 dpurdie 3258
The command works within various levels of verbosity:
299 dpurdie 3259
 
3260
=over 8
3261
 
361 dpurdie 3262
=item *
299 dpurdie 3263
 
361 dpurdie 3264
No Verbosity
3265
 
299 dpurdie 3266
The basic command will display the build order and the external
335 dpurdie 3267
dependencies. External dependencies may be prefixed with one of the
3268
following indicators:
299 dpurdie 3269
 
335 dpurdie 3270
=over 8
3271
 
361 dpurdie 3272
=item   '+' Multiple versions of this package are being used by sandboxed components.
335 dpurdie 3273
 
361 dpurdie 3274
=item   '*' The package cannot be found in any of the package archives.
335 dpurdie 3275
 
3276
=back
3277
 
361 dpurdie 3278
=item *
299 dpurdie 3279
 
361 dpurdie 3280
Verbosity of 1
3281
 
359 dpurdie 3282
This level of verbosity will display the build order and detailed information
299 dpurdie 3283
on the dependencies. The dependencies will be prefixed with:
3284
 
3285
=over 8
3286
 
361 dpurdie 3287
=item   E Dependent Package is external to the sandbox
299 dpurdie 3288
 
361 dpurdie 3289
=item   I Dependent Package is internal to the sandbox
299 dpurdie 3290
 
3291
=back
3292
 
335 dpurdie 3293
External dependencies may be prefixed with one of the indicators described for
3294
no-verbosity. Additionally the internal consumer of the external package is also
3295
shown. These are prefixed with a 'U'.
299 dpurdie 3296
 
361 dpurdie 3297
=item *
299 dpurdie 3298
 
361 dpurdie 3299
Verbosity of 2
3300
 
6133 dpurdie 3301
Usage information will also be displayed. This is the same as invoking the 
3302
'-usedby' option.
299 dpurdie 3303
 
361 dpurdie 3304
=item *
299 dpurdie 3305
 
361 dpurdie 3306
Verbosity over 2
3307
 
359 dpurdie 3308
This should be considered a debug option. Undocumented internal information will
299 dpurdie 3309
be displayed.
3310
 
3311
=back
3312
 
7211 dpurdie 3313
The build infomation display will show the state of each package as a cryptic set of four characters within square brackets.
3314
 
3315
The first character may be one of:
3316
 
3317
=over 8
3318
 
3319
=item S - Build is being skipped
3320
 
3321
=item s - Build is being suppressed
3322
 
3323
=item blank - Build is active
3324
 
3325
=back
3326
 
3327
The second character may be one of:
3328
 
3329
=over 8
3330
 
3331
=item * - This is the current package
3332
 
3333
=item B - Has been build
3334
 
3335
=item - - A 'noBuild'. Will not be built due to build filters
3336
 
3337
=back
3338
 
3339
The third character may be one of:
3340
 
3341
=over 8
3342
 
3343
=item E - The package only exists in dpkg_archive
3344
 
3345
=item L - The package has been built and exists within the sandbox
3346
 
3347
=item M - The package has been built and exists in both the sandbox and dpkg_archive
3348
 
3349
=back
3350
 
3351
The fourth character may be one of (requires the -fingerprint option):
3352
 
3353
=over 8
3354
 
3355
=item G - A good fingerprint
3356
 
3357
=item B - A bad fingerprint. Files in the package have been modified since the last build.
3358
 
3359
=item blank - The package has not been built and no fingerprint has been calculated.
3360
 
3361
=back
3362
 
4197 dpurdie 3363
=head1 Buildfilter
3364
 
3365
=head2 NAME
3366
 
3367
Display and Modify Sandbox buildfilter
3368
 
3369
=head2 SYNOPSIS
3370
 
3371
jats sandbox buildfilter [command options] [TARGETS]+
3372
 
3373
 Command Options
3374
    -help[=n]               - Command specific help, [n=1,2,3]
3375
    -man                    - Same as -help=3
3376
 
3377
 Target Names
3378
    -TARGET                 - Remove target from the current buildfilter
3379
    +TARGET                 - Add target to current buildfilter
3380
    TARGET                  - If first target, then reset buildfilter 
3381
                              and add target, otherwise add target.
3382
 
3383
=head2 OPTIONS
3384
 
3385
The 'buildfilter' command takes the following options:
3386
 
3387
=over 8
3388
 
3389
=item -TARGET
3390
 
3391
If a target name starts with a '-' and is not an option, then that target will be
3392
removed from the current buildfilter. 
3393
 
3394
If the named target is not a part of the current buildfilter then nothing will happen.
3395
 
3396
=item +TARGET
3397
 
3398
If a target name starts with a '+' then that target will be added to the current buildfilter.
3399
 
3400
If the named target is already a part of the current buildfilter then nothing will happen.
3401
 
3402
 
3403
=item TARGET
3404
 
3405
If a target name does not start with either a '-' or a '+' then the target will be added to the
3406
current buildfilter.
3407
 
3408
If this is the first named target then the build filter will be set to this one target.
3409
 
3410
=back
3411
 
3412
=head2 DESCRIPTION
3413
 
3414
The 'buildfilter' command will display and optionally modify the build filter used within
3415
the sandbox.
3416
 
3417
=head2 EXAMPLES
3418
 
3419
The command
3420
 
3421
    jats sandbox buildfilter 
3422
 
3423
will simply display the current buildfilter.
3424
 
3425
The command
3426
 
3427
    jats sandbox buildfilter +COBRA +PPC_603E
3428
 
3429
will append the build targets COBRA and PPC_603E to the current buildfilter.
3430
 
3431
The command
3432
 
3433
    jats sandbox buildfilter -COBRA
3434
 
3435
will remove the build target COBRA from the current buildfilter.
3436
 
3437
The command
3438
 
3439
    jats sandbox buildfilter COBRA +PPC_603E
3440
 or jats sandbox buildfilter COBRA PPC_603E
3441
 
3442
will set the buildfilter to be COBRA and PPC_603E
3443
 
6133 dpurdie 3444
=head1 Skip Build
3445
 
3446
=head2 NAME
3447
 
3448
Mark a package to be skipped during the build
3449
 
3450
=head2 SYNOPSIS
3451
 
3452
jats sandbox [un]skip [command options] [PackageName]+
3453
 
3454
 Command Options
3455
    -help[=n]               - Command specific help, [n=1,2,3]
3456
    -man                    - Same as -help=3
3457
    -[no]machine            - Skip on on this type of machine
3458
 
3459
=head2 ARGUMENTS
3460
 
3461
Arguments to the 'skip' command are the names of packages to be marked.
3462
 
3463
If no packages are named then the command will display all packages that are marked to be skipped.
3464
 
3465
If the named package is '.', then the current package will be excluded.
3466
 
3467
=head2 OPTIONS
3468
 
3469
The 'skip' command takes the following options:
3470
 
3471
=over 8
3472
 
3473
=item -[no]machine
3474
 
3475
This option will flag that the package will be skipped only on this type of build machine.
3476
 
3477
=back
3478
 
3479
=head2 DESCRIPTION
3480
 
3481
The 'skip' command marked the named packages to be skipped during the build, or the mark will be removed.
3482
 
3483
=head2 EXAMPLES
3484
 
3485
The command
3486
 
3487
    jats sandbox skip package1 
3488
 
3489
will mark package1 to be skipped during the following builds.
3490
 
3491
=head1 Sandbox Finger Print
3492
 
3493
=head2 NAME
3494
 
3495
Various fingerprint operations
3496
 
3497
=head2 SYNOPSIS
3498
 
3499
jats sandbox finger[print] [options]
3500
 
3501
 Command Options
3502
    -help[=n]               - Command specific help, [n=1,2,3]
3503
    -man                    - Same as -help=3
3504
    -[no]generate           - Generate a fingerprint over a package
3505
    -[no]delete             - Delete the fingerprint information
3506
 
3507
=head2 ARGUMENTS
3508
 
3509
Arguments to the 'fingerprint' command are the names of packages to be processed.
3510
 
3511
If no packages are named then the command will process the current package, if any.
3512
 
3513
=head2 OPTIONS
3514
 
3515
The 'fingerprint' command takes the following options:
3516
 
3517
=over 8
3518
 
3519
=item -[no]generate
3520
 
3521
This option will cause the fingerprint of the package to be regenerated.
3522
 
3523
=item -[no]delete
3524
 
3525
This option will delete the fingerprint information associated wit a package.
3526
 
3527
=back
3528
 
3529
=head2 DESCRIPTION
3530
 
3531
The 'fingerprint' command, will by default, examine the packages fingerprint and report
3532
if the package has been modified since the fingerprint was created.
3533
 
3534
Options allow different modes of operation.
3535
 
3536
A fingerprint may only be created after the 'build.pl' file has been created. It requires the
3537
build process to generate metadata about the package.
3538
 
3539
=head2 EXAMPLES
3540
 
3541
The command
3542
 
3543
    jats sandbox fingerprint -generate
3544
 
3545
will regenerate the fingerprint of the current package. Useful after trivial edits to 
3546
enable the sandbox builder to bypass the package and not to rebuild it and all of its dependents.
3547
 
359 dpurdie 3548
=head1 Command all
331 dpurdie 3549
 
359 dpurdie 3550
=head2 NAME
3551
 
3552
Build packages in the sandbox
3553
 
3554
=head2 SYNOPSIS
3555
 
1329 dpurdie 3556
jats sandbox all [command options] [arguments]
359 dpurdie 3557
 
6198 dpurdie 3558
 Common Options:
3559
    -help[=n], -man            - Command specific help, [n=1,2,3]
6276 dpurdie 3560
    -onlyLevel=number          - Limit building to one level
1329 dpurdie 3561
    -toPackage=name            - Stop building after package
3562
    -fromPackage=name          - Start building from package
3563
    -justPackage=name[,name]   - Build named packages
3564
    -ignorePackage=name[,name] - Do not build named packages
6133 dpurdie 3565
    -entireSandbox             - Process the entire sandbox
3566
    -users                     - Process package users, not dependencies
6198 dpurdie 3567
    -multiBuilders=mode        - Handle conflicting packages. error|report|ignore
6133 dpurdie 3568
    -[no]keepgoing             - Ignore errors
6198 dpurdie 3569
    -[no]reScan                - Recalculate and cache sandbox structure
3570
 Command Specific Options
6133 dpurdie 3571
    -[no]skip                  - Skip if no source change (default:skip)
359 dpurdie 3572
 
6133 dpurdie 3573
 
359 dpurdie 3574
=head2 ARGUMENTS
3575
 
3576
Arguments are passed to the 'make' phase of the process.
3577
 
3578
=head2 OPTIONS
3579
 
6133 dpurdie 3580
=over
359 dpurdie 3581
 
6133 dpurdie 3582
=item B<-[no]skip>
3583
 
3584
This operation overides the default smart building mechanism.
3585
 
3586
By default, a package will not be built if the last build was successful and 
3587
there has not been any change to the source of the package, since the last 
3588
succesful build.
3589
 
3590
=back
3591
 
359 dpurdie 3592
=head2 DESCRIPTION
3593
 
331 dpurdie 3594
The 'all' command will perform build, if the build files are out of date,
3595
followed by a make in each of the packages within the sandbox, in the correct
3596
build order.
3597
 
3598
Any arguments are passed to the 'make' phase of the process.
3599
 
3600
This command may be used to:
3601
 
3602
=over 8
3603
 
361 dpurdie 3604
=item *
331 dpurdie 3605
 
361 dpurdie 3606
Pickup any build file changes.
331 dpurdie 3607
 
361 dpurdie 3608
=item *
3609
 
3610
Resume a failed build.
3611
 
331 dpurdie 3612
=back
3613
 
359 dpurdie 3614
=head1 Command build
331 dpurdie 3615
 
359 dpurdie 3616
=head2 NAME
3617
 
3618
Build packages in the sandbox
3619
 
3620
=head2 SYNOPSIS
3621
 
1329 dpurdie 3622
jats sandbox build [command options] [arguments]
359 dpurdie 3623
 
6198 dpurdie 3624
 Common Options:
3625
    -help[=n], -man            - Command specific help, [n=1,2,3]
6276 dpurdie 3626
    -onlyLevel=number          - Limit building to one level
1329 dpurdie 3627
    -toPackage=name            - Stop building after package
3628
    -fromPackage=name          - Start building from package
3629
    -justPackage=name[,name]   - Build named packages
3630
    -ignorePackage=name[,name] - Do not build named packages
6133 dpurdie 3631
    -entireSandbox             - Process the entire sandbox
3632
    -users                     - Process package users, not dependencies
6198 dpurdie 3633
    -multiBuilders=mode        - Handle conflicting packages. error|report|ignore
6133 dpurdie 3634
    -[no]keepgoing             - Ignore errors
6198 dpurdie 3635
    -[no]reScan                - Recalculate and cache sandbox structure
3636
 Command Specific Options
6133 dpurdie 3637
    -[no]skip                  - Skip if no source change (default:skip)
359 dpurdie 3638
 
3639
=head2 ARGUMENTS
3640
 
3641
Arguments are passed to the 'make' phase of the process.
3642
 
3643
=head2 OPTIONS
3644
 
6133 dpurdie 3645
=over
359 dpurdie 3646
 
6133 dpurdie 3647
=item B<-[no]skip>
3648
 
3649
This operation overides the default smart building mechanism.
3650
 
3651
By default, a package will not be built if the last build was successful and 
3652
there has not been any change to the source of the package, since the last 
3653
succesful build.
3654
 
3655
=back
3656
 
359 dpurdie 3657
=head2 DESCRIPTION
3658
 
331 dpurdie 3659
The 'build' command will force a build followed by a make in each of the packages
3660
within the sandbox, in the correct build order.
3661
 
3662
Any arguments are passed to the 'make' phase of the process.
3663
 
3664
In practice, the 'sandbox all' command is quicker.
3665
 
359 dpurdie 3666
=head1 Clean
331 dpurdie 3667
 
359 dpurdie 3668
=head2 NAME
3669
 
3670
Clean all sandbox components
3671
 
3672
=head2 SYNOPSIS
3673
 
1329 dpurdie 3674
jats sandbox clean|clobber [command options]
359 dpurdie 3675
 
6198 dpurdie 3676
 Common Options:
3677
    -help[=n], -man            - Command specific help, [n=1,2,3]
6276 dpurdie 3678
    -onlyLevel=number          - Limit building to one level
1329 dpurdie 3679
    -toPackage=name            - Stop building after package
3680
    -fromPackage=name          - Start building from package
3681
    -justPackage=name[,name]   - Build named packages
3682
    -ignorePackage=name[,name] - Do not build named packages
6133 dpurdie 3683
    -entireSandbox             - Process the entire sandbox
3684
    -users                     - Process package users, not dependencies
6198 dpurdie 3685
    -multiBuilders=mode        - Handle conflicting packages. error|report|ignore
6133 dpurdie 3686
    -[no]keepgoing             - Ignore errors
6198 dpurdie 3687
    -[no]reScan                - Recalculate and cache sandbox structure
359 dpurdie 3688
 
3689
=head2 ARGUMENTS
3690
 
3691
None
3692
 
3693
=head2 OPTIONS
3694
 
6198 dpurdie 3695
The are no command specific options.
359 dpurdie 3696
 
3697
=head2 DESCRIPTION
3698
 
3699
The 'clean' command will perform a 'jats make clean' in all components in the
3700
sandbox.
3701
 
3702
The 'clobber' command will perform a 'jats clobber' in all components in the
3703
sandbox.
3704
 
3705
=head1 make
3706
 
3707
=head2 NAME
3708
 
3709
Make packages in the sandbox
3710
 
3711
=head2 SYNOPSIS
3712
 
1329 dpurdie 3713
jats sandbox make [command options] [arguments]
359 dpurdie 3714
 
6198 dpurdie 3715
 Common Options:
3716
    -help[=n], -man            - Command specific help, [n=1,2,3]
6276 dpurdie 3717
    -onlyLevel=number          - Limit building to one level
1329 dpurdie 3718
    -toPackage=name            - Stop building after package
3719
    -fromPackage=name          - Start building from package
3720
    -justPackage=name[,name]   - Build named packages
3721
    -ignorePackage=name[,name] - Do not build named packages
6133 dpurdie 3722
    -entireSandbox             - Process the entire sandbox
3723
    -users                     - Process package users, not dependencies
6198 dpurdie 3724
    -multiBuilders=mode        - Handle conflicting packages. error|report|ignore
3725
    -[no]keepgoing             - Ignore errors
3726
    -[no]reScan                - Recalculate and cache sandbox structure
359 dpurdie 3727
 
3728
=head2 ARGUMENTS
3729
 
3730
Arguments are passed to the 'make' phase of the process.
3731
 
3732
=head2 OPTIONS
3733
 
3734
The are no command specific options.
3735
 
3736
=head2 DESCRIPTION
3737
 
331 dpurdie 3738
The 'make' command will perform a 'make' operation in each of the packages
3739
within the sandbox, in the correct build order.
3740
 
3741
Any arguments are passed to the 'make'.
3742
 
359 dpurdie 3743
=head1 cmd
331 dpurdie 3744
 
359 dpurdie 3745
=head2 NAME
3746
 
3747
Process each package with a specified command.
3748
 
3749
=head2 SYNOPSIS
3750
 
1329 dpurdie 3751
jats sandbox cmd [command options] [arguments]
359 dpurdie 3752
 
6198 dpurdie 3753
 Common Options:
3754
    -help[=n], -man            - Command specific help, [n=1,2,3]
6276 dpurdie 3755
    -onlyLevel=number          - Limit building to one level
1329 dpurdie 3756
    -toPackage=name            - Stop building after package
3757
    -fromPackage=name          - Start building from package
3758
    -justPackage=name[,name]   - Build named packages
3759
    -ignorePackage=name[,name] - Do not build named packages
6133 dpurdie 3760
    -entireSandbox             - Process the entire sandbox
3761
    -users                     - Process package users, not dependencies
6198 dpurdie 3762
    -multiBuilders=mode        - Handle conflicting packages. error|report|ignore
3763
    -[no]keepgoing             - Ignore errors
3764
    -[no]reScan                - Recalculate and cache sandbox structure
3765
 Command Specific Options
3766
    -[no]reverse               - Reverse the processing order
359 dpurdie 3767
 
3768
=head2 ARGUMENTS
3769
 
3770
Arguments are passed to a JATS command.
3771
 
3772
=head2 OPTIONS
3773
 
6198 dpurdie 3774
The 'cmd' command takes the following options:
359 dpurdie 3775
 
6198 dpurdie 3776
=over 8
2054 dpurdie 3777
 
6198 dpurdie 3778
=item -[no]reverse
2054 dpurdie 3779
 
6198 dpurdie 3780
This option will controlls the order in which the packages will be processed.
2054 dpurdie 3781
 
6198 dpurdie 3782
The default option is 'noreverse'. Packages will be processed in the build order.
3783
 
2054 dpurdie 3784
=back
3785
 
359 dpurdie 3786
=head2 DESCRIPTION
3787
 
331 dpurdie 3788
The 'cmd' command will pass all of its arguments to JATS in the build directory
3789
of each of the packages within the sandbox, in the package build order.
3790
 
4086 dpurdie 3791
=head2 EXAMPLES
3792
 
3793
The following command will update all the Subversion-based packages in the sandbox.
3794
 
3795
    jats sandbox cmd eprog svn update
3796
 
3797
Note the use of 'eprog' in the command string. This tells JATS to run the external
3798
(to JATS) program. Without this the command would run the JATS-internal command
3799
called 'svn' - with different results.
3800
 
3801
The following command will update the dependencies in the build.pl files to match
3802
those of a nominated release. This will only affect the package versions
3803
external to the sandbox, although all version information in the build.pl
3804
files will be updated.
3805
 
3806
    jats sandbox cmd upddep -rtagid=12345
3807
 
359 dpurdie 3808
=head1 Cache
331 dpurdie 3809
 
359 dpurdie 3810
=head2 NAME
331 dpurdie 3811
 
359 dpurdie 3812
Cache dependent packages
331 dpurdie 3813
 
359 dpurdie 3814
jats sandbox [options] cache [command options]
331 dpurdie 3815
 
359 dpurdie 3816
 Options:
3817
    -help[=n]               - Help message, [n=1,2,3]
3818
    -man                    - Full documentation [-help=3]
3819
    -verbose[=n]            - Verbose command operation
337 dpurdie 3820
 
359 dpurdie 3821
 Command Options
3822
    -help[=n]               - Command specific help, [n=1,2,3]
337 dpurdie 3823
 
359 dpurdie 3824
=head2 ARGUMENTS
3825
 
3826
The are no command specific arguments.
3827
 
3828
=head2 OPTIONS
3829
 
3830
The are no command specific options.
3831
 
3832
=head2 DESCRIPTION
3833
 
3834
The 'cache' command will cache all external dependent packages into the users
3835
dpkg_archive_cache as defined through the EnvVar GBE_DPKG_CACHE. The result is
3836
similar to the command 'jats sandbox build -cache', without the overhead of
3837
building the sandbox components.
3838
 
3839
This command allows the simple creation of a small development environment that
3840
is not tied to the larger Development Environment. It may then be used in a
337 dpurdie 3841
disconnected mode to perform development.
3842
 
6192 dpurdie 3843
=head1 Sandbox Test Links
3844
 
3845
=head2 NAME
3846
 
3847
Test and delete sandbox link files
3848
 
3849
=head2 SYNOPSIS
3850
 
3851
jats sandbox testlinks [options]
3852
 
3853
 Command Options
3854
    -help[=n]               - Command specific help, [n=1,2,3]
3855
    -man                    - Same as -help=3
3856
    -[no]delete             - Delete bad links
3857
 
3858
=head2 ARGUMENTS
3859
 
3860
This command does not take any arguments
3861
 
3862
=head2 OPTIONS
3863
 
3864
The 'fingerprint' command takes the following options:
3865
 
3866
=over 8
3867
 
3868
=item -[no]delete
3869
 
3870
This option will delete the link files if they are bad.
3871
 
3872
=back
3873
 
3874
=head2 DESCRIPTION
3875
 
3876
The 'testlinks' command, will by default, examine symbolic links within the sandbox and report on
3877
broken links.
3878
 
3879
An option allows the broken links to be deleted.
3880
 
3881
Each package in the sandbox will have a symbolic link to the packages 'package' area. If a package is removed
3882
from the sandbox the link file may be left in the sandbox and cause a 'build' to fail.
3883
 
3884
=head2 EXAMPLES
3885
 
3886
The command
3887
 
3888
    jats sandbox testlinks
3889
 
3890
will test the symbolic links in the sandbox metadata.
3891
 
3892
=head1 Sandbox Scan Depth
3893
 
3894
=head2 NAME
3895
 
3896
Set and Display the build file scanner depth
3897
 
3898
=head2 SYNOPSIS
3899
 
3900
jats sandbox scandepth [options] [depth]
3901
 
3902
 Command Options
3903
    -help[=n]               - Command specific help, [n=1,2,3]
3904
    -man                    - Same as -help=3
3905
 
3906
=head2 ARGUMENTS
3907
 
3908
This command takes one optional argument. A positive number that control the 
3909
depth of the build filter scanner.
3910
 
3911
The default value is '3'. Deeper scans may be required for sandboxes containing badly formed 
3912
packages. The tradoff is speed for all sandbox operations.
3913
 
3914
Setting the scan depth will force a rescan of the sandbox build files on the next command that
3915
requires the information.
3916
 
3917
=head2 OPTIONS
3918
 
3919
The scandepth command only accepts the standard help and man options.
3920
 
3921
=head2 DESCRIPTION
3922
 
3923
The scandepth command, will by default, display the current value for the build file scanner.
3924
 
3925
If a numeric argument is provided this will set the future build file scan depth.
3926
 
3927
=head2 EXAMPLES
3928
 
3929
The command
3930
 
3931
    jats sandbox scandepth 5
3932
 
3933
will set future build file scan to a maximum of 5 directories below the root of the sandbox.
3934
 
227 dpurdie 3935
=cut
3936