Subversion Repositories DevTools

Rev

Rev 303 | Rev 311 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 303 Rev 305
Line 29... Line 29...
29
use JatsSystem;
29
use JatsSystem;
30
use JatsVersionUtils;
30
use JatsVersionUtils;
31
use FileUtils;
31
use FileUtils;
32
use Pod::Usage;
32
use Pod::Usage;
33
use Getopt::Long;
33
use Getopt::Long;
-
 
34
use File::Path;
34
 
35
 
35
our $BuildVersion           = "2.1.0";
36
our $BuildVersion           = "2.1.0";
36
 
37
 
37
#.. Switchs
38
#.. Switchs
38
#
39
#
Line 98... Line 99...
98
our $ScmInterface;                              # Interface directory
99
our $ScmInterface;                              # Interface directory
99
 
100
 
100
 
101
 
101
 
102
 
102
my  $DeleteDPACKAGE         = 0;                # Must clobber DPACKAGE
103
my  $DeleteDPACKAGE         = 0;                # Must clobber DPACKAGE
-
 
104
my  $build_source_pkg       = 0;                # Flag to build source package
103
my  $opt_help               = 0;
105
my  $opt_help               = 0;
104
 
106
 
105
BuildLibInit();
107
BuildLibInit();
106
 
108
 
107
sub BuildLibInit
109
sub BuildLibInit
Line 2350... Line 2352...
2350
        }
2352
        }
2351
    }
2353
    }
2352
    return $string;
2354
    return $string;
2353
}
2355
}
2354
 
2356
 
-
 
2357
#-------------------------------------------------------------------------------
-
 
2358
# Function        : BuildReleaseFile
2355
 
2359
#
-
 
2360
# Description     : Legacy function
-
 
2361
#                   Don't know what it was meant to do
-
 
2362
#                   Unfortunately it is present in a lot of build.pl files
-
 
2363
#
-
 
2364
#                   Not well supported on all machine types
-
 
2365
#
-
 
2366
# Inputs          : $BuildFilename          - Root of output filename
-
 
2367
#                   $BuildDir               - Path of subdir to tar
-
 
2368
#
-
 
2369
#                   Also uses the undocumented: GBE_SNAPSHOT_DIR
-
 
2370
#
-
 
2371
# Returns         : Does not return
-
 
2372
#                   Once invoked this function will exit the build
-
 
2373
#
2356
sub BuildReleaseFile
2374
sub BuildReleaseFile
2357
{
2375
{
2358
    my ( $BuildFilename, $BuildDir ) = @_;
2376
    my ( $BuildFilename, $BuildDir ) = @_;
2359
    my ( $SnapDir );
2377
    my ( $SnapDir );
2360
 
2378
 
Line 2374... Line 2392...
2374
    System( "$::GBE_BIN/tar czf $SnapDir$BuildFilename.tgz $BuildDir" );
2392
    System( "$::GBE_BIN/tar czf $SnapDir$BuildFilename.tgz $BuildDir" );
2375
 
2393
 
2376
    Error( "To extract use: $::GBE_BIN/tar xvzf $BuildFilename.tgz" );
2394
    Error( "To extract use: $::GBE_BIN/tar xvzf $BuildFilename.tgz" );
2377
}
2395
}
2378
 
2396
 
-
 
2397
#-------------------------------------------------------------------------------
-
 
2398
# Function        : BuildSnapshot
2379
 
2399
#
-
 
2400
# Description     : Legacy function
-
 
2401
#                   Don't know what it was meant to do
-
 
2402
#                   Unfortunately it is present in a lot of build.pl files
-
 
2403
#
-
 
2404
# Inputs          : None that are used
-
 
2405
#
-
 
2406
# Returns         : Undefined
-
 
2407
#
2380
sub BuildSnapshot
2408
sub BuildSnapshot
2381
{
2409
{
2382
}
2410
}
2383
 
2411
 
-
 
2412
#-------------------------------------------------------------------------------
-
 
2413
# Function        : BuildSrcArchive
-
 
2414
#
-
 
2415
# Description     : Create a source snapshot of the build source
-
 
2416
#                   Designed to provide a source image for packaging
-
 
2417
#                   examples
-
 
2418
#
-
 
2419
#                   Should be platform independent
-
 
2420
#
-
 
