Subversion Repositories DevTools

Rev

Rev 243 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 243 Rev 245
Line 24... Line 24...
24
use strict;
24
use strict;
25
use warnings;
25
use warnings;
26
use JatsError;
26
use JatsError;
27
use JatsSystem;
27
use JatsSystem;
28
use FileUtils;
28
use FileUtils;
-
 
29
use JatsBuildFiles;
-
 
30
use ArrayHashUtils;
29
 
31
 
30
use Pod::Usage;                             # required for help support
32
use Pod::Usage;                             # required for help support
31
use Getopt::Long;
33
use Getopt::Long;
32
use File::Find;
34
use File::Find;
33
use File::Copy;
35
use File::Copy;
Line 416... Line 418...
416
        (my $vob_name = $vob) =~ s~/~$VOB_SEP~g;
418
        (my $vob_name = $vob) =~ s~/~$VOB_SEP~g;
417
 
419
 
418
        Verbose2 ("Examine label $spec in vob: $vob" );
420
        Verbose2 ("Examine label $spec in vob: $vob" );
419
 
421
 
420
        my $cmd = ClearToolCmd ('lstype', "lbtype:$spec\@$vob_name");
422
        my $cmd = ClearToolCmd ('lstype', "lbtype:$spec\@$vob_name");
-
 
423
        my $cmd_done = 0;
421
        open(CMD, "$cmd 2>&1 |") || Error( "can't run command: $!");
424
        open(CMD, "$cmd 2>&1 |") || Error( "can't run command: $!");
422
        while (<CMD>)
425
        while (<CMD>)
423
        {
426
        {
424
            #
427
            #
425
            #   Filter output from the user
428
            #   Filter output from the user
-
 
429
            #   Stay in loop to avoid Broken Pipe message
426
            #
430
            #
427
            chomp;
431
            chomp;
428
            Verbose2("lstype: $_");
432
            Verbose2("lstype: $_");
-
 
433
            next if ( $cmd_done );
429
            next if ( m~Error~ );
434
            next if ( m~Error~ );
430
            next unless ( m~label type~ );
435
            next unless ( m~label type~ );
431
            push @label_not_locked, $spec unless( m~\(locked\)~ );
436
            push @label_not_locked, $spec unless( m~\(locked\)~ );
432
            $label_count++;
437
            $label_count++;
433
            $found = $vob;
438
            $found = $vob;
434
            last;
439
            $cmd_done = 1;
435
        }
440
        }
436
        close(CMD);
441
        close(CMD);
437
        last if ( $found );
442
        last if ( $found );
438
    }
443
    }
439
 
444
 
Line 555... Line 560...
555
#   Locate the JATS build files within the populated view
560
#   Locate the JATS build files within the populated view
556
#
561
#
557
chdir ($VIEWDIR) or Error( "Cannot chdir to $VIEWDIR");
562
chdir ($VIEWDIR) or Error( "Cannot chdir to $VIEWDIR");
558
Message( "Locating build files");
563
Message( "Locating build files");
559
 
564
 
560
my @build_list = locate_build_files( "$VIEWDIR$ROOT_VOB" );
565
my $bscanner = BuildFileScanner( "$VIEWDIR$ROOT_VOB", 'build.pl', '--LocateAll' );
-
 
566
$bscanner->scan();
-
 
567
my @build_list = $bscanner->getInfo();
561
foreach my $fe ( @build_list )
568
foreach my $be ( @build_list )
562
{
569
{
563
    Message( DisplayPath ("Build file: $fe->[0] Name: $fe->[1]"));
570
    Message( DisplayPath ("Build file: $be->{dir} Name: $be->{file}"));
564
}
571
}
565
 
572
 
566
#
573
#
567
#   If we are extracting the view then we are done
574
#   If we are extracting the view then we are done
568
#   Display useful information for the user
575
#   Display useful information for the user
Line 583... Line 590...
583
 
590
 
584
#
591
#
585
#   Determine the list of builds to perform
592
#   Determine the list of builds to perform
586
#   Ensure that the user-requested build files are present
593
#   Ensure that the user-requested build files are present
587
#
594
#
-
 
595
#   The user specifies the build file, via the mangled package name
-
 
596
#   This is package_name . project extension (daf_utils.cr)
-
 
