Subversion Repositories DevTools

Rev

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