2421
#                   Creates an archive file and places it into the
-
 
2422
#                   interface directory. The archive will be packaged
-
 
2423
#                   automatically by the build process
-
 
2424
#
-
 
2425
#                   Use the 'pax' utility
-
 
2426
#                       1) Can massage the file path such that the stored
-
 
2427
#                          directory image contains the package name and version
-
 
2428
#
-
 
2429
#                   Directive can be used at any time before the BuildMake
-
 
2430
#
-
 
2431
#                   Will handle the existence of an auto.pl file by inserting
-
 
2432
#                   it as build.pl.
-
 
2433
#
-
 
2434
# Inputs          : Options
-
 
2435
#
-
 
2436
#
-
 
2437
# Returns         : 
-
 
2438
#
-
 
2439
sub BuildSrcArchive
-
 
2440
{
-
 
2441
    #
-
 
2442
    #   If we are clobbering, then there is nothing to do
-
 
2443
    #   The generated file is placed within the interface
-
 
2444
    #   directory and that directory will be deleted during the clobber
-
 
2445
    #
-
 
2446
    return if ( $Clobber );
-
 
2447
    DataDirective("BuildSrcArchive");
-
 
2448
 
-
 
2449
    #
-
 
2450
    #   Currently this operation is only supported of some platforms
-
 
2451
    #   Only supported on Unix platforms
-
 
2452
    #   Uses the 'pax' utility
-
 
2453
    #
-
 
2454
    unless ( LocateProgInPath ( 'pax', '--All' ) && ( $ScmHost eq "Unix" ) )
-
 
2455
    {
-
 
2456
        Log( "SrcPackage . Not supported" );
-
 
2457
        return;
-
 
2458
    }
-
 
2459
 
-
 
2460
    #
-
 
2461
    #   Only allow one instance of the directive
-
 
2462
    #
-
 
2463
    Error ("Multiple BuildSrcArchive directives not supported")
-
 
2464
        if ( $build_source_pkg );
-
 
2465
 
-
 
2466
    #
-
 
2467
    #   Create the name of the archive
-
 
2468
    #       Based on the package name and version
-
 
2469
    #       Has no spaces
-
 
2470
    #
-
 
2471
    my $build_name = $BUILDNAME;
-
 
2472
    $build_name =~ s~\s+~_~g;
-
 
2473
 
-
 
2474
    #
-
 
2475
    #   Create the archive in the interface directory
-
 
2476
    #   Don't need to clobber it as the entire interface directory
-
 
2477
    #   will be clobbered
-
 
2478
    #
-
 
2479
    $build_source_pkg = $build_name;
-
 
2480
}
-
 
2481
 
-
 
2482
#-------------------------------------------------------------------------------
-
 
2483
# Function        : BuildSrcArchiveBody
-
 
2484
#
-
 
2485
# Description     : Function to implement the body of the BuildSrcArchive
-
 
2486
#                   operation. Will be invoked during BuildMake
-
 
2487
#
-
 
2488
# Inputs          : None
-
 
2489
#
-
 
2490
# Returns         : 
-
 
2491
#
-
 
2492
sub BuildSrcArchiveBody
-
 
