Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
227 dpurdie 1
########################################################################
263 dpurdie 2
# Copyright (C) 2008 ERG Limited, 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;
44
 
45
 
46
use Pod::Usage;                             # required for help support
47
use Getopt::Long qw(:config require_order); # Stop on non-option
48
my $VERSION = "1.0.0";                      # Update this
49
 
50
#
51
#   Options
52
#
53
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
54
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
359 dpurdie 55
my $opt_help = 0;                           # Help level
56
my $opt_exact = 0;                          # Exact (escrow) build
1273 dpurdie 57
my $opt_toPackage;                          # Control recursion
58
my $opt_fromPackage;                        # Control recursion
1328 dpurdie 59
my @opt_justPackage;                        # Control recursion
1273 dpurdie 60
my @opt_ignorePackage;                      # Control recursion
227 dpurdie 61
 
62
#
63
#   Globals - Provided by the JATS environment
64
#
65
my $USER         = $ENV{'USER'};
66
my $UNIX         = $ENV{'GBE_UNIX'};
67
my $HOME         = $ENV{'HOME'};
68
my $GBE_SANDBOX  = $ENV{'GBE_SANDBOX'};
69
my $GBE_DPKG_SBOX= $ENV{'GBE_DPKG_SBOX'};
325 dpurdie 70
my $GBE_MACHTYPE = $ENV{'GBE_MACHTYPE'};
227 dpurdie 71
 
3527 dpurdie 72
my $GBE_DPKG_LOCAL  = $ENV{'GBE_DPKG_LOCAL'};
73
my $GBE_DPKG_CACHE  = $ENV{'GBE_DPKG_CACHE'};
74
my $GBE_DPKG        = $ENV{'GBE_DPKG'};
75
my $GBE_DPLY        = $ENV{'GBE_DPLY'};
76
my $GBE_DPKG_STORE  = $ENV{'GBE_DPKG_STORE'};
77
my $GBE_BUILDFILTER = $ENV{'GBE_BUILDFILTER'};
335 dpurdie 78
 
227 dpurdie 79
#
80
#   Globals
81
#
1273 dpurdie 82
my @stopped = ();                         # Stopped entries
227 dpurdie 83
my @build_order = ();                     # Build Ordered list of entries
255 dpurdie 84
my %extern_deps;                          # Hash of external dependencies
227 dpurdie 85
my %packages;                             # Hash of packages
86
 
87
 
88
#-------------------------------------------------------------------------------
89
# Function        : Mainline Entry Point
90
#
91
# Description     :
92
#
93
# Inputs          :
94
#
95
 
96
#
97
#   Process help and manual options
98
#
1328 dpurdie 99
my $result = getOptionsFromArray ( \@ARGV );
227 dpurdie 100
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
101
pod2usage(-verbose => 1)  if ($opt_help == 2 );
299 dpurdie 102
pod2usage(-verbose => 2)  if ($opt_help > 2 );
227 dpurdie 103
 
104
#
105
#   Configure the error reporting process now that we have the user options
106
#
107
ErrorConfig( 'name'    => 'SANDBOX',
108
             'verbose' => $opt_verbose );
109
 
110
#
359 dpurdie 111
#   Reconfigure the options parser to allow subcommands to parse options
227 dpurdie 112
#
359 dpurdie 113
Getopt::Long::Configure('permute');
227 dpurdie 114
 
115
#
359 dpurdie 116
#   Determine Sandbox type. Exact or local
117
#
118
$opt_exact = (-f  $GBE_SANDBOX . '/sandbox_dpkg_archive/.exact' )
119
    if ( $GBE_SANDBOX );
120
 
121
#
227 dpurdie 122
#   Parse the user command and decide what to do
123
#
359 dpurdie 124
#   Remove user command from the command line. This will leave command options
125
#   in @ARGV so that they can be parsed by the subcommand.
227 dpurdie 126
#
127
my $cmd = shift @ARGV || "";
128
help(1)                                 if ( $cmd =~ m/^help$/ || $cmd eq "" );
359 dpurdie 129
buildcmd($cmd, @ARGV )                  if ( $cmd =~ m/(^all$)|(^build$)/  );
130
cache(@ARGV)                            if ( $cmd =~ m/^cache$/  );
131
clean($cmd, @ARGV)                      if ( $cmd =~ m/(^clobber$)|(^clean$)/  );
132
cmd('make', $cmd, @ARGV )               if ( $cmd =~ m/(^make$)/  );
133
cmd('cmd', @ARGV)                       if ( $cmd =~ m/^cmd$/ );
134
create_sandbox()                        if ( $cmd =~ m/^create$/ );
299 dpurdie 135
delete_sandbox()                        if ( $cmd =~ m/^delete$/ );
227 dpurdie 136
info(@ARGV)                             if ( $cmd =~ m/^info$/ );
359 dpurdie 137
populate(@ARGV)                         if ( $cmd =~ m/^populate$/  );
227 dpurdie 138
 
139
Error ("Unknown sandbox command: $cmd");
140
exit 1;
141
 
142
 
143
#-------------------------------------------------------------------------------
144
#
145
#   Give the user a clue
146
#
147
sub help
148
{
149
    my ($level) = @_;
150
    $level = $opt_help unless ( $level );
151
 
152
    pod2usage(-verbose => 0, -message => "Version: ". $VERSION)  if ($level == 1 );
153
    pod2usage(-verbose => $level -1 );
154
}
155
 
