Changeset 74 in ProjectBuilder for devel/pb/bin
- Timestamp:
- Sep 1, 2007, 1:56:48 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r73 r74 21 21 22 22 # Global variables 23 use vars qw (%defpkgdir %extpkgdir % version %confparam %filteredfiles %pbrc $debug $LOG $projectbuilderver $projectbuilderrev);23 use vars qw (%defpkgdir %extpkgdir %filteredfiles %pbrc $debug $LOG); 24 24 25 25 $debug = 0; # Debug level 26 26 $LOG = *STDOUT; # Where to log 27 27 use lib qw (lib); 28 use ProjectBuilder::common qw (env_init); 29 use ProjectBuilder::distro qw (distro_init); 30 use ProjectBuilder::cms; 31 use ProjectBuilder::changelog qw (changelog); 32 use ProjectBuilder::Version qw (version_init); 33 use ProjectBuilder::pb qw (pb_init); 28 use ProjectBuilder::Distribution qw (pb_distro_init); 29 use ProjectBuilder::Changelog qw (pb_changelog); 30 use ProjectBuilder::Version qw (pb_version_init); 31 use ProjectBuilder::Base qw (pb_conf_read pb_cms_init pb_mkdir_p pb_system pb_rm_rf); 34 32 35 33 my %opts; # CLI Options … … 46 44 getopts('hl:p:qr:tv',\%opts); 47 45 48 version_init();46 my ($projectbuilderver,$projectbuilderrev) = ("0.5","1"); #pb_version_init(); 49 47 if (defined $opts{'h'}) { 50 syntax();48 pb_syntax(); 51 49 exit(0); 52 50 } … … 71 69 # Get Action 72 70 $action = shift @ARGV; 73 die syntax() if (not defined $action);71 die pb_syntax() if (not defined $action); 74 72 75 73 # Handle root of the project if defined … … 79 77 # Handles project name if any 80 78 if (defined $opts{'p'}) { 81 $ENV{'PBPROJ'} = env_init($opts{'p'});79 $ENV{'PBPROJ'} = pb_env_init($opts{'p'}); 82 80 } else { 83 $ENV{'PBPROJ'} = env_init();81 $ENV{'PBPROJ'} = pb_env_init(); 84 82 } 85 83 … … 91 89 my $ptr = get_pkg(); 92 90 @pkgs = @$ptr; 93 cms_init();91 pb_cms_init($ENV{'PBPROJ'}); 94 92 95 93 foreach my $pbpkg (@pkgs) { … … 117 115 # Clean up dest if necessary. The export will recreate it 118 116 my $dest = "$ENV{'PBDESTDIR'}/$pbpkg-$pbver"; 119 pb rm_rf($dest) if (-d $dest);117 pb_rm_rf($dest) if (-d $dest); 120 118 121 119 # Export CMS tree for the concerned package to dest … … 126 124 my $dir = $defpkgdir{$pbpkg}; 127 125 $dir = $extpkgdir{$pbpkg} if (not defined $dir); 128 pb system("$ENV{'PBCMSEXP'} $option $ENV{'PBROOT'}/$dir $dest 1>/dev/null", "Exporting $ENV{'PBROOT'}/$dir");126 pb_system("$ENV{'PBCMSEXP'} $option $ENV{'PBROOT'}/$dir $dest 1>/dev/null", "Exporting $ENV{'PBROOT'}/$dir"); 129 127 130 128 # Creates a REVISION file … … 134 132 135 133 # Extract cms log history and store it 136 pb system("$ENV{'PBCMSLOG'} $option $ENV{'PBROOT'}/$dir > $dest/$ENV{'PBCMSLOGFILE'}", "Extracting log info");134 pb_system("$ENV{'PBCMSLOG'} $option $ENV{'PBROOT'}/$dir > $dest/$ENV{'PBCMSLOGFILE'}", "Extracting log info"); 137 135 138 136 my %build; … … 142 140 my ($ndir,$ver) = split(/_/,$d); 143 141 chomp($ver); 144 my ($ddir, $dver, $dfam, $dtype, $dsuf) = distro_init($ndir,$ver);142 my ($ddir, $dver, $dfam, $dtype, $dsuf) = pb_distro_init($ndir,$ver); 145 143 print $LOG "DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $dsuf)."\n" if ($debug >= 1); 146 144 print $LOG "DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n" if ($debug >= 1); … … 251 249 # Prepare the dest directory for archive 252 250 if (-x "$ENV{'PBCONF'}/$pbpkg/pbinit") { 253 pb system("cd $dest ; $ENV{'PBCONF'}/$pbpkg/pbinit","Executing init script $ENV{'PBCONF'}/$pbpkg/pbinit");251 pb_system("cd $dest ; $ENV{'PBCONF'}/$pbpkg/pbinit","Executing init script $ENV{'PBCONF'}/$pbpkg/pbinit"); 254 252 } 255 253 … … 257 255 chdir "$ENV{'PBDESTDIR'}" || die "Unable to change dir to $ENV{'PBDESTDIR'}"; 258 256 # Possibility to look at PBSRC to guess more the filename 259 pb system("tar cfpz $pbpkg-$pbver.tar.gz $pbpkg-$pbver","Creating $pbpkg tar files compressed");257 pb_system("tar cfpz $pbpkg-$pbver.tar.gz $pbpkg-$pbver","Creating $pbpkg tar files compressed"); 260 258 print $LOG "Under $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz\n" if ($debug >= 0); 261 259 # Keep track of what is generated for default … … 269 267 if (not defined $vertag) { 270 268 if (-f $pbrc{$ENV{'PBPROJ'}}) { 271 my $pbroot = pb_ init($pbrc{$ENV{'PBPROJ'}},"pbroot");269 my $pbroot = pb_conf_read($pbrc{$ENV{'PBPROJ'}},"pbroot"); 272 270 # There is only one line normaly 273 $vertag = (keys %$pbroot)[0] 274 $ENV{'PBROOT'} = (values %$pbroot)[0] 271 $vertag = (keys %$pbroot)[0]; 272 $ENV{'PBROOT'} = (values %$pbroot)[0]; 275 273 } else { 276 274 die "Unable to open $pbrc{$ENV{'PBPROJ'}}\nYou may want to precise as parameter version-tag"; … … 284 282 285 283 # Get the running distro to build on 286 my ($ddir, $dver, $dfam, $dtype, $dsuf) = distro_init();284 my ($ddir, $dver, $dfam, $dtype, $dsuf) = pb_distro_init(); 287 285 print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $dsuf))."\n" if ($debug >= 1); 288 286 … … 300 298 foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') { 301 299 if (! -d "$ENV{'PBBUILDDIR'}/$d") { 302 pb mkdir_p("$ENV{'PBBUILDDIR'}/$d") || die "Please ensure that you can write into $ENV{'PBBUILDDIR'} to create $d\nSolution: setup _topdir in your ~/.rpmmacros or\nchown the $ENV{'PBBUILDDIR'} directory to your uid";300 pb_mkdir_p("$ENV{'PBBUILDDIR'}/$d") || die "Please ensure that you can write into $ENV{'PBBUILDDIR'} to create $d\nSolution: setup _topdir in your ~/.rpmmacros or\nchown the $ENV{'PBBUILDDIR'} directory to your uid"; 303 301 } 304 302 } … … 315 313 foreach my $f (@specfile) { 316 314 if ($f =~ /\.spec$/) { 317 pb system("rpmbuild -ba $f","Building package with $f");315 pb_system("rpmbuild -ba $f","Building package with $f"); 318 316 last; 319 317 } 320 318 } 321 319 } elsif ($dtype eq "tgz") { 322 pb mkdir_p("$ENV{'PBBUILDDIR'}/install") if (! -d "$ENV{'PBBUILDDIR'}/install");320 pb_mkdir_p("$ENV{'PBBUILDDIR'}/install") if (! -d "$ENV{'PBBUILDDIR'}/install"); 323 321 } elsif ($dtype eq "ebuild") { 324 pb mkdir_p("$ENV{'PBBUILDDIR'}/portage") if (! -d "$ENV{'PBBUILDDIR'}/portage");322 pb_mkdir_p("$ENV{'PBBUILDDIR'}/portage") if (! -d "$ENV{'PBBUILDDIR'}/portage"); 325 323 } else { 326 324 } … … 328 326 } else { 329 327 print $LOG "'$action' is not available\n"; 330 syntax();328 pb_syntax(); 331 329 } 332 330 … … 343 341 344 342 print $LOG "DEBUG: From $f to $destfile\n" if ($debug >= 1); 345 pb mkdir_p(dirname($destfile)) if (! -d dirname($destfile));343 pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile)); 346 344 open(DEST,"> $destfile") || die "Unable to create $destfile"; 347 345 open(FILE,"$f") || die "Unable to open $f: $!"; … … 360 358 my $p = $defpkgdir{$pbpkg}; 361 359 $p = $extpkgdir{$pbpkg} if (not defined $p); 362 changelog($dtype, $pbpkg, $pbtag, $dsuf, $p, \*DEST);360 pb_changelog($dtype, $pbpkg, $pbtag, $dsuf, $p, \*DEST); 363 361 $tmp = ""; 364 362 } … … 400 398 my @files; 401 399 402 pb system("tar xfpz $src $dir >/dev/null","Extracting build files");400 pb_system("tar xfpz $src $dir >/dev/null","Extracting build files"); 403 401 opendir(DIR,"$dir") || die "Unable to open directory $dir"; 404 402 foreach my $f (readdir(DIR)) { … … 410 408 closedir(DIR); 411 409 # Not enough but still a first cleanup 412 pb rm_rf("$dir");410 pb_rm_rf("$dir"); 413 411 return(@files); 414 412 } 415 413 416 sub syntax {414 sub pb_syntax { 417 415 418 416 print "pb (aka project-builder) Version $projectbuilderver-$projectbuilderrev\n";
Note:
See TracChangeset
for help on using the changeset viewer.