2493
{
-
 
2494
    return unless ( $build_source_pkg );
-
 
2495
 
-
 
2496
    my $archive_dir = "pkg/$BUILDNAME_PACKAGE/src";
-
 
2497
    my $archive_file = "$build_source_pkg" . '.tar';
-
 
2498
 
-
 
2499
    Log( "SrcPackage . $archive_file.gz" );
-
 
2500
    unlink "$archive_dir/$archive_file";
-
 
2501
    unlink "$archive_dir/$archive_file.gz";
-
 
2502
    mkpath($archive_dir, 0, 0775);
-
 
2503
    
-
 
2504
    #
-
 
2505
    #   Create a list of files and top-level dirs to add to source archive
-
 
2506
    #   Many files are ignored
-
 
2507
    #   Should only be executed on the first 'build' thus many internal
-
 
2508
    #   directories will not be present
-
 
2509
    #
-
 
2510
    my @flist;
-
 
2511
    my $auto_pl;
-
 
2512
    opendir (my $tp, '.' ) or Error ("Cannot read current directory");
-
 
2513
    while ( $_ = readdir($tp) )
-
 
2514
    {
-
 
2515
        next if ( m/^\.$/ );
-
 
2516
        next if ( m'^\.\.$' );
-
 
2517
        next if ( m'^build\.log$' );
-
 
2518
        next if ( m'\.gbe$' );
-
 
2519
        next if ( m'^local$' );
-
 
2520
        next if ( m'^pkg$' );
-
 
2521
        next if ( m/^$BUILDINTERFACE$/ );
-
 
2522
        $auto_pl = 1, next  if ( m'^auto\.pl$' );
-
 
2523
        next if (  m'^build\.pl$' );
-
 
2524
        next if ( m/^$build_source_pkg$/ );
-
 
2525
        push @flist, $_;
-
 
2526
    }
-
 
2527
    closedir $tp;
-
 
2528
 
-
 
2529
    #
-
 
2530
    #   If we don't have an auto.pl, then we add the build.pl file
-
 
2531
    #   If we do have a auto.pl - it gets tricky. Its don't after the
-
 
2532
    #   initial pax command
-
 
2533
    #
-
 
2534
    unless ( $auto_pl )
-
 
2535
    {
-
 
2536
        push @flist, 'build.pl';
-
 
2537
    }
-
 
2538
 
-
 
2539
    #
-
 
2540
    #   Create the command to be executed
-
 
2541
    #   Prefix archive paths with build_name
-
 
2542
    #
-
 
2543
    my @command = ( 'pax', '-w', '-f', "$archive_dir/$archive_file" );
-
 
2544
    System( '--NoShell' , @command, '-s', "~^~$build_source_pkg/~", @flist );
-
 
2545
 
-
 
2546
    #
-
 
2547
    #   If we have an auto.pl file, then we need to add it to the archive
-
 
2548
    #   but it needs to be called build.pl
-
 
2549
    #
-
 
2550
    if ( $auto_pl )
-
 
2551
    {
-
 
2552
        System( '--NoShell' , @command, '-a', '-s', "~^auto.pl~$build_source_pkg/build.pl~" , 'auto.pl' );
-
 
2553
    }
-
 
2554
 
-
 
2555
    #
-
 
2556
    #   Must now zip the file
-
 
2557
    #   Can't zip and append at the same time
-
 
2558
    #
-
 
2559
    System( '--NoShell' , 'gzip', "$archive_dir/$archive_file" );
-
 
2560
 
-
 
2561
    #
-
 
2562
    #   Display the results
-
 
2563
    #
-
 
2564
    System ('--NoShell', 'pax', '-z', "-f$archive_dir/$archive_file.gz")
-
 
2565
        if (IsVerbose (1));
-
 
2566
}
2384
 
2567
 
-
 
2568
#-------------------------------------------------------------------------------
-
 
2569
# Function        : BuildAccessPerms
-
 
2570
#
2385
#.. Check if access/permissions setting requested...
2571
# Description     : Check if access/permissions setting requested...
-
 
2572
#                   Legacy
-
 
2573
#
-
 
2574
# Inputs          : None
-
 
2575
#
-
 