156
#-------------------------------------------------------------------------------
157
# Function        : create_sandbox
158
#
159
# Description     : create a sandbox in the current current directory
160
#
161
# Inputs          : None
162
#
163
#
164
sub create_sandbox
165
{
359 dpurdie 166
    GetOptions (
167
                "help:+"        => \$opt_help,
168
                "manual:3"      => \$opt_help,
169
                "exact"         => \$opt_exact,
170
                ) || Error ("Invalid command line" );
171
 
172
    SubCommandHelp( $opt_help, "Create Sandbox") if ($opt_help || $#ARGV >= 0 );
173
 
227 dpurdie 174
    Error ("Cannot create a sandbox within a sandbox",
175
           "Sandbox base is: $GBE_SANDBOX" ) if ( $GBE_SANDBOX );
359 dpurdie 176
 
227 dpurdie 177
    mkdir ('sandbox_dpkg_archive') || Error ("Cannot create the directory: sandbox_dpkg_archive") ;
359 dpurdie 178
 
179
    TouchFile( 'sandbox_dpkg_archive/.exact', 'Sandbox marker file')
180
        if ($opt_exact);
181
 
182
    Message ('Sandbox created' . ($opt_exact ? ' - With exact version number processing' : ''));
227 dpurdie 183
    exit  0;
184
}
185
 
186
#-------------------------------------------------------------------------------
299 dpurdie 187
# Function        : delete_sandbox
188
#
189
# Description     : Delete a sandbox
190
#                   Its up to the user the delete the components in the sandbox
191
#
192
# Inputs          : None
193
#
361 dpurdie 194
# Returns         :
299 dpurdie 195
#
196
sub delete_sandbox
197
{
359 dpurdie 198
    GetOptions (
199
                "help:+"        => \$opt_help,
200
                "manual:3"      => \$opt_help,
201
                ) || Error ("Invalid command line" );
202
 
203
    SubCommandHelp( $opt_help, "Delete Sandbox") if ($opt_help || $#ARGV >= 0 );
204
 
299 dpurdie 205
    unless ( $GBE_SANDBOX )
206
    {
207
        Warning("No sandbox found to delete");
208
    }
209
    else
210
    {
365 dpurdie 211
        Error ("Sandbox directory not completely removed")
361 dpurdie 212
            if RmDirTree( "$GBE_SANDBOX/sandbox_dpkg_archive" );
299 dpurdie 213
 
214
        Message("Sandbox information deleted",
215
                "Sandbox components must be manually deleted");
216
    }
217
    exit 0;
218
}
219
 
220
#-------------------------------------------------------------------------------
227 dpurdie 221
# Function        : info
222
#
223
# Description     : Display Sandbox information
224
#
225
# Inputs          : Command line args
226
#                   -v  - Be more verbose
227
#
228
# Returns         : Will exit
229
#
230
sub info
231
{
1328 dpurdie 232
    my (@cmd_opts ) = @_;
233
    my $show = 0;
227 dpurdie 234
 
1328 dpurdie 235
    Getopt::Long::Configure('pass_through');
236
    getOptionsFromArray ( \@cmd_opts,
237
                           'verbose:+'  => \$show,
238
                        ) || Error ("Invalid command line" );
239
    SubCommandHelp( $opt_help, "Sandbox Information") if ($opt_help || $#cmd_opts >=0 );
361 dpurdie 240
 
227 dpurdie 241
    #
242
    #   Determine Sandbox information
243
    #   Populate global variables
244
    #
1273 dpurdie 245
    calc_sandbox_info(1);
227 dpurdie 246
 
247
    #
248
    #   Display information
249
    #
3527 dpurdie 250
    Message ("Type       : " . ($opt_exact ? 'Exact' : 'Development') );
251
    Message ("Base       : $GBE_SANDBOX");
252
    Message ("Archive    : $GBE_DPKG_SBOX");
253
    Message ("BuildFilter: $GBE_BUILDFILTER" . ( (-f $GBE_SANDBOX . '/buildfilter')  ? ' - Local to sandbox' : ''));
227 dpurdie 254
 
1273 dpurdie 255
 
227 dpurdie 256
    Message ("Build Order");
1273 dpurdie 257
    foreach my $pname ( @stopped )
258
    {
259
        Message( "    Level:" . "-"  . " Name: " . $pname . ' (Stopped)');
260
    }
227 dpurdie 261
    foreach my $fe ( @build_order )
262
    {
1273 dpurdie 263
        Message( "    Level:" . $fe->{level} . " Name: " . $fe->{dname} . ($fe->{buildActive} ? '' : ' (Build Suppressed)'));
1328 dpurdie 264
        Message( DisplayPath ("        Path: $fe->{dir}" )) if $show;
227 dpurdie 265
 
1328 dpurdie 266
        if ( $show )
227 dpurdie 267
        {
359 dpurdie 268
            foreach my $idep ( sort values %{$fe->{'ideps'}} )
227 dpurdie 269
            {
359 dpurdie 270
                Message ("        I:$idep");
227 dpurdie 271
            }
272
 
359 dpurdie 273
            foreach my $edep ( sort keys %{$fe->{'edeps'}} )
227 dpurdie 274
            {
359 dpurdie 275
                my ($ppn,$ppv) = split( $; , $edep);
276
                Message ("        E:$ppn $ppv");
227 dpurdie 277
            }
361 dpurdie 278
 
227 dpurdie 279
        }
280
    }
281
 
359 dpurdie 282
    #
283
    #   External dependencies flags
284
    #       * - Package does not exist in dpkg_archive
285
    #       + - Multiple versions of this package are used
286
 
255 dpurdie 287
    Message("External Dependencies");
227 dpurdie 288
    foreach my $de ( sort keys %extern_deps )
289
    {
290
        my @vlist = keys %{$extern_deps{$de}};
335 dpurdie 291
        my $flag = $#vlist ? '+' : '';
359 dpurdie 292
        foreach my $pve ( @vlist )
227 dpurdie 293
        {
359 dpurdie 294
            my ($pn,$pv) = split( $; , $pve );
295
            my $exists = check_package_existance($pn,$pv  ) ? '' : '*';
335 dpurdie 296
            my $flags = sprintf ("%4.4s", $flag . $exists);
359 dpurdie 297
            Message ("${flags}${pn} ${pv}");
1328 dpurdie 298
            if ( $show )
227 dpurdie 299
            {
359 dpurdie 300
                foreach my $pkg ( @{$extern_deps{$de}{$pve}} )
227 dpurdie 301
                {
359 dpurdie 302
                    my $ppn = join ('.', split( $; , $pkg));
303
                    Message ("        U:$ppn");
227 dpurdie 304
                }
305
            }
359 dpurdie 306
 
227 dpurdie 307
        }
308
    }
309
 
1328 dpurdie 310
    if ( $show > 2 || $opt_verbose > 2 )
227 dpurdie 311
    {
312
        DebugDumpData( "extern_deps", \%extern_deps);
313
        DebugDumpData( "build_order", \@build_order);
314
        DebugDumpData( "packages", \%packages);
315
    }
316
    exit (0);
317
}
318
 
319
#-------------------------------------------------------------------------------
335 dpurdie 320
# Function        : check_package_existance
321
#
322
# Description     : Determine if a given package-version exists
323
#
324
# Inputs          : $name           - Package Name
325
#                   $ver            - Package Version
326
#
327
# Returns         : true            - Package exists
328
#
329
sub check_package_existance
330
{
331
    my ($name, $ver) = @_;
332
    #
333
    #   Look in each package archive directory
334
    #
335
    foreach my $dpkg ( $GBE_DPKG_SBOX,
336
                       $GBE_DPKG_LOCAL,
337
                       $GBE_DPKG_CACHE,
338
                       $GBE_DPKG,
339
                       $GBE_DPLY,
340
                       $GBE_DPKG_STORE )
341
    {
342
        next unless ( $dpkg );
343
        if ( -d "$dpkg/$name/$ver" )
344
        {
345
            return 1;
346
        }
347
    }
348
   return 0;
349
}
350
 
351
 
352
#-------------------------------------------------------------------------------
227 dpurdie 353
# Function        : calc_sandbox_info
354
#
355
# Description     : Examine the sandbox and determine all the important
356
#                   information
357
#
1273 dpurdie 358
#                   Operation will be modified by
359
#                       $opt_toPackage
360
#                       $opt_fromPackage
1328 dpurdie 361
#                       @opt_justPackage
1273 dpurdie 362
#                       @opt_ignorePackage
227 dpurdie 363
#
1273 dpurdie 364
# Inputs          : info                - True: Just for info
365
#                                               Keep supressed packages
366
#
227 dpurdie 367
# Returns         : Will exit if not in a sandbox
368
#                   Populates global variables
369
#                       @build_order - build ordered array of build entries
370
#
371
sub calc_sandbox_info
372
{
1273 dpurdie 373
    my ($info) = @_;
374
 
227 dpurdie 375
    #
376
    #   Start from the root of the sandbox
377
    #
378
    Error ("Command must be executed from within a Sandbox") unless ( $GBE_SANDBOX );
379
    chdir ($GBE_SANDBOX) || Error ("Cannot chdir to $GBE_SANDBOX");
380
 
381
    #
382
    #   Locate all packages within the sandbox
383
    #   These will be top-level directories - one per package
384
    #
385
    my @dirlist;
386
    my @build_list;
255 dpurdie 387
    foreach my $pname ( glob("*") )
227 dpurdie 388
    {
255 dpurdie 389
        next if ( $pname =~ m~^\.~ );
390
        next if ( $pname =~ m~dpkg_archive$~ );
297 dpurdie 391
        next if ( $pname =~ m~^CVS$~ );
255 dpurdie 392
        next unless ( -d $pname );
393
        Verbose ("Package discovered: $pname");
275 dpurdie 394
 
325 dpurdie 395
        if ( -f "$pname/stop" || -f "$pname/stop.$GBE_MACHTYPE" )
275 dpurdie 396
        {
1273 dpurdie 397
            push @stopped, $pname;
275 dpurdie 398
            Warning("Package contains stop file: $pname");
399
            next;
400
        }
401
 
255 dpurdie 402
        push @dirlist, $pname;
227 dpurdie 403
 
404
        #
405
        #   Locate the build files in each package
245 dpurdie 406
        #   Scan the build files and extract dependancy information
227 dpurdie 407
        #
359 dpurdie 408
        my $bscanner = BuildFileScanner( $pname, 'build.pl',
409
                                                 '--LocateAll',
410
                                                 $opt_exact ? '--ScanExactDependencies' : '--ScanDependencies' );
245 dpurdie 411
        $bscanner->scan();
412
        my @blist = $bscanner->getInfo();
255 dpurdie 413
        Warning ("Package does not have build files: $pname") unless ( @blist );
414
        Warning ("Package has multiple build files: $pname") if ( $#blist > 0 );
245 dpurdie 415
        push @build_list, @blist;
227 dpurdie 416
    }
417
 
418
    #
419
    #   Process each build file and extract
420
    #       Name of the Package
421
    #       Dependency list
422
    #   Build up a hash of dependence information
423
    #
424
 
425
    my %depends;
299 dpurdie 426
    my %multi;
245 dpurdie 427
    foreach my $be ( @build_list )
227 dpurdie 428
    {
245 dpurdie 429
        Verbose( DisplayPath ("Build file: " . $be->{dir} . " Name: " . $be->{file} ));
359 dpurdie 430
        #
431
        #   Sandbox vs Exact processing
432
        #       Set a suitable display name
433
        #       Set a suitable tag
434
        #
435
        $be->{dname} = $opt_exact ? $be->{full}    : $be->{mname};
436
        $be->{tag}   = $opt_exact ? $be->{fullTag} : $be->{package};
437
 
245 dpurdie 438
#        DebugDumpData ("be", $be );
227 dpurdie 439
 
440
        #
299 dpurdie 441
        #   Catch multiple builds for the same package
442
        #   Report later - when we have all
443
        #
359 dpurdie 444
        next unless ( $be->{dname} );
445
        push @{$multi{$be->{dname}}},$be->{dir};
299 dpurdie 446
 
447
        #
227 dpurdie 448
        #   Add into dependency struct
449
        #
1273 dpurdie 450
        $depends{$be->{tag}} = $be;
227 dpurdie 451
    }
452
 
359 dpurdie 453
    foreach my $dname ( sort keys %multi )
299 dpurdie 454
    {
365 dpurdie 455
        ReportError ("Multiple builders for : $dname", @{$multi{$dname}} )
359 dpurdie 456
            if ( scalar @{$multi{$dname}} > 1 );
299 dpurdie 457
    }
458
    ErrorDoExit();
459
 
245 dpurdie 460
#DebugDumpData ("depends", \%depends );
461
 
227 dpurdie 462
    #
463
    #   Determine the build order
464
    #
465
    @build_order = ();
466
    my $more = 1;
467
    my $level = 0;
468
 
469
    #
255 dpurdie 470
    #   Remove any dependencies to 'external' packages
227 dpurdie 471
    #   These will not be met internally and can be regarded as constant
472
    #
1273 dpurdie 473
    #   Split 'depends' into internal (ideps) and external (edeps)
474
    #       edeps : External Dependencies
475
    #               Key:        Name;Version
476
    #               Value:      'tag' - index into packages
477
    #       ideps : Internal Dependencies
478
    #               Key:        'tag'   - Index into packages
479
    #               Value:      'dname' - Display Name
480
    #
227 dpurdie 481
    foreach my $key ( keys %depends )
482
    {
483
        foreach my $build ( keys( %{$depends{$key}{depends}} ))
484
        {
485
            unless (exists $depends{$build})
486
            {
1273 dpurdie 487
                $depends{$key}{'edeps'}{$depends{$key}{depends}{$build}} = $build;
227 dpurdie 488
                delete ($depends{$key}{depends}{$build}) ;
489
                Verbose2( "Not in set: $build");
490
            }
491
            else
492
            {
1273 dpurdie 493
                $depends{$key}{'ideps'}{$build} = $depends{$build}{dname};
227 dpurdie 494
            }
495
        }
496
    }
359 dpurdie 497
 
498
#DebugDumpData ("depends", \%depends );
499
 
361 dpurdie 500
 
359 dpurdie 501
    #
502
    #   Determine package build order
503
    #       Scan the list of packages in the build set and determine
504
    #       those with no dependencies. These can be built.
505
    #       Remove those packages as dependents from all packages
506
    #       Repeat.
507
    #
1328 dpurdie 508
    my %found    = map { $_ => 1 } @opt_ignorePackage;
509
    my %notFound = map { $_ => 1 } @opt_justPackage;
1273 dpurdie 510
    my $scan_start = 0;
511
    my $scan_stop = 0;
1328 dpurdie 512
    my $scan_active = ($opt_fromPackage) ? 0 : 1;
513
    $scan_active = 0 if ( !$opt_fromPackage && !$opt_fromPackage && !@opt_ignorePackage && @opt_justPackage );
1273 dpurdie 514
 
227 dpurdie 515
    while ( $more )
516
    {
517
        $more = 0;
518
        $level++;
519
        my @build;
520
 
521
        #
522
        #   Locate packages with no dependencies
523
        #
524
        foreach my $key ( keys %depends )
525
        {
526
            next if ( keys( %{$depends{$key}{depends}} ) );
527
            push @build, $key;
528
        }
529
 
530
        foreach my $build ( @build )
531
        {
532
            $more = 1;
1273 dpurdie 533
            my $fe = $depends{$build};
534
            my $scan_add = $scan_active ? 1 : 0;
535
 
1328 dpurdie 536
            if ( $opt_fromPackage && (($fe->{mname} eq $opt_fromPackage) || ($fe->{name} eq $opt_fromPackage)))
1273 dpurdie 537
            {
1328 dpurdie 538
                $scan_add = 1;
539
                $scan_active = 1;
540
                $scan_start = 1;
541
            }
542
 
543
            if ( $opt_toPackage && (($fe->{mname} eq $opt_toPackage) || ($fe->{name} eq $opt_toPackage)))
544
            {
1273 dpurdie 545
                $scan_add = 0;
1328 dpurdie 546
                $scan_active = 0;
547
                $scan_stop = 1;
548
            }
549
 
550
            if ( @opt_justPackage )
551
            {
552
                foreach my $pname ( @opt_justPackage )
1273 dpurdie 553
                {
554
                    if ( (($fe->{mname} eq $pname) || ($fe->{name} eq $pname)))
555
                    {
556
                        $scan_add = 1;
557
                        delete $notFound{$pname};
558
                    }
559
                }
560
            }
1328 dpurdie 561
 
1273 dpurdie 562
            if ( @opt_ignorePackage )
563
            {
564
                foreach my $pname ( @opt_ignorePackage )
565
                {
566
                    if ( (($fe->{mname} eq $pname) || ($fe->{name} eq $pname)))
567
                    {
568
                        $scan_add = 0;
569
                        delete $found{$pname};
570
                    }
571
                }
572
            }
573
 
227 dpurdie 574
            $fe->{level} = $level;
1273 dpurdie 575
            $fe->{buildActive} = $scan_add;
227 dpurdie 576
            $packages{$build} = $fe;
1273 dpurdie 577
            push (@build_order, $fe) if ( $scan_add || $info );
227 dpurdie 578
            delete $depends{$build};
579
            delete $fe->{depends};                          # remove now its not needed
580
        }
581
 
582
        foreach my $key ( keys %depends )
583
        {
584
            foreach my $build ( @build )
585
            {
586
                delete $depends{$key}{depends}{$build};
587
            }
588
        }
589
    }
590
 
591
    #
1273 dpurdie 592
    #   Detect bad user specifications
593
    #
594
    ReportError ("Specified FromPackage not found: $opt_fromPackage") if ( $opt_fromPackage && !$scan_start );
595
    ReportError ("Specified ToPackage not found: $opt_toPackage") if ( $opt_toPackage && !$scan_stop );
596
    ReportError ("Specified ExactPackages not found: ", keys( %notFound) ) if ( %notFound );
597
    ReportError ("Specified IgnorePackages not found: ", keys( %found) ) if ( %found );
598
    ErrorDoExit();
599
 
600
    #
601
    #   Calculate the external dependencies
602
    #       Only process packages that are a part of the build
603
    #
604
    #   extern_deps structure
605
    #       Hash key: 'tag'   - Index into packages
606
    #          Value: Hash of:
607
    #                 Key  : Name;Version
608
    #                 Value: Array of: 'tags' (Index into packages)
609
    #                                   of packages that use the external
610
    #                                   component.
611
    {
612
        Verbose ("Calculate external dependencies");
613
        %extern_deps = ();
614
 
615
        foreach my $key ( keys %packages )
616
        {
617
                next unless ( $packages{$key}{buildActive} );
618
                next unless ( $packages{$key}{'edeps'} );
619
                foreach ( keys %{$packages{$key}{'edeps'}} )
620
                {
621
                    push @{$extern_deps{$packages{$key}{'edeps'}{$_}} {$_} }, $key;
622
                }
623
        }
624
    }
625
 
626
    #
227 dpurdie 627
    #   Just to be sure to be sure
628
    #
245 dpurdie 629
    if ( keys %depends )
630
    {
631
        #DebugDumpData ("depends", \%depends );
632
        Error( "Internal algorithm error: Bad dependancy walk",
633
               "Possible circular dependency");
634
    }
227 dpurdie 635
 
1273 dpurdie 636
#   DebugDumpData("Packages", \%packages);
359 dpurdie 637
#   DebugDumpData ("Order", \@build_order);
638
#   DebugDumpData("External Depends", \%extern_deps );
227 dpurdie 639
}
640
 
641
#-------------------------------------------------------------------------------
642
# Function        : cmd
643
#
644
# Description     : Execute a command in all the sandboxes
645
#                       Locate the base of the sandbox
646
#                       Locate all packages in the sandbox
647
#                       Locate all build files in each sandbox
648
#                       Determine build order
649
#                       Issue commands for each sandbox in order
650
#
255 dpurdie 651
# Inputs          : Arguments passed to jats build
227 dpurdie 652
#
653
# Returns         : Will exit
654
#
655
sub cmd
656
{
1328 dpurdie 657
    my ($hcmd, @cmd_opts ) = @_;
2053 dpurdie 658
    my $opt_keepgoing;
359 dpurdie 659
 
660
    Getopt::Long::Configure('pass_through');
2053 dpurdie 661
    getOptionsFromArray ( \@cmd_opts,
662
                           'keepgoing!'  => \$opt_keepgoing,
663
                        ) || Error ("Invalid command line" );
359 dpurdie 664
    SubCommandHelp( $opt_help, $hcmd) if ($opt_help  );
665
 
227 dpurdie 666
    #
667
    #   Determine Sandbox information
668
    #   Populate global variables
669
    #
670
    calc_sandbox_info();
671
    foreach my $fe ( @build_order )
672
    {
673
        my $dir = $fe->{dir};
359 dpurdie 674
        Message( "Level:" . $fe->{level} . " Name: " . $fe->{dname} ,
227 dpurdie 675
                  DisplayPath ("        Path: $fe->{dir}" ));
676
 
1328 dpurdie 677
        my $result = JatsCmd( "-cd=$dir", @cmd_opts);
2053 dpurdie 678
        if ( $result ) {
679
            if ( $opt_keepgoing ) {
680
                Warning ("Cmd failure");
681
            } else {
682
                Error   ("Cmd failure");
683
            }
684
        }
227 dpurdie 685
    }
686
 
687
    exit 0;
688
}
689
 
690
#-------------------------------------------------------------------------------
331 dpurdie 691
# Function        : buildcmd
692
#
693
# Description     : Build the entire sandbox
694
#                   The all and the build are similar.
695
#                   Its not really useful to do a build without a make
696
#                   so we don't try
697
#
698
# Inputs          : Arguments passed to jats make
699
#
700
#
701
# Returns         : Will exit
702
#
703
 
704
sub buildcmd
705
{
337 dpurdie 706
    my ($cmd, @cmd_opts) = @_;
331 dpurdie 707
    my @build_opts;
337 dpurdie 708
    my @make_opts;
331 dpurdie 709
 
710
    #
359 dpurdie 711
    #   Extract and options
712
    #
713
    Getopt::Long::Configure('pass_through');
1328 dpurdie 714
    getOptionsFromArray ( \@cmd_opts ) || Error ("Invalid command line" );
359 dpurdie 715
    SubCommandHelp( $opt_help, "Command $cmd") if ($opt_help );
361 dpurdie 716
 
359 dpurdie 717
    #
331 dpurdie 718
    #   Insert default options
719
    #
720
    push @build_opts, '-noforce' if ( $cmd eq 'all' );
721
    push @build_opts, '-force' if ( $cmd ne 'all' );
722
 
337 dpurdie 723
    #
724
    #   Attempt to split the options into build and make options
725
    #   Only handle the often used options to build.
726
    #
727
    foreach  ( @cmd_opts )
728
    {
729
        if ( m/^-cache/ || m/^-package/ || m/^-forcebuildpkg/ || m/-expert/) {
730
            push @build_opts, $_;
731
        } else {
732
            push @make_opts, $_;
733
        }
734
    }
735
 
331 dpurdie 736
    push @make_opts, 'all'  unless ( @make_opts  );
737
 
738
    #
739
    #   Determine Sandbox information
740
    #   Populate global variables
741
    #
742
    calc_sandbox_info();
743
    foreach my $fe ( @build_order )
744
    {
745
        my $dir = $fe->{dir};
359 dpurdie 746
        Message( "Level:" . $fe->{level} . " Name: " . $fe->{dname} ,
331 dpurdie 747
                  DisplayPath ("        Path: $fe->{dir}" ));
748
 
749
        JatsCmd( "-cd=$dir", 'build', @build_opts) && Error ("Build Cmd failure") if ( $result );
750
        JatsCmd( "-cd=$dir", 'make',  @make_opts)  && Error ("Make Cmd failure")  if ( $result );
751
    }
752
 
753
    exit 0;
754
}
755
 
756
 
757
#-------------------------------------------------------------------------------
273 dpurdie 758
# Function        : clean
759
#
760
# Description     : Execute a command in all the sandboxes
761
#                       Locate the base of the sandbox
762
#                       Locate all packages in the sandbox
763
#                       Locate all build files in each sandbox
764
#                       Determine build order
765
#                       Issue commands for each sandbox in order
766
#
767
# Inputs          : Arguments passed to jats build
768
#
769
# Returns         : Will exit
770
#
771
sub clean
772
{
1328 dpurdie 773
    my ($mode, @cmd_opts ) = @_;
359 dpurdie 774
 
273 dpurdie 775
    #
359 dpurdie 776
    #   Extract and options
777
    #
778
    Getopt::Long::Configure('pass_through');
1328 dpurdie 779
    getOptionsFromArray ( \@cmd_opts ) || Error ("Invalid command line" );
359 dpurdie 780
    SubCommandHelp( $opt_help, "Clean") if ($opt_help );
781
 
782
    #
273 dpurdie 783
    #   Determine Sandbox information
784
    #   Populate global variables
785
    #
786
    calc_sandbox_info();
787
 
788
    my @cmd = $mode eq 'clobber' ? ('clobber') : ('make', 'clean' );
789
 
790
    #
791
    #   Clobber and clean need to be done in the reverse order
792
    #
793
    foreach my $fe ( reverse @build_order )
794
    {
795
        my $dir = $fe->{dir};
359 dpurdie 796
        Message( "Level:" . $fe->{level} . " Name: " . $fe->{dname} ,
273 dpurdie 797
                  DisplayPath ("        Path: $fe->{dir}" ));
798
 
1328 dpurdie 799
        my $result = JatsCmd( "-cd=$dir", @cmd, @cmd_opts);
273 dpurdie 800
        Error ("Cmd failure") if ( $result );
801
    }
802
 
803
    exit 0;
804
}
805
 
806
 
807
#-------------------------------------------------------------------------------
337 dpurdie 808
# Function        : cache
809
#
810
# Description     : Cache external packages into the sandbox
811
#
812
# Inputs          : @opts                   - User options
813
#
814
# Returns         : Nothing
815
#
816
sub cache
817
{
1328 dpurdie 818
    my (@cmd_opts) = @_;
337 dpurdie 819
 
1328 dpurdie 820
    getOptionsFromArray ( \@cmd_opts ) || Error ("Invalid command line" );
821
    SubCommandHelp( $opt_help, "Cache") if ($opt_help || $#cmd_opts >= 0 );
359 dpurdie 822
 
337 dpurdie 823
    #
824
    #   Determine Sandbox information
825
    #   Populate global variables
826
    #
827
    Message("Cache External Dependencies");
828
    calc_sandbox_info();
829
 
830
    #
1273 dpurdie 831
    #   Walk the list of external dependencies and cache each one
337 dpurdie 832
    #
833
    foreach my $de ( sort keys %extern_deps )
834
    {
835
        my @vlist = keys %{$extern_deps{$de}};
359 dpurdie 836
        foreach my $pve ( @vlist )
337 dpurdie 837
        {
359 dpurdie 838
            my ($pn,$pv) = split( $; , $pve );
839
            Message ("Cache ${pn} ${pv}");
840
            JatsTool ('cache_dpkg', "${pn}/${pv}" );
337 dpurdie 841
        }
842
    }
361 dpurdie 843
 
337 dpurdie 844
    exit 0;
361 dpurdie 845
 
337 dpurdie 846
}
847
 
359 dpurdie 848
#-------------------------------------------------------------------------------
849
# Function        : populate
850
#
851
# Description     : Populate the sandbox with package versions
852
#
853
#
854
# Inputs          : commands            - Array of command line arguments
855
#                   Mode-0:
856
#
857
#                       pkg_name pkg_version        - Import files for named package
858
#                       options:
859
#                           -recurse                - Import dependent packages too
860
#                           -missing                - Import dependencies not in dpkg_archive
861
#                           -test                   - Show what would be done
862
#                           -extractfiles           - Extract file, no view
863
#
864
#
865
#
866
#
867
# Returns         : Does not return
868
#
869
use JatsRmApi;
870
use DBI;
337 dpurdie 871
 
359 dpurdie 872
#
873
#   Data Base Interface
874
#
875
my $RM_DB;
876
my $PopLevel = 0;
877
my %PopPackage;
878
my @StrayPackages;
879
my @PopBase;
880
 
881
sub populate
882
{
1328 dpurdie 883
    my (@cmd_opts ) = @_;
359 dpurdie 884
    my $opt_missing = 0;
885
    my $opt_recurse = 0;
886
    my $opt_test = 0;
1328 dpurdie 887
    my $opt_show = 0;
359 dpurdie 888
    my $opt_extractfiles;
889
    my @opt_extract = qw(-extract);
890
    my @opt_fnames;
1328 dpurdie 891
    my @opt_exclude;
892
    my $opt_all;
359 dpurdie 893
 
1328 dpurdie 894
 
359 dpurdie 895
    Getopt::Long::Configure('pass_through');
1328 dpurdie 896
    getOptionsFromArray ( \@cmd_opts,
897
                "all"               => \$opt_all,
898
                "missing"           => \$opt_missing,
899
                "test"              => \$opt_test,
900
                "show"              => \$opt_show,
901
                "recurse:100"       => \$opt_recurse,
902
                'excludePackage:s'  => sub{ opts_add2List( \@opt_exclude, @_ )},
359 dpurdie 903
                ) || Error ("Invalid command line" );
904
 
905
    SubCommandHelp( $opt_help, "Populate Sandbox") if ($opt_help );
906
 
907
    #
1328 dpurdie 908
    #   Sanity tests
909
    #
910
    Error ("Populate: -missing and -all options are mutually exclusive")
911
        if ( $opt_missing && $opt_all );
912
 
913
    #
359 dpurdie 914
    #   Extract options for the jats extract utility
915
    #
1328 dpurdie 916
    foreach ( @cmd_opts )
359 dpurdie 917
    {
918
        if ( m~^-~ ) {
919
            push ( @opt_extract, $_);
920
        } else {
921
            push ( @opt_fnames, $_);
922
        }
923
    }
924
 
925
    #
926
    #   Allow exactly zero or two 'bare' arguments
927
    #   Create an array of package-versions to be processed.
928
    #
929
    if ( $#opt_fnames >= 0 )
930
    {
365 dpurdie 931
        Error ("Populate: Must specify both a package name and version")
359 dpurdie 932
            if ( $#opt_fnames != 1 );
933
        push @PopBase, join( $;, @opt_fnames );
934
    }
1328 dpurdie 935
    elsif ( $opt_missing || $opt_all )
359 dpurdie 936
    {
937
        #
938
        #   User has not provided a package name to extract
1328 dpurdie 939
        #   Assume that the user will want all or missing dependencies
359 dpurdie 940
        #
941
        #   Determine packages that are not present
942
        #
943
        calc_sandbox_info();
944
 
945
        #
946
        # Scan for missing dependencies
947
        #
948
        foreach my $de ( sort keys %extern_deps )
949
        {
950
            my @vlist = keys %{$extern_deps{$de}};
951
            foreach my $pve ( @vlist )
952
            {
953
                my ($pn,$pv) = split( $; , $pve );
1328 dpurdie 954
                unless ($opt_missing && check_package_existance( $pn, $pv ))
359 dpurdie 955
                {
956
                    push @PopBase, join( $;, $pn , $pv );
957
                }
958
            }
959
        }
960
    }
961
    else
962
    {
963
        Error ("No command or option specified. See help for command usage");
964
    }
965
 
966
    #
967
    #   Process the list of package-versions
968
    #   These are top level packages. Get details from Release Manager
969
    #
970
    #DebugDumpData("Data", \@PopBase );
971
    $PopLevel = 0;
972
    foreach my $entry ( @PopBase )
973
    {
974
        my ($pname, $pver ) = split( $; , $entry);
975
 
976
        my $pv_id = getPkgDetailsByName($pname, $pver);
977
        Error ("populate: $pname, $pver not found in Release Manager" )
978
            unless ( $pv_id );
979
        getPkgDetailsByPV_ID($pv_id);
980
    }
981
    #
982
    #   If recursing then process packages that have yet to
983
    #   be processed. At the start there will be the initial user specified
984
    #   packages on the list. Place a marker at the end so that we can
985
    #   determine how far we are recursing down the dependency tree.
986
    #
1328 dpurdie 987
    $opt_recurse = ($opt_all ? 100 : $opt_recurse);
359 dpurdie 988
    if ( $opt_recurse )
989
    {
990
        my $marker = join($; , '_NEXT_LEVEL_', 0, 0 );
991
        push @StrayPackages, $marker;
992
        $PopLevel++;
993
 
994
        while ( $#StrayPackages >= 0 )
995
        {
996
            my ($name, $ver, $pv_id) = split($;, shift @StrayPackages);
997
 
998
            #
999
            #   Marker.
1000
            #   Increment the level of recursion
1001
            #   Detect end conditions
1002
            #
1003
            if ( $name eq '_NEXT_LEVEL_' )
1004
            {
1005
                last unless ($#StrayPackages >= 0 );
1006
                $PopLevel++;
1007
                last if ( $PopLevel > $opt_recurse );
1008
                push @StrayPackages, $marker;
1009
                next;
1010
            }
1011
 
1012
            next if ( exists $PopPackage{$name}{$ver}{done} );
1013
            getPkgDetailsByPV_ID ( $pv_id );
1014
            #print "Stray: $pv_id, $name, $ver\n";
1015
        }
1016
    }
1017
    #DebugDumpData("Data", \%PopPackage );
1018
 
1019
    #
1020
    #   Determine packages that need to be extracted
1328 dpurdie 1021
    #   Sort alphabetically - case insensitive
359 dpurdie 1022
    #
1328 dpurdie 1023
    foreach my $pname ( sort {lc($a) cmp lc($b)} keys %PopPackage )
359 dpurdie 1024
    {
1328 dpurdie 1025
        pkgscan:
359 dpurdie 1026
        foreach my $pver ( sort keys %{$PopPackage{$pname}} )
1027
        {
1028
            #
1029
            #   Create a nice view name for the extraction
365 dpurdie 1030
            #   Will also be used to test for package existence
359 dpurdie 1031
            #
1032
            my $vname = "$pname $pver";
1033
            $vname =~ s~ ~_~g;
1034
            $vname =~ s~__~~g;
1035
 
1036
            if ( -d "$GBE_SANDBOX/$vname" )
1037
            {
1038
                Warning("Package already in sandbox: $pname, $pver");
1039
                next;
1040
            }
1041
 
1042
            #
1043
            #   If scanning for missing packages, then examine archives
1044
            #   for the packages existence. Don't do this on level-0 packages
1045
            #   These have been user specified.
1046
            #
1047
            if ( $opt_missing && $PopPackage{$pname}{$pver}{level}  )
1048
            {
1049
                my $found = check_package_existance( $pname, $pver );
1050
                if ( $found )
1051
                {
1052
                    Verbose ("Package found in archive - skipped: $pname, $pver");
1053
                    next;
1054
                }
1055
            }
1056
 
1057
            #
1328 dpurdie 1058
            #   Has the user specifically excluded this package
1059
            #   Allow three forms
1060
            #       packageName
1061
            #       packageName_Version
1062
            #       packageName.projectName
1063
            #
1064
            my $excluded;
1065
            foreach my $ename ( @opt_exclude )
1066
            {
1067
                if ( $ename eq $pname ) {
1068
                    $excluded = 1;
1069
                } elsif ($ename eq $pname .'_' . $pver ) {
1070
                    $excluded = 1;
1071
                } else {
1072
                    if ( $pver =~ m~(\.[a-z]{2,4})$~ )
1073
                    {
1074
                        $excluded = ($ename eq $pname . $1 );
1075
                    }
1076
                }
1077
 
1078
                if ( $excluded )
1079
                {
1080
                    Message ("Package excluded by user - skipped: $pname, $pver");
1081
                    next pkgscan;
1082
                }
1083
            }
1084
 
1085
            #
359 dpurdie 1086
            #   Generate commands to extract the package
1087
            #
1088
            my $vcstag = $PopPackage{$pname}{$pver}{vcstag};
1089
            my @cmd = qw(jats_vcsrelease);
1090
            push @cmd, "-view=$vname", "-label=$vcstag", @opt_extract;
1328 dpurdie 1091
            if ( $opt_show )
359 dpurdie 1092
            {
1328 dpurdie 1093
                Message ("$pname $pver");
1094
            }
1095
            elsif ( $opt_test )
1096
            {
359 dpurdie 1097
                Message "jats " . QuoteCommand (@cmd );
1098
            }
1099
            else
1100
            {
1101
                Message "Extracting: $pname $pver";
1102
                my $rv = JatsCmd (@cmd);
1103
                Error ("Package version not extracted")
1104
                    if ( $rv );
1105
            }
1106
        }
1107
    }
1108
 
1109
    #
1110
    # This command does not return
1111
    #
1112
    exit (0);
1113
}
1114
 
337 dpurdie 1115
#-------------------------------------------------------------------------------
359 dpurdie 1116
# Function        : getPkgDetailsByName
1117
#
1118
# Description     : Determine the PVID for a given package name and version
1119
#
1120
# Inputs          : $pname          - Package name
1121
#                   $pver           - Package Version
1122
#
361 dpurdie 1123
# Returns         :
359 dpurdie 1124
#
1125
 
1126
sub getPkgDetailsByName
1127
{
1128
    my ($pname, $pver) = @_;
1129
    my $pv_id;
1130
    my (@row);
1131
 
1132
    connectRM(\$RM_DB) unless ($RM_DB);
1133
 
1134
    # First get details for a given package version
1135
 
1136
    my $m_sqlstr = "SELECT pv.PV_ID, pkg.PKG_NAME, pv.PKG_VERSION" .
1137
                    " FROM RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGES pkg" .
1138
                    " WHERE pkg.PKG_NAME = \'$pname\' AND pv.PKG_VERSION = \'$pver\' AND pv.PKG_ID = pkg.PKG_ID";
1139
    my $sth = $RM_DB->prepare($m_sqlstr);
1140
    if ( defined($sth) )
1141
    {
1142
        if ( $sth->execute( ) )
1143
        {
1144
            if ( $sth->rows )
1145
            {
1146
                while ( @row = $sth->fetchrow_array )
1147
                {
1148
                    $pv_id = $row[0];
1149
                    my $name = $row[1];
1150
                    my $ver = $row[2];
1151
                    Verbose( "getPkgDetailsByName :PV_ID= $pv_id");
1152
                }
1153
            }
1154
            $sth->finish();
1155
        }
1156
    }
1157
    else
1158
    {
1159
        Error("Prepare failure" );
1160
    }
1161
    return $pv_id;
1162
}
1163
 
1164
#-------------------------------------------------------------------------------
1165
# Function        : getPkgDetailsByPV_ID
1166
#
1167
# Description     : Populate the Packages structure given a PV_ID
1168
#                   Called for each package in the SBOM
1169
#
1170
# Inputs          : PV_ID           - Package Unique Identifier
1171
#
1172
# Returns         : Populates Package
1173
#
1174
sub getPkgDetailsByPV_ID
1175
{
1176
    my ($PV_ID) = @_;
1177
    my $foundDetails = 0;
1178
    my (@row);
1179
 
1180
    connectRM(\$RM_DB) unless ($RM_DB);
1181
 
1182
    # First get details from pv_id
1183
 
1184
    my $m_sqlstr = "SELECT pv.PV_ID, pkg.PKG_NAME, pv.PKG_VERSION, release_manager.PK_RMAPI.return_vcs_tag($PV_ID)" .
1185
                    " FROM RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGES pkg " .
1186
                    " WHERE pv.PV_ID = \'$PV_ID\' AND pv.PKG_ID = pkg.PKG_ID";
1187
 
1188
    my $sth = $RM_DB->prepare($m_sqlstr);
1189
    if ( defined($sth) )
1190
    {
1191
        if ( $sth->execute( ) )
1192
        {
1193
            if ( $sth->rows )
1194
            {
1195
                while ( @row = $sth->fetchrow_array )
1196
                {
1197
                    my $pv_id       = $row[0];
1198
                    my $name        = $row[1];
1199
                    my $ver         = $row[2];
1200
                    my $vcstag      = $row[3] || '';
1201
 
1202
                    $vcstag =~ tr~\\/~/~;
1203
                    Verbose ("getPkgDetailsByPV_ID: $PV_ID, $name, $ver, $vcstag");
1204
 
1205
                    $PopPackage{$name}{$ver}{pvid} = $PV_ID;
1206
                    $PopPackage{$name}{$ver}{done} = 1;
1207
                    $PopPackage{$name}{$ver}{vcstag} = $vcstag;
1208
                    $PopPackage{$name}{$ver}{level} = $PopLevel;
1209
                    getDependsByPV_ID( $pv_id, $name, $ver );
1210
                }
1211
            }
1212
            else
1213
            {
1214
                Warning ("No Package details for: PVID: $PV_ID");
1215
            }
1216
            $sth->finish();
1217
        }
1218
        else
1219
        {
1220
            Error("getPkgDetailsByPV_ID: Execute failure", $m_sqlstr );
1221
        }
1222
    }
1223
    else
1224
    {
1225
        Error("Prepare failure" );
1226
    }
1227
}
1228
 
1229
#-------------------------------------------------------------------------------
1230
# Function        : getDependsByPV_ID
1231
#
1232
# Description     : Extract the dependancies for a given package version
1233
#
1234
# Inputs          : $pvid
1235
#
1236
# Returns         :
1237
#
1238
sub getDependsByPV_ID
1239
{
1240
    my ($pv_id, $pname, $pver) = @_;
1241
 
1242
    connectRM(\$RM_DB) unless ($RM_DB);
1243
 
1244
    #
365 dpurdie 1245
    #   Now extract the package dependencies
359 dpurdie 1246
    #
1247
    my $m_sqlstr = "SELECT pkg.PKG_NAME, pv.PKG_VERSION, pd.DPV_ID" .
1248
                   " FROM RELEASE_MANAGER.PACKAGE_DEPENDENCIES pd, RELEASE_MANAGER.PACKAGE_VERSIONS pv, RELEASE_MANAGER.PACKAGES pkg" .
1249
                   " WHERE pd.PV_ID = \'$pv_id\' AND pd.DPV_ID = pv.PV_ID AND pv.PKG_ID = pkg.PKG_ID";
1250
    my $sth = $RM_DB->prepare($m_sqlstr);
1251
    if ( defined($sth) )
1252
    {
1253
        if ( $sth->execute( ) )
1254
        {
1255
            if ( $sth->rows )
1256
            {
1257
                while ( my @row = $sth->fetchrow_array )
1258
                {
1259
                    my $name = $row[0];
1260
                    my $ver = $row[1];
1261
 
1262
                    Verbose2( "       Depends: $name, $ver");
1263
                    unless ( exists $PopPackage{$name} && exists $PopPackage{$name}{$ver} && exists $PopPackage{$name}{$ver}{done} )
1264
                    {
1265
                        push @StrayPackages, join($;, $name, $ver, $row[2] );
1266
                    }
1267
                }
1268
            }
1269
            $sth->finish();
1270
        }
1271
    }
1272
    else
1273
    {
1274
        Error("GetDepends:Prepare failure" );
1275
    }
1276
}
1277
 
1278
#-------------------------------------------------------------------------------
1273 dpurdie 1279
# Function        : getOptionsFromArray
1280
#
1281
# Description     : Like getOptions, but handles an array
1282
#                   Provided as the version of Perl used does not have one
1283
#
1284
# Inputs          : pArray                  - Ref to array
1285
#                   ....                    - GetOptions arguments
1286
#
1287
# Returns         : 
1288
#
1289
sub getOptionsFromArray
1290
{
1291
    my ($pArray, %args) = @_;
1292
 
1328 dpurdie 1293
    #
1294
    #   Common arguments
1295
    #
1296
    my %commonOptions = (
1297
        'help|h:+'          => \$opt_help,
1298
        'manual:3'          => \$opt_help,
1299
        'verbose:+'         => \$opt_verbose,
1300
        'topackage:s'       => \$opt_toPackage,
1301
        'frompackage:s'     => \$opt_fromPackage,
1302
        'justpackage:s'     => sub{ opts_add2List( \@opt_justPackage, @_ )},
1303
        'ignorepackage:s'   => sub{ opts_add2List( \@opt_ignorePackage, @_ )},
1304
        );
1305
 
1306
    #
1307
    #   Merge in the user options
1308
    #
1309
    @commonOptions{keys %args} = values %args;
1310
 
1273 dpurdie 1311
    local ( @ARGV );
1312
    @ARGV = @$pArray;
1328 dpurdie 1313
    my $rv = GetOptions ( %commonOptions );
1273 dpurdie 1314
    @$pArray = @ARGV;
1315
 
1328 dpurdie 1316
    ErrorConfig('verbose' => $opt_verbose );
1273 dpurdie 1317
    return $rv;
1318
}
1319
 
1328 dpurdie 1320
#-------------------------------------------------------------------------------
1321
# Function        : opts_add2List
1322
#
1323
# Description     : Option processing helper
1324
#                   Add comma separated options to an array
1325
#                   User can then add items one at a time, or several at once
1326
#
1327
# Inputs          : aref        - Ref to an array to extent
1328
#                   arg2        - Option name
1329
#                   arg3        - Option value
1330
#
1331
# Returns         : 
1332
#
1333
sub opts_add2List
1334
{
1335
    my( $ref, $name, $value) = @_;
1336
    if ( $value )
1337
    {
1338
        foreach ( split(/\s*,\s*/,$value) )
1339
        {
1340
            push @{$ref}, $_;
1341
        }
1342
    }
1343
}
1273 dpurdie 1344
 
1345
#-------------------------------------------------------------------------------
359 dpurdie 1346
# Function        : SubCommandHelp
1347
#
1348
# Description     : Provide help on a subcommand
1349
#
1350
# Inputs          : $help_level             - Help Level 1,2,3
1351
#                   $topic                  - Topic Name
1352
#
1353
# Returns         : This function does not return
1354
#
1355
sub SubCommandHelp
1356
{
1357
    my ($help_level, $topic) = @_;
1358
    my @sections;
1359
    #
1360
    #   Spell out the section we want to display
1361
    #
1362
    #   Note:
1363
    #   Due to bug in pod2usage can't use 'head1' by itself
1364
    #   Each one needs a subsection.
1365
    #
1366
    push @sections, qw( NAME SYNOPSIS ) ;
1367
    push @sections, qw( ARGUMENTS OPTIONS )     if ( $help_level > 1 );
1368
    push @sections, qw( DESCRIPTION EXAMPLES )  if ( $help_level > 2 );
1369
 
1370
    #
1371
    #   Extract section from the POD
1372
    #
1373
    pod2usage({-verbose => 99,
1374
               -noperldoc => 1,
1375
               -sections => $topic . '/' . join('|', @sections) } );
1376
}
1377
 
1378
#-------------------------------------------------------------------------------
227 dpurdie 1379
#   Documentation
359 dpurdie 1380
#   NOTE
227 dpurdie 1381
#
359 dpurdie 1382
#   Each subcommand MUST have
1383
#   head1 section as used by the subcommand
1384
#       This should be empty, as the contents will NOT be displayed
1385
#   head2 sections called
1386
#       NAME SYNOPSIS ARGUMENTS OPTIONS DESCRIPTION EXAMPLES
1387
#
1388
#=head1 xxxxxx
1389
#=head2 NAME
1390
#=head2 SYNOPSIS
1391
#=head2 ARGUMENTS
1392
#=head2 OPTIONS
1393
#=head2 DESCRIPTION
1394
#=head2 EXAMPLES
1395
#
227 dpurdie 1396
 
1397
=pod
1398
 
1399
=head1 NAME
1400
 
1401
jats_sandbox - Build in a Development Sandbox
1402
 
1403
=head1 SYNOPSIS
1404
 
361 dpurdie 1405
  jats sandbox [options] command [command options]
227 dpurdie 1406
 
1407
 Options:
1328 dpurdie 1408
    -help[=n]                  - Display help with specified detail
1409
    -help -help                - Detailed help message
1410
    -man                       - Full documentation
227 dpurdie 1411
 
1328 dpurdie 1412
 Options for recursion control:
1413
    -toPackage=name            - Stop building after package
1273 dpurdie 1414
    -fromPackage=name          - Start building from package
1415
    -justPackage=name[,name]   - Build named packages
1416
    -ignorePackage=name[,name] - Do not build named packages
1417
 
227 dpurdie 1418
 Commands:
1419
    help                - Same as -help
1420
    create              - Create a sandbox in the current directory
359 dpurdie 1421
    populate            - Populate the sandbox with packages
299 dpurdie 1422
    delete              - Delete the sandbox
255 dpurdie 1423
    info [[-v]-v]       - Sandbox information. -v: Be more verbose
227 dpurdie 1424
    cmd                 - Do commands in all sandbox components
1328 dpurdie 1425
    all                 - Do 'build', if required, then a make in all components
331 dpurdie 1426
    build               - Force 'build and make' in all sandbox components
275 dpurdie 1427
    make                - Do 'make' in all sandbox components
273 dpurdie 1428
    clean               - Do 'make clean' in all sandbox components
1429
    clobber             - Do 'build clobber' is all sandbox components
337 dpurdie 1430
    cache               - Cache external dependent packages
227 dpurdie 1431
 
359 dpurdie 1432
 Use the command
1433
    jats sandbox 'command' -h
1434
 for command specific help
361 dpurdie 1435
 
227 dpurdie 1436
=head1 OPTIONS
1437
 
1438
=over 8
1439
 
299 dpurdie 1440
=item B<-help[=n]>
227 dpurdie 1441
 
1442
Print a brief help message and exits.
299 dpurdie 1443
There are three levels of help
227 dpurdie 1444
 
299 dpurdie 1445
=over 8
1446
 
361 dpurdie 1447
=item   1
299 dpurdie 1448
 
361 dpurdie 1449
Brief synopsis
299 dpurdie 1450
 
361 dpurdie 1451
=item   2
299 dpurdie 1452
 
361 dpurdie 1453
Synopsis and option summary
1454
 
1455
=item   3
1456
 
1457
Detailed help in man format
1458
 
299 dpurdie 1459
=back 8
1460
 
227 dpurdie 1461
=item B<-help -help>
1462
 
1463
Print a detailed help message with an explanation for each option.
1464
 
1465
=item B<-man>
1466
 
299 dpurdie 1467
Prints the manual page and exits. This is the same a -help=3
227 dpurdie 1468
 
1328 dpurdie 1469
=item B<-toPackage=name>
1273 dpurdie 1470
 
1471
This option is available in all commands that process multiple packages.
1328 dpurdie 1472
Package processing will stop at the named package.
1273 dpurdie 1473
 
1474
The default operation is to process all packages.
1475
 
1328 dpurdie 1476
=item B<-fromPackage=name>
1273 dpurdie 1477
 
1478
This option is available in all commands that process multiple packages.
1328 dpurdie 1479
Package processing will start at the named package.
1273 dpurdie 1480
 
1328 dpurdie 1481
The default operation is to process no packages.
1273 dpurdie 1482
 
1328 dpurdie 1483
=item B<-justPackage=name[,name]>
1273 dpurdie 1484
 
1485
This option is available in all commands that process multiple packages. The
1328 dpurdie 1486
named packages will be processed in the correct build order. Packages that are
1487
not named will be skipped, unless the package is being processed due to
1488
being in the 'fromPackage' to 'toPackage' range.
1273 dpurdie 1489
 
1490
Multiple packages can be named either by separating names with a comma, or
1491
with multiple options.
1492
 
1328 dpurdie 1493
=item B<-ignorePackage=name[,name]>
1273 dpurdie 1494
 
1495
This option is available in all commands that process multiple packages. The
1496
named packages will not be processed.
1497
 
1498
Multiple packages can be named either by separating names with a comma, or
1499
with multiple options.
1500
 
1501
The exclusion of a package takes precedence over its inclusion.
1502
 
279 dpurdie 1503
=back
1504
 
227 dpurdie 1505
=head1 DESCRIPTION
1506
 
299 dpurdie 1507
This program is the primary tool for the maintenance of Development Sandboxes.
1508
 
227 dpurdie 1509
More documentation will follow.
1510
 
279 dpurdie 1511
=head2 SANDBOX DIRECTORY
1512
 
299 dpurdie 1513
The sandbox directory is marked as being a sandbox through the use of the
1514
'sandbox create' command. This will create a suitable structure within the
279 dpurdie 1515
current directory.
1516
 
1517
Several JATS commands operate differently within a sandbox. The 'extract' and
365 dpurdie 1518
'release' commands will create static views within the sandbox and not the
279 dpurdie 1519
normal directory. The 'sandbox' sub commands can only be used within a sandbox.
1520
 
1521
The sandbox directory contains sub directories, each should contain a single
359 dpurdie 1522
package. Sub directories may be created with the 'jats extract' command or with the
1523
'jats sandbox populate' command.
279 dpurdie 1524
 
1525
Note: Symbolic links are not supported. They cannot work as he sandbox mechanism
365 dpurdie 1526
requires that all the packages be contained within a sub directory tree so
279 dpurdie 1527
that the root of the sandbox can be located by a simple scan of the directory
1528
tree.
1529
 
325 dpurdie 1530
If a package subdirectory contains a file called 'stop' or 'stop.
1531
<GBE_MACHTYPE>', then that package will not be considered as a part of the
1532
build-set. A 'stop' file will prevent consideration all build platforms. The 'stop.
1533
<GBE_MACHTYPE>' will only prevent consideration if being built on a GBE_MACHTYPE
1534
type of computer.
279 dpurdie 1535
 
3527 dpurdie 1536
If the sandbox contains a file called 'buildfilter', then the contents of the
1537
file will be read and used a buildfilter. The file is processed by reading each
1538
line and:
1539
 
1540
=over 4
1541
 
1542
=item * Removing white space at both ends of the line
1543
 
1544
=item * Removing empty lines
1545
 
1546
=item * Lines that start with a # are comments and are removed
1547
 
1548
=item * Remaining lines are joined together to form a buildfilter
1549
 
1550
=back
1551
 
359 dpurdie 1552
=head1 Create Sandbox
299 dpurdie 1553
 
359 dpurdie 1554
=head2 NAME
299 dpurdie 1555
 
359 dpurdie 1556
Create Sandbox
1557
 
1558
=head2 SYNOPSIS
1559
 
1328 dpurdie 1560
jats sandbox create [command options]
359 dpurdie 1561
 
1562
 Command Options
1563
    -help[=n]               - Command specific help, [n=1,2,3]
1564
    -verbose[=n]            - Verbose operation
1565
    -exact                  - Create sandbox to reproduce exact versions
1566
 
1567
=head2 OPTIONS
1568
 
1569
The 'create' command takes the following options:
1570
 
1571
=over 8
1572
 
1573
=item -exact
1574
 
1575
When this option is specified the sandbox is marked for exact processing of
1576
package versions. In this mode the version numbers of the packages in the
1577
sandbox are significant. This is ideal for recreating a package-version.
1578
 
1579
The default is for in-exact processing, in which the version numbers of packages
1580
within the sandbox are not significant. The is ideal for development.
1581
 
1582
=back
1583
 
1584
=head2 DESCRIPTION
1585
 
299 dpurdie 1586
The 'create' command will create a sandbox in the users current directory. It is
1587
not possible to create a sandbox within a sandbox.
1588
 
1589
A sandbox can be created in a directory that contains files and subdirectories.
1590
 
1591
The create command simply places a known directory in the current directory.
359 dpurdie 1592
This directory is used by the sandboxing process. It may be manually deleted, or
299 dpurdie 1593
deleted with the 'delete' command.
1594
 
359 dpurdie 1595
=head1 Populate Sandbox
1596
 
1597
=head2 NAME
1598
 
1599
Populate a Sandbox
1600
 
1601
=head2 SYNOPSIS
1602
 
1328 dpurdie 1603
jats sandbox populate [command options] [packageName packageVersion]
359 dpurdie 1604
 
1605
 Command Options
1328 dpurdie 1606
    -help[=n]                  - Command specific help, [n=1,2,3]
1607
    -toPackage=name            - Stop building after package
1608
    -fromPackage=name          - Start building from package
1609
    -justPackage=name[,name]   - Build named packages
1610
    -ignorePackage=name[,name] - Do not build named packages
1611
    -excludePackage=name[,name]- Do not extract named package
1612
    -recurse[=n]               - Locate dependencies within packages
1613
    -all                       - Populate with all dependencies
1614
    -missing                   - Locate missing packages
1615
    -show                      - Show packages that would be extracted
1616
    -test                      - Do not extract packages
1617
    -<Other>                   - Pass options to jats extract
359 dpurdie 1618
 
1619
=head2 ARGUMENTS
1620
 
1621
The 'populate' command can take a package name and version as arguments. It will
1622
then populate the sandbox with this package. See 'DESCRIPTION' for details.
1623
 
1624
=head2 OPTIONS
1625
 
1626
The 'populate' command takes the following options:
1627
 
1628
=over 4
1629
 
1328 dpurdie 1630
=item -excludePackage=name[,name]
1631
 
1632
This option prevents one, or more, packages from populating the sandbox.
1633
Packages specified with this option will not be extracted from version control
1634
and added to the sandbox.
1635
 
1636
Packages can be itentified in three ways:
1637
 
1638
=over 4
1639
 
1640
=item 1. Package Name
1641
 
1642
All package versions matching the named package will be excluded.
1643
 
1644
=item 2. Package Name and Version
1645
 
1646
Only the specified version of the named package will be excluded. The
1647
user specifies the package name and version as a single string separated with
1648
an underscore. ie: core_devl_2.100.5000.cr
1649
 
1650
=item 3. Package Name and Suffix
1651
 
1652
All packages matching the named package and project will be excluded. The
1653
user specifies the package name and project as a single string separated with
1654
a dot. ie: core_devl.cr
1655
 
1656
 
1657
=back
1658
 
359 dpurdie 1659
=item -recurse[=N]
1660
 
1661
This option will modify the operation of the command such that dependencies
1662
of named packages can also be extracted into the sandbox.
1663
 
1664
The default operation is to only extract named packages. If the option is
1665
specified then all dependent packages are processed. An optional numeric argument
1666
can be specified to limit the depth of the recursion.
1667
 
1328 dpurdie 1668
=item -all
1669
 
1670
This option will populate the sandbox will all dependencies of packages that are
1671
currently in the sandbox.
1672
 
1673
The global options that control recursion will affect the packages that are
1674
processed.
1675
 
1676
This option cannot be used with the '-missing' option.
1677
 
359 dpurdie 1678
=item -missing
1679
 
1680
This option will modify the operation of the dependency recursion scanning such
1681
that dependent packages that exist in a package archive will not be extracted.
1682
 
1683
Use of this option allows a sandbox to be populated with packages that are
1684
required by packages in the sandbox, but are not available in a package archive.
1685
 
1328 dpurdie 1686
The global options that control recursion will affect the packages that are
1687
processed.
1688
 
1689
This option cannot be used with the '-all' option.
1690
 
1691
=item -show
1692
 
1693
This option will prevent the command from performing the extraction. It will
1694
simply display the names of the packages that would be extracted.
1695
 
359 dpurdie 1696
=item -test
1697
 
1698
This option will prevent the command from performing the extraction. It will
1699
simply display the JATS commands that can be used to perform the extraction.
1700
 
1701
=item -<Other>
1702
 
1703
Options not understood by the 'populate' sub command will be passed through
1704
the package extraction program. Useful options include:
1705
 
363 dpurdie 1706
=over 4
359 dpurdie 1707
 
361 dpurdie 1708
=item *
359 dpurdie 1709
 
361 dpurdie 1710
-extractfiles
359 dpurdie 1711
 
361 dpurdie 1712
=item *
1713
 
1714
-branch=<branch name>
1715
 
359 dpurdie 1716
=back
1717
 
1718
=back
1719
 
1720
=head2 DESCRIPTION
1721
 
1722
The 'populate' command can be used to assist in populating the sandbox. It has
1723
two modes of operation.
1724
 
363 dpurdie 1725
=over 4
359 dpurdie 1726
 
361 dpurdie 1727
=item 1
359 dpurdie 1728
 
361 dpurdie 1729
Named Package
1730
 
363 dpurdie 1731
If the user specifies both a package name and a package version then the command
359 dpurdie 1732
will populate the sandbox with that package and optionally its dependencies.
1733
 
361 dpurdie 1734
=item 2
359 dpurdie 1735
 
361 dpurdie 1736
Determine missing dependencies
1737
 
359 dpurdie 1738
If the user does not specify a package name and version, but does specify
1739
the '-missing' option,  then the command will examine the current sandbox and
1740
determine missing dependent packages. It will then populate the sandbox with
1741
these packages and optionally there dependencies.
1742
 
1743
=back
1744
 
1745
=head2 EXAMPLES
1746
 
1747
=over 4
1748
 
361 dpurdie 1749
=item *
359 dpurdie 1750
 
361 dpurdie 1751
jats sandbox populate package1 version1
1752
 
359 dpurdie 1753
This command will populate the sandbox with version1 of package1, if it does not
1754
already exist in the sandbox.
1755
 
361 dpurdie 1756
=item *
359 dpurdie 1757
 
361 dpurdie 1758
jats sandbox populate package1 version1 -recurse -missing
1759
 
359 dpurdie 1760
This command will populate the sandbox with version1 of package1, if it does not
1761
already exist in the sandbox, together will all the packages dependencies that
1762
are not available in a package archive.
1763
 
361 dpurdie 1764
=item *
359 dpurdie 1765
 
361 dpurdie 1766
jats sandbox populate -recurse -missing
1767
 
359 dpurdie 1768
This command will examine the current sandbox and populate the sandbox with
1769
packages that are required to build the packages in the sandbox and the
1770
dependencies of these packages, provide the dependent package is not in a
1771
package archive.
1772
 
361 dpurdie 1773
=item *
359 dpurdie 1774
 
361 dpurdie 1775
jats sandbox populate
1776
 
359 dpurdie 1777
This command will examine the current sandbox and populate the sandbox with
1778
packages that are required to build the packages in the sandbox. It will not
1779
examine the dependents of these packages.
1780
 
1781
=back
1782
 
1783
=head1 Delete Sandbox
1784
 
1785
=head2 NAME
1786
 
365 dpurdie 1787
Delete a a sandbox
359 dpurdie 1788
 
1789
=head2 SYNOPSIS
1790
 
1791
jats sandbox [options] delete
1792
 
1793
 Options:
1794
    -help[=n]               - Help message, [n=1,2,3]
1795
    -man                    - Full documentation [-help=3]
1796
    -verbose[=n]            - Verbose command operation
1797
 
1798
=head2 DESCRIPTION
1799
 
299 dpurdie 1800
The 'delete' command will delete the sandbox's marker directory. The command may
1801
be executed anywhere within the sandbox.
1802
 
359 dpurdie 1803
Once the sandbox has been deleted, the user must remove the components within the
299 dpurdie 1804
sandbox.
1805
 
359 dpurdie 1806
=head1 Sandbox Information
299 dpurdie 1807
 
359 dpurdie 1808
=head2 NAME
1809
 
1810
Display Sandbox Information
1811
 
1812
=head2 SYNOPSIS
1813
 
1328 dpurdie 1814
jats sandbox info [command options]
359 dpurdie 1815
 
1816
 Command Options
1328 dpurdie 1817
    -help[=n]                  - Command specific help, [n=1,2,3]
1818
    -verbose[=n]               - Display more information
1819
    -toPackage=name            - Stop building after package
1820
    -fromPackage=name          - Start building from package
1821
    -justPackage=name[,name]   - Build named packages
1822
    -ignorePackage=name[,name] - Do not build named packages
361 dpurdie 1823
 
359 dpurdie 1824
=head2 OPTIONS
1825
 
1826
=over
1827
 
1828
=item B<-verbose[=n]>
1829
 
1830
This options will increase the verbosity of the information being displayed.
1831
Values 1 and 2 are described in the detailed 'DESCRIPTION'. Other values are
1832
reserved for diagnostic use.
1833
 
1834
=back
1835
 
1836
=head2 DESCRIPTION
1837
 
299 dpurdie 1838
The 'info' command will display information about the build order and the
359 dpurdie 1839
dependencies of packages that it finds within the sandbox.
299 dpurdie 1840
 
359 dpurdie 1841
The command works within various levels of verbosity:
299 dpurdie 1842
 
1843
=over 8
1844
 
361 dpurdie 1845
=item *
299 dpurdie 1846
 
361 dpurdie 1847
No Verbosity
1848
 
299 dpurdie 1849
The basic command will display the build order and the external
335 dpurdie 1850
dependencies. External dependencies may be prefixed with one of the
1851
following indicators:
299 dpurdie 1852
 
335 dpurdie 1853
=over 8
1854
 
361 dpurdie 1855
=item   '+' Multiple versions of this package are being used by sandboxed components.
335 dpurdie 1856
 
361 dpurdie 1857
=item   '*' The package cannot be found in any of the package archives.
335 dpurdie 1858
 
1859
=back
1860
 
361 dpurdie 1861
=item *
299 dpurdie 1862
 
361 dpurdie 1863
Verbosity of 1
1864
 
359 dpurdie 1865
This level of verbosity will display the build order and detailed information
299 dpurdie 1866
on the dependencies. The dependencies will be prefixed with:
1867
 
1868
=over 8
1869
 
361 dpurdie 1870
=item   E Dependent Package is external to the sandbox
299 dpurdie 1871
 
361 dpurdie 1872
=item   I Dependent Package is internal to the sandbox
299 dpurdie 1873
 
1874
=back
1875
 
335 dpurdie 1876
External dependencies may be prefixed with one of the indicators described for
1877
no-verbosity. Additionally the internal consumer of the external package is also
1878
shown. These are prefixed with a 'U'.
299 dpurdie 1879
 
361 dpurdie 1880
=item *
299 dpurdie 1881
 
361 dpurdie 1882
Verbosity of 2
1883
 
359 dpurdie 1884
Reserved for future use
299 dpurdie 1885
 
361 dpurdie 1886
=item *
299 dpurdie 1887
 
361 dpurdie 1888
Verbosity over 2
1889
 
359 dpurdie 1890
This should be considered a debug option. Undocumented internal information will
299 dpurdie 1891
be displayed.
1892
 
1893
=back
1894
 
359 dpurdie 1895
=head1 Command all
331 dpurdie 1896
 
359 dpurdie 1897
=head2 NAME
1898
 
1899
Build packages in the sandbox
1900
 
1901
=head2 SYNOPSIS
1902
 
1328 dpurdie 1903
jats sandbox all [command options] [arguments]
359 dpurdie 1904
 
1905
 Command Options
1328 dpurdie 1906
    -help[=n]                  - Command specific help, [n=1,2,3]
1907
    -toPackage=name            - Stop building after package
1908
    -fromPackage=name          - Start building from package
1909
    -justPackage=name[,name]   - Build named packages
1910
    -ignorePackage=name[,name] - Do not build named packages
359 dpurdie 1911
 
1912
=head2 ARGUMENTS
1913
 
1914
Arguments are passed to the 'make' phase of the process.
1915
 
1916
=head2 OPTIONS
1917
 
1918
The are command specific options.
1919
 
1920
=head2 DESCRIPTION
1921
 
331 dpurdie 1922
The 'all' command will perform build, if the build files are out of date,
1923
followed by a make in each of the packages within the sandbox, in the correct
1924
build order.
1925
 
1926
Any arguments are passed to the 'make' phase of the process.
1927
 
1928
This command may be used to:
1929
 
1930
=over 8
1931
 
361 dpurdie 1932
=item *
331 dpurdie 1933
 
361 dpurdie 1934
Pickup any build file changes.
331 dpurdie 1935
 
361 dpurdie 1936
=item *
1937
 
1938
Resume a failed build.
1939
 
331 dpurdie 1940
=back
1941
 
359 dpurdie 1942
=head1 Command build
331 dpurdie 1943
 
359 dpurdie 1944
=head2 NAME
1945
 
1946
Build packages in the sandbox
1947
 
1948
=head2 SYNOPSIS
1949
 
1328 dpurdie 1950
jats sandbox build [command options] [arguments]
359 dpurdie 1951
 
1952
 Command Options
1328 dpurdie 1953
    -help[=n]                  - Command specific help, [n=1,2,3]
1954
    -toPackage=name            - Stop building after package
1955
    -fromPackage=name          - Start building from package
1956
    -justPackage=name[,name]   - Build named packages
1957
    -ignorePackage=name[,name] - Do not build named packages
359 dpurdie 1958
 
1959
=head2 ARGUMENTS
1960
 
1961
Arguments are passed to the 'make' phase of the process.
1962
 
1963
=head2 OPTIONS
1964
 
1965
The are no command specific options.
1966
 
1967
=head2 DESCRIPTION
1968
 
331 dpurdie 1969
The 'build' command will force a build followed by a make in each of the packages
1970
within the sandbox, in the correct build order.
1971
 
1972
Any arguments are passed to the 'make' phase of the process.
1973
 
1974
In practice, the 'sandbox all' command is quicker.
1975
 
359 dpurdie 1976
=head1 Clean
331 dpurdie 1977
 
359 dpurdie 1978
=head2 NAME
1979
 
1980
Clean all sandbox components
1981
 
1982
=head2 SYNOPSIS
1983
 
1328 dpurdie 1984
jats sandbox clean|clobber [command options]
359 dpurdie 1985
 
1986
 Command Options
1328 dpurdie 1987
    -help[=n]                  - Command specific help, [n=1,2,3]
1988
    -toPackage=name            - Stop building after package
1989
    -fromPackage=name          - Start building from package
1990
    -justPackage=name[,name]   - Build named packages
1991
    -ignorePackage=name[,name] - Do not build named packages
359 dpurdie 1992
 
1993
=head2 ARGUMENTS
1994
 
1995
None
1996
 
1997
=head2 OPTIONS
1998
 
1999
No command specific options
2000
 
2001
=head2 DESCRIPTION
2002
 
2003
The 'clean' command will perform a 'jats make clean' in all components in the
2004
sandbox.
2005
 
2006
The 'clobber' command will perform a 'jats clobber' in all components in the
2007
sandbox.
2008
 
2009
=head1 make
2010
 
2011
=head2 NAME
2012
 
2013
Make packages in the sandbox
2014
 
2015
=head2 SYNOPSIS
2016
 
1328 dpurdie 2017
jats sandbox make [command options] [arguments]
359 dpurdie 2018
 
2019
 Command Options
1328 dpurdie 2020
    -help[=n]                  - Command specific help, [n=1,2,3]
2021
    -toPackage=name            - Stop building after package
2022
    -fromPackage=name          - Start building from package
2023
    -justPackage=name[,name]   - Build named packages
2024
    -ignorePackage=name[,name] - Do not build named packages
359 dpurdie 2025
 
2026
=head2 ARGUMENTS
2027
 
2028
Arguments are passed to the 'make' phase of the process.
2029
 
2030
=head2 OPTIONS
2031
 
2032
The are no command specific options.
2033
 
2034
=head2 DESCRIPTION
2035
 
331 dpurdie 2036
The 'make' command will perform a 'make' operation in each of the packages
2037
within the sandbox, in the correct build order.
2038
 
2039
Any arguments are passed to the 'make'.
2040
 
359 dpurdie 2041
=head1 cmd
331 dpurdie 2042
 
359 dpurdie 2043
=head2 NAME
2044
 
2045
Process each package with a specified command.
2046
 
2047
=head2 SYNOPSIS
2048
 
1328 dpurdie 2049
jats sandbox cmd [command options] [arguments]
359 dpurdie 2050
 
2051
 Command Options
1328 dpurdie 2052
    -help[=n]                  - Command specific help, [n=1,2,3]
2053 dpurdie 2053
    -[no]keepgoing             - Ignore errors
1328 dpurdie 2054
    -toPackage=name            - Stop building after package
2055
    -fromPackage=name          - Start building from package
2056
    -justPackage=name[,name]   - Build named packages
2057
    -ignorePackage=name[,name] - Do not build named packages
359 dpurdie 2058
 
2059
=head2 ARGUMENTS
2060
 
2061
Arguments are passed to a JATS command.
2062
 
2063
=head2 OPTIONS
2064
 
2053 dpurdie 2065
=over
359 dpurdie 2066
 
2053 dpurdie 2067
=item B<-[no]keepgoing>
2068
 
2069
This options controls the behaviour of the command when an error is encountered.
2070
 
2071
The default opertation is to terminate the command on the package with the
2072
error. This can be modified so that errors are ignored.
2073
 
2074
=back
2075
 
359 dpurdie 2076
=head2 DESCRIPTION
2077
 
331 dpurdie 2078
The 'cmd' command will pass all of its arguments to JATS in the build directory
2079
of each of the packages within the sandbox, in the package build order.
2080
 
359 dpurdie 2081
=head1 Cache
331 dpurdie 2082
 
359 dpurdie 2083
=head2 NAME
331 dpurdie 2084
 
359 dpurdie 2085
Cache dependent packages
331 dpurdie 2086
 
359 dpurdie 2087
jats sandbox [options] cache [command options]
331 dpurdie 2088
 
359 dpurdie 2089
 Options:
2090
    -help[=n]               - Help message, [n=1,2,3]
2091
    -man                    - Full documentation [-help=3]
2092
    -verbose[=n]            - Verbose command operation
337 dpurdie 2093
 
359 dpurdie 2094
 Command Options
2095
    -help[=n]               - Command specific help, [n=1,2,3]
337 dpurdie 2096
 
359 dpurdie 2097
=head2 ARGUMENTS
2098
 
2099
The are no command specific arguments.
2100
 
2101
=head2 OPTIONS
2102
 
2103
The are no command specific options.
2104
 
2105
=head2 DESCRIPTION
2106
 
2107
The 'cache' command will cache all external dependent packages into the users
2108
dpkg_archive_cache as defined through the EnvVar GBE_DPKG_CACHE. The result is
2109
similar to the command 'jats sandbox build -cache', without the overhead of
2110
building the sandbox components.
2111
 
2112
This command allows the simple creation of a small development environment that
2113
is not tied to the larger Development Environment. It may then be used in a
337 dpurdie 2114
disconnected mode to perform development.
2115
 
227 dpurdie 2116
=cut
2117