597
#
588
if ( $#opt_build  >= 0)
598
if ( $#opt_build  >= 0)
589
{
599
{
590
    Verbose( "Check and locate the build files");
600
    Verbose( "Check and locate the build files");
591
    my @blist = ();
601
    my @build_list = ();
592
    foreach my $bentry ( @opt_build )
602
    foreach my $bentry ( @opt_build )
593
    {
603
    {
594
        my @fnd;
-
 
595
        foreach my $entry ( @build_list )
604
        if ($bscanner->match( $bentry) )
596
        {
605
        {
597
            next if ( $entry->[2] );
606
            UniquePush (\@build_list, $bscanner->getMatchList() );
598
 
-
 
599
            if ( $entry->[0] =~ m~/$bentry$~ )
607
            Verbose ("Found: $bentry");
600
            {
608
        }
601
                push @fnd, $entry;
-
 
602
                $entry->[2] = 1;
-
 
603
                next;
-
 
604
            }
609
        else
605
 
-
 
606
            if ( $entry->[1] eq $bentry )
-
 
607
            {
610
        {
608
                $entry->[2] = 1;
-
 
609
                push @fnd, $entry;
611
            Error ("Cannot locate requested build files for: $bentry")
610
            }
-
 
611
        }
612
        }
612
 
-
 
613
        Error ("Cannot locate requested build file/directory: $bentry")
-
 
614
           unless( @fnd  );
-
 
615
        Verbose ("Found: $bentry as @fnd");
-
 
616
        push @blist, @fnd;
-
 
617
    }
613
    }
618
    @build_list = @blist;
-
 
619
}
614
}
620
 
615
 
621
#
616
#
622
#   Sanity test if we will transfer the generated package to dpkg_archive
617
#   Sanity test if we will transfer the generated package to dpkg_archive
623
#   There are some limits
618
#   There are some limits
Line 647... Line 642...
647
Warning ("Beta Release") if $opt_beta;
642
Warning ("Beta Release") if $opt_beta;
648
 
643
 
649
#
644
#
650
#   Process each of the build files in the specified order
645
#   Process each of the build files in the specified order
651
#
646
#
652
foreach my $fe (@build_list)
647
foreach my $be (@build_list)
653
{
648
{
654
    my $build_dir = $fe->[0];
-
 
655
 
649
 
656
    #
650
    #
657
    #   We need to change to the build directory
651
    #   We need to change to the build directory
658
    #   Moreover we need the local name of the build directory.
652
    #   Moreover we need the local name of the build directory.
659
    #   Windows does not handle a UNC pathname to well (at all)
653
    #   Windows does not handle a UNC pathname to well (at all)
660
    #
654
    #
-
 
655
    my $build_dir = $be->{dir};
661
    chdir ("$build_dir") or Error( "Cannot chdir to build directory: $build_dir");
656
    chdir ("$build_dir") or Error( "Cannot chdir to build directory: $build_dir");
662
 
657
 
663
    if ( $fe->[1] =~ m/^build.pl$/ )
658
    if ( $be->{file} =~ m/^build.pl$/ )
664
    {
659
    {
665
        Message ("Using JATS: $build_dir");
660
        Message ("Using JATS: $build_dir");
666
        #
661
        #
667
        #   Invoke JATS to build the package and make the package
662
        #   Invoke JATS to build the package and make the package
668
        #
663
        #
Line 686... Line 681...
686
    else
681
    else
687
    {
682
    {
688
        #
683
        #
689
        #   Ant build files
684
        #   Ant build files
690
        #
685
        #
691
        my $pname =  $fe->[1];
686
        my $pname =  $be->{file};
692
        Message ("Using ANT: $build_dir, $pname");
687
        Message ("Using ANT: $build_dir, $pname");
693
        $pname =~ s~depends.xml$~.xml~;
688
        $pname =~ s~depends.xml$~.xml~;
694
        copy($fe->[1], "auto.xml");
689
        copy($be->{file}, "auto.xml");
695
        JatsCmd("-buildfile $pname ant build")        and Error("Package did not build");
690
        JatsCmd("-buildfile $pname ant build")        and Error("Package did not build");
696
        JatsCmd("-buildfile $pname ant make_package") and Error("Package did not make_package");
691
        JatsCmd("-buildfile $pname ant make_package") and Error("Package did not make_package");
697
    }
692
    }
698
}
693
}
699
 
694
 
700
#
695
#
701
#   Copy the generated packages
696
#   Copy the generated packages
702
#       1) dpkg_archive
697
#       1) dpkg_archive
703
#       2) Users local directory
698
#       2) Users local directory
704
#
699
#
705
foreach my $fe (@build_list)
700
foreach my $be (@build_list)
706
{
701
{
707
    my $build_dir = $fe->[0];
702
    my $build_dir = $be->{dir};
708
    chdir ("$build_dir") or Error( "Cannot chdir to build directory: $build_dir");
703
    chdir ("$build_dir") or Error( "Cannot chdir to build directory: $build_dir");
709
    if ( $opt_dpkg )
704
    if ( $opt_dpkg )
710
    {
705
    {
711
        Message ("Using: $build_dir");
706
        Message ("Using: $build_dir");
712
        my $create_opts = "-o";
707
        my $create_opts = "-o";
Line 721... Line 716...
721
    }
716
    }
722
 
717
 
723
    #
718
    #
724
    #   Test structure of the package
719
    #   Test structure of the package
725
    #   Ensure that it has a descpkg file
720
    #   Ensure that it has a descpkg file
726
    #   Would be nice to test package name and version ... if we could get them
721
    #   Validate the package name and version
727
    #   More important for ANT projects than JATS as JATS has a sanity test
722
    #   More important for ANT projects than JATS as JATS has a sanity test
728
    #
723
    #
729
    if ( $opt_test )
724
    if ( $opt_test )
730
    {
725
    {
731
        JatsCmd("-here create_dpkg -test") and $error++;
726
        JatsCmd("-here create_dpkg -test -pname=$be->{name} -pversion=$be->{version}") and $error++;
732
    }
727
    }
733
 
728
 
734
}
729
}
735
Error ("Package not transferred")
730
Error ("Package not transferred")
736
    if ( $error );
731
    if ( $error );
Line 857... Line 852...
857
    Error ("View was not deleted")
852
    Error ("View was not deleted")
858
        if ( -d $VIEWDIR );
853
        if ( -d $VIEWDIR );
859
}
854
}
860
 
855
 
861
#-------------------------------------------------------------------------------
856
#-------------------------------------------------------------------------------
862
# Function        : locate_build_files
-
 
863
#
-
 
864
# Description     : Locate all potential buildfiles in the view
-
 
865
#
-
 
866
# Inputs          : base_dir     - Start directory
-
 
867
#
-
 
868
# Returns         : An array of build files
-
 
869
#                   Each entry in the array conatins
-
 
870
#                       Directory
-
 
871
#                       Filename
-
 
872
#
-
 
873
my @located_files;
-
 
874
my $locate_files_base;
-
 
875
sub locate_build_files
-
 
876
{
-
 
877
    my ( $base_dir) = @_;
-
 
878
 
-
 
879
    #
-
 
880
    #   Locate build files ( JATS and ANT )
-
 
881
    #
-
 
882
    sub locate_build_files_wanted
-
 
883
    {
-
 
884
 
-
 
885
        my $dir = "$File::Find::dir";
-
 
886
        my $file = $_;
-
 
887
        my $arg = "$dir/$file";
-
 
888
 
-
 
889
        return if ( -d $arg );
-
 
890
 
-
 
891
        #
-
 
892
        #   Detect a JATS build file
-
 
893
        #
-
 
894
        if ( $file eq "build.pl"  )
-
 
895
        {
-
 
896
            push @located_files, [ $dir, $file ];
-
 
897
            return;
-
 
898
        }
-
 
899
 
-
 
900
        #
-
 
901
        #   Detect ANT {packagename}depends.xml file
-
 
902
        #
-
 
903
        if ( $file =~ m/(.+)depends.xml$/ )
-
 
904
        {
-
 
905
            if ( -f $1 . ".xml" )
-
 
906
            {
-
 
907
                push @located_files, [ $dir, $file ];
-
 
908
                return;
-
 
909
            }
-
 
910
        }
-
 
911
    }
-
 
912
 
-
 
913
    @located_files = ();
-
 
914
    $locate_files_base = $base_dir;
-
 
915
    File::Find::find ( \&locate_build_files_wanted, $base_dir );
-
 
916
    return @located_files;
-
 
917
}
-
 
918
 
-
 
919
 
-
 
920
#-------------------------------------------------------------------------------
-
 
921
# Function        : copy_directory
857
# Function        : copy_directory
922
#
858
#
923
# Description     : Copy a directory tree
859
# Description     : Copy a directory tree
924
#
860
#
925
# Inputs          : Source directory
861
# Inputs          : Source directory
Line 1324... Line 1260...
1324
    -label=xxx         - Clearcase label
1260
    -label=xxx         - Clearcase label
1325
    -spec=xxx          - Same as -label=xxx
1261
    -spec=xxx          - Same as -label=xxx
1326
    -path=xxx          - Source Path
1262
    -path=xxx          - Source Path
1327
    -view=xxx          - Modify the name of the created view
1263
    -view=xxx          - Modify the name of the created view
1328
    -vob=vobname       - VOB name
1264
    -vob=vobname       - VOB name
1329
    -build=xxx         - Location of build file
1265
    -build=xxx         - Package Name to build
1330
    -root=xxx          - Root directory for generated view
1266
    -root=xxx          - Root directory for generated view
1331
    -latestroot=xxx    - Use the LATEST rootlevel directory 'xxx'
1267
    -latestroot=xxx    - Use the LATEST rootlevel directory 'xxx'
1332
    -[mk]branch=xxx    - Will create a view with a branch rule
1268
    -[mk]branch=xxx    - Will create a view with a branch rule
1333
    -config=xxx        - Create a view with the provided config spec
1269
    -config=xxx        - Create a view with the provided config spec
1334
    -tag=xxx           - Alternate tag used with in the ViewTag
1270
    -tag=xxx           - Alternate tag used with in the ViewTag
Line 1414... Line 1350...
1414
 
1350
 
1415
By default this utility will examine all the VOBs for the label.
1351
By default this utility will examine all the VOBs for the label.
1416
 
1352
 
1417
=item B<-build=xxx>
1353
=item B<-build=xxx>
1418
 
1354
 
1419
This option allows the location of the build file to be specified.
1355
This option allows the user to specify the packages to be built and the
-
 
1356
order in which the packages are to be built.
1420
This is useful if the extracted view contains multiple build files
1357
This is useful if the extracted view contains multiple build files
1421
 
1358
 
1422
This option may be used multiple times. Each specified build directory will be
1359
This option may be used multiple times.
-
 
1360
 
1423
built in the order in which they were specified.
1361
There are two forms in which the build target can be specified. It can be
-
 
1362
specified as a full package name and vesrion, or as a package name and the
-
 
1363
project suffix.
1424
 
1364
 
1425
By default the program will assume that there is only one build file in the
1365
By default the program will assume that there is only one build file in the
1426
view and will not build if multiple files are present.
1366
view and will not build if multiple files are present, unless the package to be
-
 
1367
built can be resolved.
1427
 
1368
 
1428
Example (JATS): -build=jats-api -build=jats-lib
1369
The location mechanism operates for both JATS and ANT build files.
1429
 
1370
 
1430
This will located the build file .../jats-api/build.pl and .../jats-lib/build.pl.
1371
Example: -build=jats-api.1.0.0000.cr
1431
 
1372
 
-
 
1373
This will locate the build file that builds version 1.0.0000.cr of the jats-api
1432
Example (ANT): -build pkgdepends.xml
1374
package. The version numbers must match exactly.
1433
 
1375
 
1434
This will located the build file pkgdepends.xml, but not pkg-apidepend.xml
1376
Example: -build=jats-api.cr -build=jats-lib.cr
1435
 
1377
 
-
 
1378
This will located the build files that build the jats_api (cr) package and the
-
 
1379
jats-lib (cr) package. The version of the packages will not be considered.
1436
 
1380
 
1437
=item B<-root=xxx>
1381
=item B<-root=xxx>
1438
 
1382
 
1439
This option allows the location of the generated view to be specified on the
1383
This option allows the location of the generated view to be specified on the
1440
command line. The environment variable GBE_VIEWBASE provides the same feature,
1384
command line. The environment variable GBE_VIEWBASE provides the same feature,