2576
# Returns         : 
2386
#
2577
#
2387
sub BuildAccessPerms
2578
sub BuildAccessPerms
2388
{
2579
{
2389
    my( $PermsFilename );
2580
    my( $PermsFilename );
2390
 
2581
 
Line 2439... Line 2630...
2439
#
2630
#
2440
# Description     : Called by directives that deal with the building phases
2631
# Description     : Called by directives that deal with the building phases
2441
#                   to perform common initialisation and to ensure that
2632
#                   to perform common initialisation and to ensure that
2442
#                   directives that collect data are no longer called
2633
#                   directives that collect data are no longer called
2443
#
2634
#
2444
# Inputs          : None
2635
# Inputs          : last                - True: Last directive expected
2445
#
2636
#
2446
# Returns         : May generate an error
2637
# Returns         : May generate an error
2447
#
2638
#
2448
sub StartBuildPhase
2639
sub StartBuildPhase
2449
{
2640
{
-
 
2641
    my ($last) = @_;
-
 
2642
 
-
 
2643
    #
-
 
2644
    #   Ensure directive is allowed
-
 
2645
    #       $BUILDPHASE >  1     - No more directives allowed
-
 
2646
    #       $BUILDPHASE == 1     - Allowed directive
-
 
2647
    #
-
 
2648
    if ( $BUILDPHASE > 1 )
-
 
2649
    {
-
 
2650
        my $function = (caller(1))[3];
-
 
2651
        $function =~ s~.*::~~;
-
 
2652
        Error ("Directive not allowed: $function","'BuildMake' must be the last directive in the build file");
-
 
2653
    }
-
 
2654
 
2450
    #
2655
    #
2451
    #   Only do it once
2656
    #   Only do it once
2452
    #
2657
    #
2453
    return if ( $BUILDPHASE++  );
2658
    return if ( $BUILDPHASE  );
-
 
2659
    $BUILDPHASE = 1;
2454
 
2660
 
2455
    #
2661
    #
2456
    #   Calcuate the aliases that are being extracted from targets
2662
    #   Calcuate the aliases that are being extracted from targets
2457
    #
2663
    #
2458
    Process_TargetAlias();
2664
    Process_TargetAlias();
Line 2487... Line 2693...
2487
    #   Must have a valid Srcdir
2693
    #   Must have a valid Srcdir
2488
    #
2694
    #
2489
    Error ("Source directory not found: $Srcdir")
2695
    Error ("Source directory not found: $Srcdir")
2490
        unless ( $Srcdir && -d $Srcdir );
2696
        unless ( $Srcdir && -d $Srcdir );
2491
 
2697
 
-
 
2698
    #
-
 
2699
    #   Create source package
-
 
2700
    #
-
 
2701
    BuildSrcArchiveBody();
-
 
2702
 
2492
    return $Srcdir;
2703
    return $Srcdir;
2493
}
2704
}
2494
 
2705
 
2495
#-------------------------------------------------------------------------------
2706
#-------------------------------------------------------------------------------
-
 
2707
# Function        : LastBuildDirective
-
 
2708
#
-
 
2709
# Description     : No more build directives allowed
-
 
2710
#
-
 
2711
# Inputs          : 
-
 
2712
#
-
 
2713
# Returns         : 
-
 
2714
#
-
 
2715
sub LastBuildDirective
-
 
2716
{
-
 
2717
    $BUILDPHASE = 2;
-
 
2718
}
-
 
2719
 
-
 
2720
#-------------------------------------------------------------------------------
2496
# Function        : BuildPackageLink
2721
# Function        : BuildPackageLink
2497
#
2722
#
2498
# Description     : Create a soft link from sandbox_dpkg_archive to the package
2723
# Description     : Create a soft link from sandbox_dpkg_archive to the package
2499
#                   being created by this build
2724
#                   being created by this build
2500
#
2725
#
Line 2677... Line 2902...
2677
    #
2902
    #
2678
    $BUILDINTERFACE = "." unless ( $BUILDINTERFACE );
2903
    $BUILDINTERFACE = "." unless ( $BUILDINTERFACE );
2679
 
2904
 
2680
    #.. Starting the build phase. No more data collection
2905
    #.. Starting the build phase. No more data collection
2681
    #
2906
    #
2682
        StartBuildPhase();
2907
    StartBuildPhase();
-
 
2908
    LastBuildDirective();
2683
 
2909
 
2684
    sub DeleteCfg
2910
    sub DeleteCfg
2685
    {
2911
    {
2686
        #
2912
        #
2687
        #   Delete files that will be re-created
2913
        #   Delete files that will be re-created
Line 2803... Line 3029...
2803
    #
3029
    #
2804
    my @cmds = ('jmake.pl', 'rebuild');
3030
    my @cmds = ('jmake.pl', 'rebuild');
2805
    push @cmds, 'NORECURSE=1' if ( $RootOnly );
3031
    push @cmds, 'NORECURSE=1' if ( $RootOnly );
2806
 
3032
 
2807
    JatsTool ( @cmds);
3033
    JatsTool ( @cmds);
-
 
3034
 
-
 
3035
    #
-
 
3036
    #   Generate some warnings that will be seen at the end of the build
-
 
3037
    #
-
 
3038
    Warning ("BuildSrcArchive Directive Present","Read JATS Manual for correct usage")
-
 
3039
        if ($build_source_pkg);
2808
}
3040
}
2809
 
3041
 
2810
 
3042
 
2811
#-------------------------------------------------------------------------------
3043
#-------------------------------------------------------------------------------
2812
# Function        : BuildVersion
3044
# Function        : BuildVersion