| 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
|
|
|
29 |
#
|
|
|
30 |
# add package_name - Add a package to the sandbox
|
|
|
31 |
# rm package_name - Remove a package from the sandbox
|
|
|
32 |
#
|
|
|
33 |
# build - Build all packages in the sandbox
|
|
|
34 |
# make - make all packages in the sandbox
|
|
|
35 |
#
|
|
|
36 |
#......................................................................#
|
|
|
37 |
|
| 263 |
dpurdie |
38 |
require 5.008_002;
|
| 227 |
dpurdie |
39 |
use strict;
|
|
|
40 |
use warnings;
|
|
|
41 |
use JatsError;
|
|
|
42 |
use JatsSystem;
|
|
|
43 |
use FileUtils;
|
| 245 |
dpurdie |
44 |
use JatsBuildFiles;
|
| 227 |
dpurdie |
45 |
use JatsVersionUtils;
|
| 299 |
dpurdie |
46 |
use File::Path qw(rmtree);
|
| 227 |
dpurdie |
47 |
|
|
|
48 |
|
|
|
49 |
use Pod::Usage; # required for help support
|
|
|
50 |
use Getopt::Long qw(:config require_order); # Stop on non-option
|
|
|
51 |
my $VERSION = "1.0.0"; # Update this
|
|
|
52 |
|
|
|
53 |
#
|
|
|
54 |
# Options
|
|
|
55 |
#
|
|
|
56 |
my $opt_debug = $ENV{'GBE_DEBUG'}; # Allow global debug
|
|
|
57 |
my $opt_verbose = $ENV{'GBE_VERBOSE'}; # Allow global verbose
|
|
|
58 |
my $opt_help = 0;
|
|
|
59 |
|
|
|
60 |
#
|
|
|
61 |
# Globals - Provided by the JATS environment
|
|
|
62 |
#
|
|
|
63 |
my $USER = $ENV{'USER'};
|
|
|
64 |
my $UNIX = $ENV{'GBE_UNIX'};
|
|
|
65 |
my $HOME = $ENV{'HOME'};
|
|
|
66 |
my $GBE_SANDBOX = $ENV{'GBE_SANDBOX'};
|
|
|
67 |
my $GBE_DPKG_SBOX= $ENV{'GBE_DPKG_SBOX'};
|
| 325 |
dpurdie |
68 |
my $GBE_MACHTYPE = $ENV{'GBE_MACHTYPE'};
|
| 227 |
dpurdie |
69 |
|
|
|
70 |
#
|
|
|
71 |
# Globals
|
|
|
72 |
#
|
|
|
73 |
my @build_order = (); # Build Ordered list of entries
|
| 255 |
dpurdie |
74 |
my %extern_deps; # Hash of external dependencies
|
| 227 |
dpurdie |
75 |
my %packages; # Hash of packages
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
#-------------------------------------------------------------------------------
|
|
|
79 |
# Function : Mainline Entry Point
|
|
|
80 |
#
|
|
|
81 |
# Description :
|
|
|
82 |
#
|
|
|
83 |
# Inputs :
|
|
|
84 |
#
|
|
|
85 |
my $result = GetOptions (
|
| 299 |
dpurdie |
86 |
"help|h:+" => \$opt_help,
|
|
|
87 |
"manual:3" => \$opt_help,
|
| 227 |
dpurdie |
88 |
"verbose+" => \$opt_verbose, # flag, multiple use allowed
|
|
|
89 |
);
|
|
|
90 |
|
|
|
91 |
#
|
|
|
92 |
# UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
|
|
|
93 |
#
|
|
|
94 |
|
|
|
95 |
#
|
|
|
96 |
# Process help and manual options
|
|
|
97 |
#
|
|
|
98 |
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
|
|
|
99 |
pod2usage(-verbose => 1) if ($opt_help == 2 );
|
| 299 |
dpurdie |
100 |
pod2usage(-verbose => 2) if ($opt_help > 2 );
|
| 227 |
dpurdie |
101 |
|
|
|
102 |
#
|
|
|
103 |
# Configure the error reporting process now that we have the user options
|
|
|
104 |
#
|
|
|
105 |
ErrorConfig( 'name' => 'SANDBOX',
|
|
|
106 |
'verbose' => $opt_verbose );
|
|
|
107 |
|
|
|
108 |
#
|
|
|
109 |
# Validate user options
|
|
|
110 |
#
|
|
|
111 |
|
|
|
112 |
#
|
|
|
113 |
# Parse the user command and decide what to do
|
|
|
114 |
#
|
|
|
115 |
#
|
|
|
116 |
my $cmd = shift @ARGV || "";
|
|
|
117 |
help(1) if ( $cmd =~ m/^help$/ || $cmd eq "" );
|
| 299 |
dpurdie |
118 |
delete_sandbox() if ( $cmd =~ m/^delete$/ );
|
| 227 |
dpurdie |
119 |
create_sandbox() if ( $cmd =~ m/^create$/ );
|
|
|
120 |
info(@ARGV) if ( $cmd =~ m/^info$/ );
|
|
|
121 |
cmd(@ARGV) if ( $cmd =~ m/^cmd$/ );
|
| 331 |
dpurdie |
122 |
buildcmd($cmd, @ARGV ) if ( $cmd =~ m/(^all$)|(^build$)/ );
|
|
|
123 |
cmd($cmd, @ARGV ) if ( $cmd =~ m/(^make$)/ );
|
| 273 |
dpurdie |
124 |
clean($cmd, @ARGV) if ( $cmd =~ m/(^clobber$)|(^clean$)/ );
|
| 227 |
dpurdie |
125 |
|
|
|
126 |
Error ("Unknown sandbox command: $cmd");
|
|
|
127 |
exit 1;
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
#-------------------------------------------------------------------------------
|
|
|
131 |
#
|
|
|
132 |
# Give the user a clue
|
|
|
133 |
#
|
|
|
134 |
sub help
|
|
|
135 |
{
|
|
|
136 |
my ($level) = @_;
|
|
|
137 |
$level = $opt_help unless ( $level );
|
|
|
138 |
|
|
|
139 |
pod2usage(-verbose => 0, -message => "Version: ". $VERSION) if ($level == 1 );
|
|
|
140 |
pod2usage(-verbose => $level -1 );
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
#-------------------------------------------------------------------------------
|
|
|
144 |
# Function : create_sandbox
|
|
|
145 |
#
|
|
|
146 |
# Description : create a sandbox in the current current directory
|
|
|
147 |
#
|
|
|
148 |
# Inputs : None
|
|
|
149 |
#
|
|
|
150 |
#
|
|
|
151 |
sub create_sandbox
|
|
|
152 |
{
|
| 331 |
dpurdie |
153 |
Error ("Unexpected arguments: @ARGV") if ( @ARGV );
|
| 227 |
dpurdie |
154 |
Error ("Cannot create a sandbox within a sandbox",
|
|
|
155 |
"Sandbox base is: $GBE_SANDBOX" ) if ( $GBE_SANDBOX );
|
|
|
156 |
mkdir ('sandbox_dpkg_archive') || Error ("Cannot create the directory: sandbox_dpkg_archive") ;
|
|
|
157 |
exit 0;
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
#-------------------------------------------------------------------------------
|
| 299 |
dpurdie |
161 |
# Function : delete_sandbox
|
|
|
162 |
#
|
|
|
163 |
# Description : Delete a sandbox
|
|
|
164 |
# Its up to the user the delete the components in the sandbox
|
|
|
165 |
#
|
|
|
166 |
# Inputs : None
|
|
|
167 |
#
|
|
|
168 |
# Returns :
|
|
|
169 |
#
|
|
|
170 |
sub delete_sandbox
|
|
|
171 |
{
|
| 331 |
dpurdie |
172 |
Error ("Unexpected arguments: @ARGV") if ( @ARGV );
|
| 299 |
dpurdie |
173 |
unless ( $GBE_SANDBOX )
|
|
|
174 |
{
|
|
|
175 |
Warning("No sandbox found to delete");
|
|
|
176 |
}
|
|
|
177 |
else
|
|
|
178 |
{
|
|
|
179 |
my $sdir = "$GBE_SANDBOX/sandbox_dpkg_archive";
|
|
|
180 |
rmtree($sdir,0,0);
|
|
|
181 |
Error ("Sandbox directory not completly removed")
|
|
|
182 |
if ( -e $sdir );
|
|
|
183 |
|
|
|
184 |
Message("Sandbox information deleted",
|
|
|
185 |
"Sandbox components must be manually deleted");
|
|
|
186 |
}
|
|
|
187 |
exit 0;
|
|
|
188 |
}
|
|
|
189 |
|
|
|
190 |
#-------------------------------------------------------------------------------
|
| 227 |
dpurdie |
191 |
# Function : info
|
|
|
192 |
#
|
|
|
193 |
# Description : Display Sandbox information
|
|
|
194 |
#
|
|
|
195 |
# Inputs : Command line args
|
|
|
196 |
# -v - Be more verbose
|
|
|
197 |
#
|
|
|
198 |
# Returns : Will exit
|
|
|
199 |
#
|
|
|
200 |
sub info
|
|
|
201 |
{
|
| 331 |
dpurdie |
202 |
Error ("Unexpected arguments: @ARGV") if ( @ARGV );
|
| 227 |
dpurdie |
203 |
#
|
|
|
204 |
# Allow user to specify verboseness as an argument
|
|
|
205 |
#
|
|
|
206 |
foreach ( @_ )
|
|
|
207 |
{
|
|
|
208 |
$opt_verbose++ if ( m/^-v/ )
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
#
|
|
|
212 |
# Determine Sandbox information
|
|
|
213 |
# Populate global variables
|
|
|
214 |
#
|
|
|
215 |
calc_sandbox_info();
|
|
|
216 |
|
|
|
217 |
#
|
|
|
218 |
# Display information
|
|
|
219 |
#
|
|
|
220 |
Message ("Base: $GBE_SANDBOX");
|
|
|
221 |
Message ("Archive: $GBE_DPKG_SBOX");
|
|
|
222 |
|
|
|
223 |
Message ("Build Order");
|
|
|
224 |
foreach my $fe ( @build_order )
|
|
|
225 |
{
|
| 245 |
dpurdie |
226 |
Message( " Level:" . $fe->{level} . " Name: " . $fe->{mname} );
|
| 227 |
dpurdie |
227 |
Message( DisplayPath (" Path: $fe->{dir}" )) if $opt_verbose;
|
|
|
228 |
|
|
|
229 |
if ( $opt_verbose )
|
|
|
230 |
{
|
|
|
231 |
foreach my $idep ( sort keys %{$fe->{ideps}} )
|
|
|
232 |
{
|
|
|
233 |
my ($ppn,$pps) = split( $; , $idep);
|
|
|
234 |
Message (" I:$ppn.$pps");
|
|
|
235 |
}
|
|
|
236 |
|
|
|
237 |
foreach my $edep ( sort keys %{$fe->{edeps}} )
|
|
|
238 |
{
|
|
|
239 |
my ($ppn,$pps) = split( $; , $edep);
|
|
|
240 |
my $pv = $fe->{edeps}{$edep};
|
|
|
241 |
Message (" E:$ppn $pv.$pps");
|
|
|
242 |
}
|
|
|
243 |
|
|
|
244 |
}
|
|
|
245 |
}
|
|
|
246 |
|
| 255 |
dpurdie |
247 |
Message("External Dependencies");
|
| 227 |
dpurdie |
248 |
foreach my $de ( sort keys %extern_deps )
|
|
|
249 |
{
|
|
|
250 |
my ($pn,$ps) = split( $; , $de);
|
|
|
251 |
my @vlist = keys %{$extern_deps{$de}};
|
|
|
252 |
my $flag = $#vlist ? '*' : ' ';
|
|
|
253 |
foreach my $pv ( @vlist )
|
|
|
254 |
{
|
|
|
255 |
Message (" $flag$pn $pv.$ps");
|
|
|
256 |
if ( $opt_verbose )
|
|
|
257 |
{
|
|
|
258 |
foreach my $pkg ( @{$extern_deps{$de}{$pv}} )
|
|
|
259 |
{
|
|
|
260 |
my ($ppn,$pps) = split( $; , $pkg);
|
|
|
261 |
Message (" U:$ppn.$pps");
|
|
|
262 |
|
|
|
263 |
}
|
|
|
264 |
}
|
|
|
265 |
}
|
|
|
266 |
}
|
|
|
267 |
|
|
|
268 |
if ( $opt_verbose > 2 )
|
|
|
269 |
{
|
|
|
270 |
DebugDumpData( "extern_deps", \%extern_deps);
|
|
|
271 |
DebugDumpData( "build_order", \@build_order);
|
|
|
272 |
DebugDumpData( "packages", \%packages);
|
|
|
273 |
}
|
|
|
274 |
exit (0);
|
|
|
275 |
}
|
|
|
276 |
|
|
|
277 |
#-------------------------------------------------------------------------------
|
|
|
278 |
# Function : calc_sandbox_info
|
|
|
279 |
#
|
|
|
280 |
# Description : Examine the sandbox and determine all the important
|
|
|
281 |
# information
|
|
|
282 |
#
|
|
|
283 |
# Inputs : None
|
|
|
284 |
#
|
|
|
285 |
# Returns : Will exit if not in a sandbox
|
|
|
286 |
# Populates global variables
|
|
|
287 |
# @build_order - build ordered array of build entries
|
|
|
288 |
#
|
|
|
289 |
sub calc_sandbox_info
|
|
|
290 |
{
|
|
|
291 |
#
|
|
|
292 |
# Start from the root of the sandbox
|
|
|
293 |
#
|
|
|
294 |
Error ("Command must be executed from within a Sandbox") unless ( $GBE_SANDBOX );
|
|
|
295 |
chdir ($GBE_SANDBOX) || Error ("Cannot chdir to $GBE_SANDBOX");
|
|
|
296 |
|
|
|
297 |
#
|
|
|
298 |
# Locate all packages within the sandbox
|
|
|
299 |
# These will be top-level directories - one per package
|
|
|
300 |
#
|
|
|
301 |
my @dirlist;
|
|
|
302 |
my @build_list;
|
| 255 |
dpurdie |
303 |
foreach my $pname ( glob("*") )
|
| 227 |
dpurdie |
304 |
{
|
| 255 |
dpurdie |
305 |
next if ( $pname =~ m~^\.~ );
|
|
|
306 |
next if ( $pname =~ m~dpkg_archive$~ );
|
| 297 |
dpurdie |
307 |
next if ( $pname =~ m~^CVS$~ );
|
| 255 |
dpurdie |
308 |
next unless ( -d $pname );
|
|
|
309 |
Verbose ("Package discovered: $pname");
|
| 275 |
dpurdie |
310 |
|
| 325 |
dpurdie |
311 |
if ( -f "$pname/stop" || -f "$pname/stop.$GBE_MACHTYPE" )
|
| 275 |
dpurdie |
312 |
{
|
|
|
313 |
Warning("Package contains stop file: $pname");
|
|
|
314 |
next;
|
|
|
315 |
}
|
|
|
316 |
|
| 255 |
dpurdie |
317 |
push @dirlist, $pname;
|
| 227 |
dpurdie |
318 |
|
|
|
319 |
#
|
|
|
320 |
# Locate the build files in each package
|
| 245 |
dpurdie |
321 |
# Scan the build files and extract dependancy information
|
| 227 |
dpurdie |
322 |
#
|
| 255 |
dpurdie |
323 |
my $bscanner = BuildFileScanner( $pname, 'build.pl', '--LocateAll', '--ScanDependencies' );
|
| 245 |
dpurdie |
324 |
$bscanner->scan();
|
|
|
325 |
my @blist = $bscanner->getInfo();
|
| 255 |
dpurdie |
326 |
Warning ("Package does not have build files: $pname") unless ( @blist );
|
|
|
327 |
Warning ("Package has multiple build files: $pname") if ( $#blist > 0 );
|
| 245 |
dpurdie |
328 |
push @build_list, @blist;
|
| 227 |
dpurdie |
329 |
}
|
|
|
330 |
|
|
|
331 |
#
|
|
|
332 |
# Process each build file and extract
|
|
|
333 |
# Name of the Package
|
|
|
334 |
# Dependency list
|
|
|
335 |
# Build up a hash of dependence information
|
|
|
336 |
#
|
|
|
337 |
|
|
|
338 |
my %depends;
|
| 299 |
dpurdie |
339 |
my %multi;
|
| 245 |
dpurdie |
340 |
foreach my $be ( @build_list )
|
| 227 |
dpurdie |
341 |
{
|
| 245 |
dpurdie |
342 |
Verbose( DisplayPath ("Build file: " . $be->{dir} . " Name: " . $be->{file} ));
|
|
|
343 |
# DebugDumpData ("be", $be );
|
| 227 |
dpurdie |
344 |
|
|
|
345 |
#
|
| 299 |
dpurdie |
346 |
# Catch multiple builds for the same package
|
|
|
347 |
# Report later - when we have all
|
|
|
348 |
#
|
| 321 |
dpurdie |
349 |
next unless ( $be->{mname} );
|
| 299 |
dpurdie |
350 |
push @{$multi{$be->{mname}}},$be->{dir};
|
|
|
351 |
|
|
|
352 |
#
|
| 227 |
dpurdie |
353 |
# Add into dependency struct
|
|
|
354 |
#
|
| 245 |
dpurdie |
355 |
$depends{$be->{package}}{depends} = $be->{depends};
|
|
|
356 |
$depends{$be->{package}}{entry} = $be;
|
| 227 |
dpurdie |
357 |
}
|
|
|
358 |
|
| 299 |
dpurdie |
359 |
foreach my $mname ( sort keys %multi )
|
|
|
360 |
{
|
|
|
361 |
ReportError ("Mutiple builders for : $mname", @{$multi{$mname}} )
|
|
|
362 |
if ( scalar @{$multi{$mname}} > 1 );
|
|
|
363 |
}
|
|
|
364 |
ErrorDoExit();
|
|
|
365 |
|
| 245 |
dpurdie |
366 |
#DebugDumpData ("depends", \%depends );
|
|
|
367 |
|
| 227 |
dpurdie |
368 |
#
|
|
|
369 |
# Determine the build order
|
|
|
370 |
#
|
|
|
371 |
@build_order = ();
|
|
|
372 |
my $more = 1;
|
|
|
373 |
my $level = 0;
|
|
|
374 |
|
|
|
375 |
#
|
| 255 |
dpurdie |
376 |
# Remove any dependencies to 'external' packages
|
| 227 |
dpurdie |
377 |
# These will not be met internally and can be regarded as constant
|
|
|
378 |
#
|
|
|
379 |
foreach my $key ( keys %depends )
|
|
|
380 |
{
|
|
|
381 |
foreach my $build ( keys( %{$depends{$key}{depends}} ))
|
|
|
382 |
{
|
|
|
383 |
unless (exists $depends{$build})
|
|
|
384 |
{
|
|
|
385 |
push @{$extern_deps{$build}{$depends{$key}{depends}{$build}}}, $key;
|
|
|
386 |
$depends{$key}{entry}{edeps}{$build} = $depends{$key}{depends}{$build};
|
|
|
387 |
delete ($depends{$key}{depends}{$build}) ;
|
|
|
388 |
Verbose2( "Not in set: $build");
|
|
|
389 |
}
|
|
|
390 |
else
|
|
|
391 |
{
|
|
|
392 |
$depends{$key}{entry}{ideps}{$build} = 1;
|
|
|
393 |
}
|
|
|
394 |
}
|
|
|
395 |
}
|
|
|
396 |
while ( $more )
|
|
|
397 |
{
|
|
|
398 |
$more = 0;
|
|
|
399 |
$level++;
|
|
|
400 |
my @build;
|
|
|
401 |
|
|
|
402 |
#
|
|
|
403 |
# Locate packages with no dependencies
|
|
|
404 |
#
|
|
|
405 |
foreach my $key ( keys %depends )
|
|
|
406 |
{
|
|
|
407 |
next if ( keys( %{$depends{$key}{depends}} ) );
|
|
|
408 |
push @build, $key;
|
|
|
409 |
}
|
|
|
410 |
|
|
|
411 |
foreach my $build ( @build )
|
|
|
412 |
{
|
|
|
413 |
$more = 1;
|
|
|
414 |
my $fe = $depends{$build}{entry};
|
|
|
415 |
$fe->{level} = $level;
|
|
|
416 |
$packages{$build} = $fe;
|
|
|
417 |
push @build_order, $fe;
|
|
|
418 |
delete $depends{$build};
|
|
|
419 |
delete $fe->{depends}; # remove now its not needed
|
|
|
420 |
}
|
|
|
421 |
|
|
|
422 |
foreach my $key ( keys %depends )
|
|
|
423 |
{
|
|
|
424 |
foreach my $build ( @build )
|
|
|
425 |
{
|
|
|
426 |
delete $depends{$key}{depends}{$build};
|
|
|
427 |
}
|
|
|
428 |
}
|
|
|
429 |
}
|
|
|
430 |
|
|
|
431 |
#
|
|
|
432 |
# Just to be sure to be sure
|
|
|
433 |
#
|
| 245 |
dpurdie |
434 |
if ( keys %depends )
|
|
|
435 |
{
|
|
|
436 |
#DebugDumpData ("depends", \%depends );
|
|
|
437 |
Error( "Internal algorithm error: Bad dependancy walk",
|
|
|
438 |
"Possible circular dependency");
|
|
|
439 |
}
|
| 227 |
dpurdie |
440 |
|
|
|
441 |
# DebugDumpData ("Order", \@build_order);
|
|
|
442 |
}
|
|
|
443 |
|
|
|
444 |
#-------------------------------------------------------------------------------
|
|
|
445 |
# Function : cmd
|
|
|
446 |
#
|
|
|
447 |
# Description : Execute a command in all the sandboxes
|
|
|
448 |
# Locate the base of the sandbox
|
|
|
449 |
# Locate all packages in the sandbox
|
|
|
450 |
# Locate all build files in each sandbox
|
|
|
451 |
# Determine build order
|
|
|
452 |
# Issue commands for each sandbox in order
|
|
|
453 |
#
|
| 255 |
dpurdie |
454 |
# Inputs : Arguments passed to jats build
|
| 227 |
dpurdie |
455 |
#
|
|
|
456 |
# Returns : Will exit
|
|
|
457 |
#
|
|
|
458 |
sub cmd
|
|
|
459 |
{
|
|
|
460 |
my @cmds = @_;
|
|
|
461 |
#
|
|
|
462 |
# Determine Sandbox information
|
|
|
463 |
# Populate global variables
|
|
|
464 |
#
|
|
|
465 |
calc_sandbox_info();
|
|
|
466 |
foreach my $fe ( @build_order )
|
|
|
467 |
{
|
|
|
468 |
my $dir = $fe->{dir};
|
| 255 |
dpurdie |
469 |
Message( "Level:" . $fe->{level} . " Name: " . $fe->{mname} ,
|
| 227 |
dpurdie |
470 |
DisplayPath (" Path: $fe->{dir}" ));
|
|
|
471 |
|
| 263 |
dpurdie |
472 |
my $result = JatsCmd( "-cd=$dir", @cmds);
|
| 255 |
dpurdie |
473 |
Error ("Cmd failure") if ( $result );
|
| 227 |
dpurdie |
474 |
}
|
|
|
475 |
|
|
|
476 |
exit 0;
|
|
|
477 |
}
|
|
|
478 |
|
|
|
479 |
#-------------------------------------------------------------------------------
|
| 331 |
dpurdie |
480 |
# Function : buildcmd
|
|
|
481 |
#
|
|
|
482 |
# Description : Build the entire sandbox
|
|
|
483 |
# The all and the build are similar.
|
|
|
484 |
# Its not really useful to do a build without a make
|
|
|
485 |
# so we don't try
|
|
|
486 |
#
|
|
|
487 |
# Inputs : Arguments passed to jats make
|
|
|
488 |
#
|
|
|
489 |
#
|
|
|
490 |
# Returns : Will exit
|
|
|
491 |
#
|
|
|
492 |
|
|
|
493 |
sub buildcmd
|
|
|
494 |
{
|
|
|
495 |
my ($cmd, @make_opts) = @_;
|
|
|
496 |
my @build_opts;
|
|
|
497 |
|
|
|
498 |
#
|
|
|
499 |
# Insert default options
|
|
|
500 |
#
|
|
|
501 |
push @build_opts, '-noforce' if ( $cmd eq 'all' );
|
|
|
502 |
push @build_opts, '-force' if ( $cmd ne 'all' );
|
|
|
503 |
|
|
|
504 |
push @make_opts, 'all' unless ( @make_opts );
|
|
|
505 |
|
|
|
506 |
#
|
|
|
507 |
# Determine Sandbox information
|
|
|
508 |
# Populate global variables
|
|
|
509 |
#
|
|
|
510 |
calc_sandbox_info();
|
|
|
511 |
foreach my $fe ( @build_order )
|
|
|
512 |
{
|
|
|
513 |
my $dir = $fe->{dir};
|
|
|
514 |
Message( "Level:" . $fe->{level} . " Name: " . $fe->{mname} ,
|
|
|
515 |
DisplayPath (" Path: $fe->{dir}" ));
|
|
|
516 |
|
|
|
517 |
JatsCmd( "-cd=$dir", 'build', @build_opts) && Error ("Build Cmd failure") if ( $result );
|
|
|
518 |
JatsCmd( "-cd=$dir", 'make', @make_opts) && Error ("Make Cmd failure") if ( $result );
|
|
|
519 |
}
|
|
|
520 |
|
|
|
521 |
exit 0;
|
|
|
522 |
}
|
|
|
523 |
|
|
|
524 |
|
|
|
525 |
#-------------------------------------------------------------------------------
|
| 273 |
dpurdie |
526 |
# Function : clean
|
|
|
527 |
#
|
|
|
528 |
# Description : Execute a command in all the sandboxes
|
|
|
529 |
# Locate the base of the sandbox
|
|
|
530 |
# Locate all packages in the sandbox
|
|
|
531 |
# Locate all build files in each sandbox
|
|
|
532 |
# Determine build order
|
|
|
533 |
# Issue commands for each sandbox in order
|
|
|
534 |
#
|
|
|
535 |
# Inputs : Arguments passed to jats build
|
|
|
536 |
#
|
|
|
537 |
# Returns : Will exit
|
|
|
538 |
#
|
|
|
539 |
sub clean
|
|
|
540 |
{
|
|
|
541 |
my ($mode, @cmds ) = @_;
|
|
|
542 |
#
|
|
|
543 |
# Determine Sandbox information
|
|
|
544 |
# Populate global variables
|
|
|
545 |
#
|
|
|
546 |
calc_sandbox_info();
|
|
|
547 |
|
|
|
548 |
my @cmd = $mode eq 'clobber' ? ('clobber') : ('make', 'clean' );
|
|
|
549 |
|
|
|
550 |
#
|
|
|
551 |
# Clobber and clean need to be done in the reverse order
|
|
|
552 |
#
|
|
|
553 |
foreach my $fe ( reverse @build_order )
|
|
|
554 |
{
|
|
|
555 |
my $dir = $fe->{dir};
|
|
|
556 |
Message( "Level:" . $fe->{level} . " Name: " . $fe->{mname} ,
|
|
|
557 |
DisplayPath (" Path: $fe->{dir}" ));
|
|
|
558 |
|
|
|
559 |
my $result = JatsCmd( "-cd=$dir", @cmd, @cmds);
|
|
|
560 |
Error ("Cmd failure") if ( $result );
|
|
|
561 |
}
|
|
|
562 |
|
|
|
563 |
exit 0;
|
|
|
564 |
}
|
|
|
565 |
|
|
|
566 |
|
|
|
567 |
#-------------------------------------------------------------------------------
|
| 227 |
dpurdie |
568 |
# Documentation
|
|
|
569 |
#
|
|
|
570 |
|
|
|
571 |
=pod
|
|
|
572 |
|
|
|
573 |
=head1 NAME
|
|
|
574 |
|
|
|
575 |
jats_sandbox - Build in a Development Sandbox
|
|
|
576 |
|
|
|
577 |
=head1 SYNOPSIS
|
|
|
578 |
|
| 255 |
dpurdie |
579 |
jats sandbox [options] [commands]
|
| 227 |
dpurdie |
580 |
|
|
|
581 |
Options:
|
| 299 |
dpurdie |
582 |
-help[=n] - Display help with specified detail
|
| 227 |
dpurdie |
583 |
-help -help - Detailed help message
|
|
|
584 |
-man - Full documentation
|
|
|
585 |
|
|
|
586 |
Commands:
|
|
|
587 |
help - Same as -help
|
|
|
588 |
create - Create a sandbox in the current directory
|
| 299 |
dpurdie |
589 |
delete - Delete the sandbox
|
| 255 |
dpurdie |
590 |
info [[-v]-v] - Sandbox information. -v: Be more verbose
|
| 227 |
dpurdie |
591 |
cmd - Do commands in all sandbox components
|
| 331 |
dpurdie |
592 |
all - Do 'build', if required, then a make in all sandbox components
|
|
|
593 |
build - Force 'build and make' in all sandbox components
|
| 275 |
dpurdie |
594 |
make - Do 'make' in all sandbox components
|
| 273 |
dpurdie |
595 |
clean - Do 'make clean' in all sandbox components
|
|
|
596 |
clobber - Do 'build clobber' is all sandbox components
|
| 227 |
dpurdie |
597 |
|
|
|
598 |
=head1 OPTIONS
|
|
|
599 |
|
|
|
600 |
=over 8
|
|
|
601 |
|
| 299 |
dpurdie |
602 |
=item B<-help[=n]>
|
| 227 |
dpurdie |
603 |
|
|
|
604 |
Print a brief help message and exits.
|
| 299 |
dpurdie |
605 |
There are three levels of help
|
| 227 |
dpurdie |
606 |
|
| 299 |
dpurdie |
607 |
=over 8
|
|
|
608 |
|
|
|
609 |
=item 1 Brief synopsis
|
|
|
610 |
|
|
|
611 |
=item 2 Synopsis and option summary
|
|
|
612 |
|
|
|
613 |
=item 3 Detailed help in man format
|
|
|
614 |
|
|
|
615 |
=back 8
|
|
|
616 |
|
| 227 |
dpurdie |
617 |
=item B<-help -help>
|
|
|
618 |
|
|
|
619 |
Print a detailed help message with an explanation for each option.
|
|
|
620 |
|
|
|
621 |
=item B<-man>
|
|
|
622 |
|
| 299 |
dpurdie |
623 |
Prints the manual page and exits. This is the same a -help=3
|
| 227 |
dpurdie |
624 |
|
| 279 |
dpurdie |
625 |
=back
|
|
|
626 |
|
| 227 |
dpurdie |
627 |
=head1 DESCRIPTION
|
|
|
628 |
|
| 299 |
dpurdie |
629 |
This program is the primary tool for the maintenance of Development Sandboxes.
|
|
|
630 |
|
| 227 |
dpurdie |
631 |
More documentation will follow.
|
|
|
632 |
|
| 279 |
dpurdie |
633 |
=head2 SANDBOX DIRECTORY
|
|
|
634 |
|
| 299 |
dpurdie |
635 |
The sandbox directory is marked as being a sandbox through the use of the
|
|
|
636 |
'sandbox create' command. This will create a suitable structure within the
|
| 279 |
dpurdie |
637 |
current directory.
|
|
|
638 |
|
|
|
639 |
Several JATS commands operate differently within a sandbox. The 'extract' and
|
|
|
640 |
'release' commands will create static viwes within the sandbox and not the
|
|
|
641 |
normal directory. The 'sandbox' sub commands can only be used within a sandbox.
|
|
|
642 |
|
|
|
643 |
The sandbox directory contains sub directories, each should contain a single
|
|
|
644 |
package. Sub directories may be created with the 'jats extract' command.
|
|
|
645 |
|
|
|
646 |
Note: Symbolic links are not supported. They cannot work as he sandbox mechanism
|
|
|
647 |
requires that all the packages be conatined within a sub directory tree so
|
|
|
648 |
that the root of the sandbox can be located by a simple scan of the directory
|
|
|
649 |
tree.
|
|
|
650 |
|
| 325 |
dpurdie |
651 |
If a package subdirectory contains a file called 'stop' or 'stop.
|
|
|
652 |
<GBE_MACHTYPE>', then that package will not be considered as a part of the
|
|
|
653 |
build-set. A 'stop' file will prevent consideration all build platforms. The 'stop.
|
|
|
654 |
<GBE_MACHTYPE>' will only prevent consideration if being built on a GBE_MACHTYPE
|
|
|
655 |
type of computer.
|
| 279 |
dpurdie |
656 |
|
| 299 |
dpurdie |
657 |
=head2 COMMAND SUMMARY
|
|
|
658 |
|
|
|
659 |
=head3 create
|
|
|
660 |
|
|
|
661 |
The 'create' command will create a sandbox in the users current directory. It is
|
|
|
662 |
not possible to create a sandbox within a sandbox.
|
|
|
663 |
|
|
|
664 |
A sandbox can be created in a directory that contains files and subdirectories.
|
|
|
665 |
|
|
|
666 |
The create command simply places a known directory in the current directory.
|
|
|
667 |
This dorectory is used by the sandboxing process. It may be manually deleted, or
|
|
|
668 |
deleted with the 'delete' command.
|
|
|
669 |
|
|
|
670 |
=head3 delete
|
|
|
671 |
|
|
|
672 |
The 'delete' command will delete the sandbox's marker directory. The command may
|
|
|
673 |
be executed anywhere within the sandbox.
|
|
|
674 |
|
|
|
675 |
Once the sanbox has been deleted, the user must remove the components within the
|
|
|
676 |
sandbox.
|
|
|
677 |
|
|
|
678 |
=head3 info
|
|
|
679 |
|
|
|
680 |
The 'info' command will display information about the build order and the
|
|
|
681 |
depenedencies of packages that it finds within the sandbox.
|
|
|
682 |
|
|
|
683 |
The command will accept one option '-v' to increase the verbosity of the
|
|
|
684 |
information being displayed.
|
|
|
685 |
|
|
|
686 |
=over 8
|
|
|
687 |
|
|
|
688 |
=item * No Verbosity
|
|
|
689 |
|
|
|
690 |
The basic command will display the build order and the external
|
|
|
691 |
dependencies
|
|
|
692 |
|
|
|
693 |
=item Verbosity of 1
|
|
|
694 |
|
|
|
695 |
This level of verbosoity will display the build order and detailed information
|
|
|
696 |
on the dependencies. The dependencies will be prefixed with:
|
|
|
697 |
|
|
|
698 |
=over 8
|
|
|
699 |
|
|
|
700 |
=item E Dependent Package is external to the sandbox
|
|
|
701 |
|
|
|
702 |
=item I Dependent Package is internal to the sandbox
|
|
|
703 |
|
|
|
704 |
=back
|
|
|
705 |
|
|
|
706 |
This level of verbosity display information on packages that are external to the
|
|
|
707 |
sandbox. External dependencies may be prefixed with a '*'. This indicates that
|
|
|
708 |
multiple versions of this package are being used by sandboxed components.
|
|
|
709 |
|
|
|
710 |
The internal consumer of the external package is also shown. These are
|
|
|
711 |
prefixed with a 'U'.
|
|
|
712 |
|
|
|
713 |
=item Verbosity of 2
|
|
|
714 |
|
|
|
715 |
Reserved forfuture use
|
|
|
716 |
|
|
|
717 |
=item Verbosity over 2
|
|
|
718 |
|
|
|
719 |
This should be considered a debug option. Undocument internal information will
|
|
|
720 |
be displayed.
|
|
|
721 |
|
|
|
722 |
=back
|
|
|
723 |
|
| 331 |
dpurdie |
724 |
=head3 all
|
|
|
725 |
|
|
|
726 |
The 'all' command will perform build, if the build files are out of date,
|
|
|
727 |
followed by a make in each of the packages within the sandbox, in the correct
|
|
|
728 |
build order.
|
|
|
729 |
|
|
|
730 |
Any arguments are passed to the 'make' phase of the process.
|
|
|
731 |
|
|
|
732 |
This command may be used to:
|
|
|
733 |
|
|
|
734 |
=over 8
|
|
|
735 |
|
|
|
736 |
=item * Pickup any build file changes.
|
|
|
737 |
|
|
|
738 |
=item * Resume a failed build.
|
|
|
739 |
|
|
|
740 |
=back
|
|
|
741 |
|
|
|
742 |
=head3 build
|
|
|
743 |
|
|
|
744 |
The 'build' command will force a build followed by a make in each of the packages
|
|
|
745 |
within the sandbox, in the correct build order.
|
|
|
746 |
|
|
|
747 |
Any arguments are passed to the 'make' phase of the process.
|
|
|
748 |
|
|
|
749 |
In practice, the 'sandbox all' command is quicker.
|
|
|
750 |
|
|
|
751 |
=head3 make
|
|
|
752 |
|
|
|
753 |
The 'make' command will perform a 'make' operation in each of the packages
|
|
|
754 |
within the sandbox, in the correct build order.
|
|
|
755 |
|
|
|
756 |
Any arguments are passed to the 'make'.
|
|
|
757 |
|
|
|
758 |
=head3 cmd
|
|
|
759 |
|
|
|
760 |
The 'cmd' command will pass all of its arguments to JATS in the build directory
|
|
|
761 |
of each of the packages within the sandbox, in the package build order.
|
|
|
762 |
|
|
|
763 |
=head3 clean
|
|
|
764 |
|
|
|
765 |
The 'clean' command will perform a 'jats make clean' in all components in the
|
|
|
766 |
sandbox.
|
|
|
767 |
|
|
|
768 |
=head3 clobber
|
|
|
769 |
|
|
|
770 |
The 'clobber' command will perform a 'jats clobber' in all components in the
|
|
|
771 |
sandbox.
|
|
|
772 |
|
| 227 |
dpurdie |
773 |
=cut
|
|
|
774 |
|
| 255 |
dpurdie |
775 |
|