Subversion Repositories DevTools

Rev

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