Changeset 21 in ProjectBuilder for devel/pb/bin
- Timestamp:
- Jul 31, 2007, 11:52:24 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb.pl
r20 r21 21 21 use POSIX qw(strftime); 22 22 23 use vars qw (%defpkgdir %extpkgdir %version %confparam %filteredfiles );23 use vars qw (%defpkgdir %extpkgdir %version %confparam %filteredfiles $debug); 24 24 %extpkgdir = (); 25 25 %filteredfiles = (); 26 $debug = 0; # Debug level 26 27 use lib qw (lib); 27 28 use common qw (env_init); … … 42 43 my $pbdate = strftime("%Y-%m-%d", @date); 43 44 44 getopts('p:t',\%opts); 45 45 getopts('hp:qtv',\%opts); 46 47 if (defined $opts{'h'}) { 48 syntax(); 49 exit(0); 50 } 51 if (defined $opts{'v'}) { 52 $debug++; 53 } 54 if (defined $opts{'q'}) { 55 $debug=-1; 56 } 46 57 # Handles project name if any 47 58 if (defined $opts{'p'}) { … … 59 70 # Get Action 60 71 $action = shift @ARGV; 61 die "Syntax: pb [-p project] <action> [<params>...]"if (not defined $action);62 63 print "Project $ENV{'PBPROJ'}\n" ;64 #print "Action: $action - ARGV:".Dumper(\@ARGV);72 die syntax() if (not defined $action); 73 74 print "Project $ENV{'PBPROJ'}\n" if ($debug >= 0); 75 print "Action: $action\n" if ($debug >= 0); 65 76 66 77 # Act depending on action 67 78 if ($action =~ /^cms2build$/) { 68 print "Action: cms2build\n";69 79 # Get packages list 70 80 if (not defined $ARGV[0]) { … … 81 91 @pkgs = @ARGV; 82 92 } 83 print "Packages:\n"; 84 print Dumper(@pkgs); 93 print "Packages: ".join(',',@pkgs)."\n" if ($debug >= 0); 85 94 cms_init(); 86 95 … … 105 114 } 106 115 $pbrev = $ENV{'PBREVISION'}; 107 print "Management of $pkg $pbver-$pbtag (rev $pbrev)\n"; 116 print "\n" if ($debug >= 0); 117 print "Management of $pkg $pbver-$pbtag (rev $pbrev)\n" if ($debug >= 0); 108 118 die "Unable to get env var PBDESTDIR" if (not defined $ENV{'PBDESTDIR'}); 109 119 # Clean up dest if necessary. The export will recreate it … … 114 124 # And generate some additional files 115 125 $OUTPUT_AUTOFLUSH=1; 116 print "$ENV{'PBCMSEXP'} of $pkg..." ;126 print "$ENV{'PBCMSEXP'} of $pkg..." if ($debug >= 0); 117 127 # computes in which dir we have to work 118 128 my $dir = $defpkgdir{$pkg}; … … 120 130 system("$ENV{'PBCMSEXP'} $option $ENV{'PBROOT'}/$dir $dest 1>/dev/null"); 121 131 if ($? == -1) { 122 print "failed to execute: $!\n" ;132 print "failed to execute: $!\n" if ($debug >= 0); 123 133 } elsif ($? & 127) { 124 printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without' ;125 } else { 126 print " Done under $dest\n";134 printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without' if ($debug >= 0); 135 } else { 136 print " OK\n" if ($debug >= 0); 127 137 } 128 138 … … 134 144 # Extract cms log history and store it 135 145 system("$ENV{'PBCMSLOG'} $option $ENV{'PBROOT'}/$dir > $dest/$ENV{'PBCMSLOGFILE'}"); 136 print "$ENV{'PBCMSLOG'} of $pkg..." ;146 print "$ENV{'PBCMSLOG'} of $pkg..." if ($debug >= 0); 137 147 if ($? == -1) { 138 print "failed to execute: $!\n" ;148 print "failed to execute: $!\n" if ($debug >= 0); 139 149 } elsif ($? & 127) { 140 printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; 141 } else { 142 print " OK\n"; 143 } 150 printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without' if ($debug >= 0); 151 } else { 152 print " OK\n" if ($debug >= 0); 153 } 154 my %build; 144 155 open(D,"$ENV{'PBCONF'}/DISTROS") || die "Unable to find $ENV{'PBCONF'}/DISTROS\n"; 145 156 while (<D>) { … … 147 158 my ($dir,$ver) = split(/_/,$d); 148 159 chomp($ver); 149 print "Generating build files for $dir ($ver)\n";150 160 my ($ddir, $dver, $dfam, $dtype, $dsuf) = distro_init($dir,$ver); 151 #print Dumper($ddir, $dver, $dfam, $dtype, $dsuf);152 #print "Filtering DDD => $pbdate, TTT => $pbtag, RRR => $pbtag$dsuf, VVV => $pbver\n";161 print "DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $dsuf)."\n" if ($debug >= 1); 162 print "DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n" if ($debug >= 1); 153 163 154 164 # Filter build files from the less precise up to the most with overloading … … 157 167 # Find all build files first relatively to PBROOT 158 168 my %bfiles; 159 #print "dir: $ENV{'PBCONF'}/$pkg\n"; 169 print "DEBUG dir: $ENV{'PBCONF'}/$pkg\n" if ($debug >= 1); 170 $build{"$ddir-$dver"} = "yes"; 160 171 if (-d "$ENV{'PBCONF'}/$pkg/$dtype") { 161 172 opendir(BDIR,"$ENV{'PBCONF'}/$pkg/$dtype" || die "Unable to open dir $ENV{'PBCONF'}/$pkg/$dtype: $!"); … … 191 202 closedir(BDIR); 192 203 } else { 193 print "No Build Files found for $ddir-$dver\n";204 $build{"$ddir-$dver"} = "no"; 194 205 next; 195 206 } 196 print " bfiles: ".Dumper(\%bfiles)."\n";207 print "DEBUG bfiles: ".Dumper(\%bfiles)."\n" if ($debug >= 1); 197 208 198 209 # Get all filters to apply … … 222 233 my $ptr; 223 234 if (@ffiles) { 224 print " ffiles: ".Dumper(\@ffiles)."\n";235 print "DEBUG ffiles: ".Dumper(\@ffiles)."\n" if ($debug >= 1); 225 236 $config->file(@ffiles); 226 237 $ptr = $config->get("filter"); 227 print " f:".Dumper($ptr)."\n";238 print "DEBUG f:".Dumper($ptr)."\n" if ($debug >= 1); 228 239 } else { 229 240 $ptr = { }; … … 242 253 } 243 254 } 255 if ($debug >= 0) { 256 my @found; 257 my @notfound; 258 foreach my $b (keys %build) { 259 push @found,$b if ($build{$b} =~ /yes/); 260 push @notfound,$b if ($build{$b} =~ /no/); 261 } 262 print "Build files generated for ".join(',',@found)."\n"; 263 print "No Build files found for ".join(',',@notfound)."\n"; 264 } 244 265 close(D); 245 266 # Prepare the dest directory for archive … … 247 268 system("cd $dest ; $ENV{'PBCONF'}/$pkg/pbinit"); 248 269 if ($? == -1) { 249 print "failed to execute: $!\n" ;270 print "failed to execute: $!\n" if ($debug >= 0); 250 271 } elsif ($? & 127) { 251 printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without' ;272 printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without' if ($debug >= 0); 252 273 } else { 253 print " $dest\n" ;274 print " $dest\n" if ($debug >= 0); 254 275 } 255 276 } 256 277 # Archive dest dir 257 278 chdir "$dest/.."; 258 print "Creating $pkg tar files (gzip... " ;279 print "Creating $pkg tar files (gzip... " if ($debug >= 0); 259 280 system("tar cfphz $pkg-$pbver.tar.gz $pkg-$pbver"); 260 281 if ($? == -1) { 261 print "failed to execute: $!\n" ;282 print "failed to execute: $!\n" if ($debug >= 0); 262 283 } elsif ($? & 127) { 263 printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without' ;264 } else { 265 print " OK)\n" ;266 print "Under $dest/../$pkg-$pbver.tar.gz\n" ;284 printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without' if ($debug >= 0); 285 } else { 286 print " OK)\n" if ($debug >= 0); 287 print "Under $dest/../$pkg-$pbver.tar.gz\n" if ($debug >= 0); 267 288 } 268 289 } 269 290 } else { 270 291 print "'$action' is not available\n"; 271 print "Available actions are:\n"; 272 print " cms2build\n"; 292 syntax(); 273 293 } 274 294 … … 284 304 my $dsuf=shift; 285 305 286 print " From $f to $destfile\n";306 print "DEBUG: From $f to $destfile\n" if ($debug >= 1); 287 307 pbmkdir_p(dirname($destfile)) if (! -d dirname($destfile)); 288 308 open(DEST,"> $destfile") || die "Unable to create $destfile"; … … 292 312 foreach my $s (keys %filter) { 293 313 # Process single variables 294 #print "debug: $filter{$s}\n";314 print "DEBUG filter{$s}: $filter{$s}\n" if ($debug > 1); 295 315 my $tmp = $filter{$s}; 296 316 next if (not defined $tmp); … … 312 332 close(DEST); 313 333 } 334 335 sub syntax { 336 337 print "Syntax: pb [-vhqt][-p project] <action> [<params>...]\n"; 338 print "\n"; 339 print "-h : This help file\n"; 340 print "-q : Quiet mode\n"; 341 print "-t : Test mode (not done yet)\n"; 342 print "-v : Verbose mode\n"; 343 print "\n"; 344 print "-p project : Name of the project you're working on\n"; 345 print " (or use the env variable PBPROJ) \n"; 346 print "\n"; 347 print "<action> can be:\n"; 348 print "\n"; 349 print "\tcms2build: Create a tar file of the project under your CMS\n"; 350 print "\t CMS supported are SVN and CVS\n"; 351 print "\n"; 352 print "\tbuild2pkg: Create packages for your running distribution \n"; 353 print "\n"; 354 print "\n"; 355 }
Note:
See TracChangeset
for help on using the changeset viewer.