Changeset 9 in ProjectBuilder for devel/pb/bin
- Timestamp:
- Jul 30, 2007, 1:22:32 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb.pl
r8 r9 8 8 # Provided under the GPL v2 9 9 10 # Syntax: pb [-p project] <action> [<params>...] 11 10 12 use strict; 11 13 use Switch; 12 14 use Getopt::Std; 15 use Data::Dumper; 16 use English; 13 17 14 18 use lib qw (lib etc); 15 19 use vars qw (%defpkgdir %extpkgdir %version); 16 use common qw ( set_env);20 use common qw (env_init); 17 21 use pb qw (defpkgdir extpkgdir version pb_init); 18 22 use cms; 19 23 20 24 my %opts; # CLI Options 25 my $action; # action to realize 26 my $test = "FALSE"; 27 my $option = ""; 28 my @pkgs; 21 29 22 getopts('p: ',\%opts);30 getopts('p:t',\%opts); 23 31 24 32 # Handles project name if any 25 33 if (defined $opts{'p'}) { 26 $ENV{'PBPROJ'} = set_env($opts{'p'});34 $ENV{'PBPROJ'} = env_init($opts{'p'}); 27 35 } else { 28 $ENV{'PBPROJ'} = set_env(); 36 $ENV{'PBPROJ'} = env_init(); 37 } 38 # Handles test option 39 if (defined $opts{'t'}) { 40 $test = "TRUE"; 41 # Works only for SVN 42 $option = "-r BASE"; 29 43 } 30 44 31 print "PBPROJ: $ENV{'PBPROJ'}\n"; 45 # Get Action 46 $action = shift @ARGV; 47 die "Syntax: pb [-p project] <action> [<params>...]" if (not defined $action); 32 48 33 cms_init(); 49 print "Project $ENV{'PBPROJ'}\n"; 50 #print "Action: $action - ARGV:".Dumper(\@ARGV); 51 52 # Act depending on action 53 if ($action =~ /^cms2build$/) { 54 print "Action: cms2build\n"; 55 # Get packages list 56 if (not defined $ARGV[0]) { 57 @pkgs = keys %defpkgdir; 58 } elsif ($ARGV[0] =~ /^all$/) { 59 @pkgs = keys %defpkgdir; 60 push(@pkgs, keys %extpkgdir); 61 } else { 62 @pkgs = @ARGV; 63 } 64 print "Packages:\n"; 65 print Dumper(@pkgs); 66 cms_init(); 67 68 foreach my $p (@pkgs) { 69 70 my $v; 71 72 if (-f "$ENV{'PBROOT'}/$p/VERSION") { 73 open(V,"$ENV{'PBROOT'}/$p/VERSION") || die "Unable to open $ENV{'PBROOT'}/$p/VERSION"; 74 $v = <V>; 75 chomp($v); 76 close(V); 77 } else { 78 $v = $ENV{'PBVER'}; 79 } 80 81 my $tag; 82 83 if (-f "$ENV{'PBROOT'}/$p/TAG") { 84 open(T,"$ENV{'PBROOT'}/$p/TAG") || die "Unable to open $ENV{'PBROOT'}/$p/TAG"; 85 $tag = <T>; 86 chomp($tag); 87 close(T); 88 } else { 89 $tag = $ENV{'PBTAG'}; 90 } 91 print "Management of $p $v-$tag (rev $ENV{'PBREVISION'})\n"; 92 die "Unable to get env var PBDESTDIR" if (not defined $ENV{'PBDESTDIR'}); 93 # Clean up dest if necessary 94 my $dest = "$ENV{'PBDESTDIR'}/$p-$v"; 95 pbrm_rf($dest) if (-d $dest); 96 97 # Export CMS tree for the concerned package to dest 98 # And generate some additional files 99 $OUTPUT_AUTOFLUSH=1; 100 print "$ENV{'PBCMSEXP'} of $p..."; 101 # computes in which dir we have to work 102 my $dir = $defpkgdir{$p}; 103 $dir = $extpkgdir{$p} if (not defined $dir); 104 system("$ENV{'PBCMSEXP'} $option $ENV{'PBROOT'}/$dir $dest 1>/dev/null"); 105 if ($? == -1) { 106 print "failed to execute: $!\n"; 107 } elsif ($? & 127) { 108 printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; 109 } else { 110 print " Done under $dest\n"; 111 } 112 113 # Creates a REVISION file 114 open(R,"> $dest/REVISION") || die "Unable to create $dest/REVISION"; 115 print R "$ENV{'PBREVISION'}\n"; 116 close(R); 117 118 # Extract cms log history and store it 119 system("$ENV{'PBCMSLOG'} $option $ENV{'PBROOT'}/$dir > $dest/$ENV{'PBCMSLOGFILE'}"); 120 print "$ENV{'PBCMSLOG'} of $p..."; 121 if ($? == -1) { 122 print "failed to execute: $!\n"; 123 } elsif ($? & 127) { 124 printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; 125 } else { 126 print " OK\n"; 127 } 128 } 129 } else { 130 print "'$action' is not available\n"; 131 print "Available actions are:\n"; 132 print " cms2build\n"; 133 }
Note:
See TracChangeset
for help on using the changeset viewer.