Changeset 315 in ProjectBuilder for devel/pb/bin/pb
- Timestamp:
- Feb 10, 2008, 6:40:37 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r314 r315 23 23 use ProjectBuilder::Distribution qw (pb_distro_init); 24 24 use ProjectBuilder::Version qw (pb_version_init); 25 use ProjectBuilder::Base qw (pb_conf_read pb_conf_get pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_ cms_export pb_cms_log pb_cms_isdiff pb_cms_copy pb_cms_checkout);25 use ProjectBuilder::Base qw (pb_conf_read pb_conf_get pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_filter_file_inplace pb_cms_export pb_cms_log pb_cms_isdiff pb_cms_copy pb_cms_checkout pb_get_date pb_log pb_log_init); 26 26 27 27 my %opts; # CLI Options … … 36 36 my %pbtag; # per package 37 37 my $pbrev; # Global REVISION variable 38 my @date= (localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());38 my @date=pb_get_date(); 39 39 my $pbdate = strftime("%Y-%m-%d", @date); 40 my $pbdatecvs = strftime("%Y-%m-%d %H:%M:%S", @date);41 40 my $debug = 0; 42 41 my $pbaccount; # Login to use to connect to the VM … … 64 63 $debug = 0 if ($debug == -1); 65 64 } 65 pb_log_init($debug, $LOG); 66 66 67 # Handles test option 67 68 if (defined $opts{'t'}) { … … 106 107 # And get global params 107 108 if (defined $opts{'p'}) { 108 ($ debug,$LOG, $filteredfiles, $supfiles, $defpkgdir, $extpkgdir)109 ($filteredfiles, $supfiles, $defpkgdir, $extpkgdir) 109 110 = pb_env_init($opts{'p'},$pbinit); 110 111 } else { 111 ($ debug,$LOG, $filteredfiles, $supfiles, $defpkgdir, $extpkgdir)112 ($filteredfiles, $supfiles, $defpkgdir, $extpkgdir) 112 113 = pb_env_init(undef,$pbinit); 113 114 } 114 115 115 p rint $LOG "Project: $ENV{'PBPROJ'}\n" if ($debug >= 0);116 p rint $LOG "Action: $action\n" if ($debug >= 0);116 pb_log(0,"Project: $ENV{'PBPROJ'}\n"); 117 pb_log(0,"Action: $action\n"); 117 118 118 119 # Keep those project values to store them at the end each time … … 154 155 } elsif ($action =~ /^clean$/) { 155 156 } else { 156 p rint $LOG "'$action' is not available\n";157 pb_log(0,"\'$action\' is not available\n"); 157 158 pb_syntax(); 158 159 } … … 162 163 my $ptr = pb_get_pkg($defpkgdir,$extpkgdir); 163 164 @pkgs = @$ptr; 164 my $cms=pb_cms_init($ENV{'PBPROJ'});165 my ($scheme,$uri)=pb_cms_init($ENV{'PBPROJ'}); 165 166 166 167 my ($pkgv, $pkgt) = pb_conf_get_if("pkgver","pkgtag"); … … 188 189 189 190 $pbrev = $ENV{'PBREVISION'}; 190 p rint $LOG "\n";191 p rint $LOG "Management of $pbpkg $pbver-$pbtag (rev $pbrev)\n";191 pb_log(2,"\n"); 192 pb_log(2,"Management of $pbpkg $pbver-$pbtag (rev $pbrev)\n"); 192 193 die "Unable to get env var PBDESTDIR" if (not defined $ENV{'PBDESTDIR'}); 193 194 # Clean up dest if necessary. The export will recreate it … … 202 203 my $dir = $defpkgdir->{$pbpkg}; 203 204 $dir = $extpkgdir->{$pbpkg} if (not defined $dir); 204 print "def:".Dumper($defpkgdir)." ext: ".Dumper($extpkgdir)." \n" if ($debug >= 1); 205 pb_cms_export($cms,$pbdatecvs,"$ENV{'PBROOT'}/$dir",$dest); 205 pb_log(2,"def:".Dumper($defpkgdir)." ext: ".Dumper($extpkgdir)." \n"); 206 207 # If it isn't a flat CMS, then we have the choice to export subdir 208 $dir = "$uri/$dir" if ($ENV{'PBREVISION'} ne "flat"); 209 pb_cms_export($scheme,"$dir",$dest); 206 210 207 211 # Get project info on authors and log file … … 216 220 # Extract cms log history and store it 217 221 if ((defined $chglog) && (! -f "$dest/NEWS")) { 218 p rint $LOG "Generating NEWS file from $chglog\n";222 pb_log(2,"Generating NEWS file from $chglog\n"); 219 223 copy($chglog,"$dest/NEWS") || die "Unable to create $dest/NEWS"; 220 224 } 221 pb_cms_log($ cms,"$ENV{'PBROOT'}/$dir",$dest,$chglog,$authors);225 pb_cms_log($scheme,$dir,$dest,$chglog,$authors); 222 226 223 227 my %build; 224 228 225 my ($ptr) = pb_conf_get ("vmlist");229 my ($ptr) = pb_conf_get_if("vmlist","chrootlist"); 226 230 foreach my $d (split(/,/,$ptr->{$ENV{'PBPROJ'}})) { 227 my ($name,$ver ) = split(/_/,$d);228 chomp($ ver);231 my ($name,$ver,$arch) = split(/-/,$d); 232 chomp($arch); 229 233 my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($name,$ver); 230 p rint $LOG "DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf)."\n" if ($debug >= 1);231 p rint $LOG "DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n" if ($debug >= 1);234 pb_log(2,"DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf)."\n"); 235 pb_log(2,"DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n"); 232 236 233 237 # Filter build files from the less precise up to the most with overloading … … 236 240 # Find all build files first relatively to PBROOT 237 241 # Find also all specific files referenced in the .pb conf file 238 my %bfiles ;239 my %pkgfiles ;240 p rint $LOG "DEBUG dir: $ENV{'PBCONF'}/$pbpkg\n" if ($debug >= 1);242 my %bfiles = {}; 243 my %pkgfiles = {}; 244 pb_log(2,"DEBUG dir: $ENV{'PBCONF'}/$pbpkg\n"); 241 245 $build{"$ddir-$dver"} = "yes"; 242 if (-d "$ENV{'PBCONF'}/$pbpkg/$dtype") { 243 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$dtype") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$dtype: $!"; 244 foreach my $f (readdir(BDIR)) { 245 next if ($f =~ /^\./); 246 $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dtype/$f"; 247 $bfiles{$f} =~ s~$ENV{'PBROOT'}~~; 248 if (defined $supfiles->{$pbpkg}) { 249 $pkgfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dtype/$f" if ($f =~ /$supfiles->{$pbpkg}/); 250 } 251 } 252 closedir(BDIR); 253 } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$dfam") { 254 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$dfam") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$dfam: $!"; 255 foreach my $f (readdir(BDIR)) { 256 next if ($f =~ /^\./); 257 $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dfam/$f"; 258 $bfiles{$f} =~ s~$ENV{'PBROOT'}~~; 259 if (defined $supfiles->{$pbpkg}) { 260 $pkgfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dfam/$f" if ($f =~ /$supfiles->{$pbpkg}/); 261 } 262 } 263 closedir(BDIR); 264 } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$ddir") { 265 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$ddir") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$ddir: $!"; 266 foreach my $f (readdir(BDIR)) { 267 next if ($f =~ /^\./); 268 $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir/$f"; 269 $bfiles{$f} =~ s~$ENV{'PBROOT'}~~; 270 if (defined $supfiles->{$pbpkg}) { 271 $pkgfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir/$f" if ($f =~ /$supfiles->{$pbpkg}/); 272 } 273 } 274 closedir(BDIR); 275 } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver") { 276 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$ddir-$dver") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$ddir-$dver: $!"; 277 foreach my $f (readdir(BDIR)) { 278 next if ($f =~ /^\./); 279 $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver/$f"; 280 $bfiles{$f} =~ s~$ENV{'PBROOT'}~~; 281 if (defined $supfiles->{$pbpkg}) { 282 $pkgfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver/$f" if ($f =~ /$supfiles->{$pbpkg}/); 283 } 284 } 285 closedir(BDIR); 246 247 if (-d "$ENV{'PBROOT'}/$pbpkg/$dtype") { 248 pb_list_bfiles("$ENV{'PBROOT'}/$pbpkg/$dtype",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 249 } elsif (-d "$ENV{'PBROOT'}/$pbpkg/$dfam") { 250 pb_list_bfiles("$ENV{'PBROOT'}/$pbpkg/$dfam",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 251 } elsif (-d "$ENV{'PBROOT'}/$pbpkg/$ddir") { 252 pb_list_bfiles("$ENV{'PBROOT'}/$pbpkg/$ddir",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 253 } elsif (-d "$ENV{'PBROOT'}/$pbpkg/$ddir-$dver") { 254 pb_list_bfiles("$ENV{'PBROOT'}/$pbpkg/$ddir-$dver",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 286 255 } else { 287 256 $build{"$ddir-$dver"} = "no"; 288 257 next; 289 258 } 290 p rint $LOG "DEBUG bfiles: ".Dumper(\%bfiles)."\n" if ($debug >= 1);259 pb_log(2,"DEBUG bfiles: ".Dumper(\%bfiles)."\n"); 291 260 292 261 # Get all filters to apply … … 301 270 } 302 271 } 303 if ($debug >= 0) { 304 my @found; 305 my @notfound; 306 foreach my $b (keys %build) { 307 push @found,$b if ($build{$b} =~ /yes/); 308 push @notfound,$b if ($build{$b} =~ /no/); 309 } 310 print $LOG "Build files generated for ".join(',',@found)."\n"; 311 print $LOG "No Build files found for ".join(',',@notfound)."\n" if (@notfound); 312 } 272 my @found; 273 my @notfound; 274 foreach my $b (keys %build) { 275 push @found,$b if ($build{$b} =~ /yes/); 276 push @notfound,$b if ($build{$b} =~ /no/); 277 } 278 pb_log(0,"Build files generated for ".join(',',@found)."\n"); 279 pb_log(0,"No Build files found for ".join(',',@notfound)."\n") if (@notfound); 313 280 # Get the generic filter (all.pbf) and 314 281 # apply those to the non-build files including those … … 321 288 if (defined $filteredfiles->{$pbpkg}) { 322 289 foreach my $f (split(/,/,$filteredfiles->{$pbpkg})) { 323 pb_filter_file ("$ENV{'PBROOT'}/$dir/$f",$ptr,"$dest/$f",$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager);290 pb_filter_file_inplace($ptr,"$dest/$f",$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager); 324 291 $liste = "$f $liste"; 325 292 } 326 293 } 327 p rint $LOG "Files ".$liste."have been filtered\n";294 pb_log(2,"Files ".$liste."have been filtered\n"); 328 295 329 296 # Prepare the dest directory for archive 330 if (-x "$ENV{'PB CONF'}/$pbpkg/pbinit") {331 pb_filter_file("$ENV{'PB CONF'}/$pbpkg/pbinit",$ptr,"$ENV{'PBTMP'}/pbinit",$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager);297 if (-x "$ENV{'PBROOT'}/$pbpkg/pbinit") { 298 pb_filter_file("$ENV{'PBROOT'}/$pbpkg/pbinit",$ptr,"$ENV{'PBTMP'}/pbinit",$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager); 332 299 chmod 0755,"$ENV{'PBTMP'}/pbinit"; 333 pb_system("cd $dest ; $ENV{'PBTMP'}/pbinit","Executing init script from $ENV{'PB CONF'}/$pbpkg/pbinit");300 pb_system("cd $dest ; $ENV{'PBTMP'}/pbinit","Executing init script from $ENV{'PBROOT'}/$pbpkg/pbinit"); 334 301 } 335 302 … … 338 305 # Possibility to look at PBSRC to guess more the filename 339 306 pb_system("tar cfz $pbpkg-$pbver.tar.gz $pbpkg-$pbver","Creating $pbpkg tar files compressed"); 340 p rint $LOG "Under $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz\n" if ($debug >= 0);307 pb_log(2,"Under $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz\n"); 341 308 342 309 # Keep track of what is generated by default … … 354 321 } 355 322 356 p rint $LOG "DEBUG pkg: ".Dumper($pkg)."\n" if ($debug >= 1);323 pb_log(2,"DEBUG pkg: ".Dumper($pkg)."\n"); 357 324 open(PKG,"> $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb") || die "Unable to create $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb"; 358 325 foreach my $p (keys %$pkg) { … … 374 341 # Get the running distro to build on 375 342 my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init(); 376 p rint $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n" if ($debug >= 1);343 pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n"); 377 344 378 345 # Get content saved in cms2build … … 392 359 393 360 my $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz"; 394 p rint $LOG "Source file: $src\n" if ($debug >= 0);395 396 p rint $LOG "Working directory: $ENV{'PBBUILDDIR'}\n" if ($debug >= 0);361 pb_log(2,"Source file: $src\n"); 362 363 pb_log(2,"Working directory: $ENV{'PBBUILDDIR'}\n"); 397 364 if ($dtype eq "rpm") { 398 365 foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') { … … 402 369 } 403 370 371 # Remove in case a previous link/file was there 404 372 unlink "$ENV{'PBBUILDDIR'}/SOURCES/".basename($src); 405 373 symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES"; … … 408 376 @specfile = pb_extract_build_files($src,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$ENV{'PBBUILDDIR'}/SPECS"); 409 377 410 p rint $LOG "specfile: ".Dumper(\@specfile)."\n" if ($debug >= 1);378 pb_log(2,"specfile: ".Dumper(\@specfile)."\n"); 411 379 # set LANGUAGE to check for correct log messages 412 380 $ENV{'LANGUAGE'}="C"; 413 #system("ls -R $ENV{'PBBUILDDIR'}") if ($debug >= 1);414 381 foreach my $f (@specfile) { 415 382 if ($f =~ /\.spec$/) { … … 432 399 pb_system("dpkg-buildpackage -us -uc -rfakeroot","Building package"); 433 400 $made="$made $pbpkg"."_*.deb $pbpkg"."_*.dsc $pbpkg"."_*.tar.gz"; 401 if (-f "/usr/bin/lintian") { 402 pb_system("lintian $made","Checking validity of debs with lintian"); 403 } 434 404 } elsif ($dtype eq "ebuild") { 435 405 my @ebuildfile; … … 528 498 } 529 499 my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($odir,$over); 530 p rint $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n" if ($debug >= 1);500 pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n"); 531 501 532 502 # Get content saved in cms2build … … 575 545 } 576 546 577 p rint $LOG "Sources handled ($cmt): $src\n" if ($debug >= 0);547 pb_log(2,"Sources handled ($cmt): $src\n"); 578 548 my ($sshhost,$sshlogin,$sshdir,$sshport,$vmtmout,$testver) = pb_conf_get($host,$login,$dir,$port,$tmout,"testver"); 579 549 my $mac = "$sshlogin->{$ENV{'PBPROJ'}}\@$sshhost->{$ENV{'PBPROJ'}}"; … … 723 693 } 724 694 if (! -f "$vem") { 725 p rint "Unable to find VM $vem\n";695 pb_log(0,"Unable to find VM $vem\n"); 726 696 } else { 727 697 pb_system("$cmd &","Launching the VM $vem"); … … 730 700 } 731 701 } else { 732 p rint "Found an existing VM $vem (pid $veexist)\n";702 pb_log(0,"Found an existing VM $vem (pid $veexist)\n"); 733 703 } 734 704 return($veexist,$vepid); … … 798 768 } 799 769 if (! -f "$vmm") { 800 p rint "Unable to find VM $vmm\n";770 pb_log(0,"Unable to find VM $vmm\n"); 801 771 } else { 802 772 pb_system("$cmd &","Launching the VM $vmm"); … … 805 775 } 806 776 } else { 807 p rint "Found an existing VM $vmm (pid $vmexist)\n";777 pb_log(0,"Found an existing VM $vmm (pid $vmexist)\n"); 808 778 } 809 779 return($vmexist,$vmpid); … … 864 834 865 835 die "-V Version parameter needed" if ((not defined $newver) || ($newver eq "")); 866 my $ cms=pb_cms_init($ENV{'PBPROJ'});867 if ($ cms->{$ENV{'PBPROJ'}}ne "svn") {836 my $scheme=pb_cms_init($ENV{'PBPROJ'}); 837 if ($scheme ne "svn") { 868 838 die "Only SVN is supported at the moment"; 869 839 } 870 my $res = pb_cms_isdiff($ cms);840 my $res = pb_cms_isdiff($scheme); 871 841 die "You need to have no differences before creating a new version" if ($res != 0); 872 my $cmsurl = pb_cms_getinfo($ cms,$ENV{'PBROOT'});842 my $cmsurl = pb_cms_getinfo($scheme,$ENV{'PBROOT'},"URL:"); 873 843 my $newurl = dirname($cmsurl)."/$newver"; 874 pb_cms_copy($ cms,$cmsurl,$newurl);875 pb_cms_checkout($ cms,$newurl,"$ENV{'PBROOT'}/../$newver");844 pb_cms_copy($scheme,$cmsurl,$newurl); 845 pb_cms_checkout($scheme,$newurl,"$ENV{'PBROOT'}/../$newver"); 876 846 my $oldver=basename($cmsurl); 877 847 open(FILE,"$ENV{'PBROOT'}/../$newver/pbconf/$ENV{'PBPROJ'}.pb") || die "Unable to open $ENV{'PBROOT'}/../$newver/pbconf/$ENV{'PBPROJ'}.pb"; … … 884 854 close(OUT); 885 855 rename("$ENV{'PBROOT'}/../$newver/pbconf/$ENV{'PBPROJ'}.pb.new","$ENV{'PBROOT'}/../$newver/pbconf/$ENV{'PBPROJ'}.pb"); 886 pb_cms_checkin($ cms,"$ENV{'PBROOT'}/../$newver");856 pb_cms_checkin($scheme,"$ENV{'PBROOT'}/../$newver"); 887 857 } 888 858 … … 905 875 @pkgs = @ARGV; 906 876 } 907 p rint $LOG "Packages: ".join(',',@pkgs)."\n" if ($debug >= 0);877 pb_log(2,"Packages: ".join(',',@pkgs)."\n"); 908 878 return(\@pkgs); 909 879 } … … 928 898 $all = 1; 929 899 } 930 p rint $LOG "VMs: $ENV{'PBVM'}\n";900 pb_log(2,"VMs: $ENV{'PBVM'}\n"); 931 901 @vm = split(/,/,$ENV{'PBVM'}); 932 902 return(\@vm,$all); … … 969 939 next if ($f =~ /^\./); 970 940 move("$dir/$f","$ddir") || die "Unable to move $dir/$f to $ddir"; 971 p rint $LOG "mv $dir/$f $ddir\n" if ($debug >= 1);941 pb_log(2,"mv $dir/$f $ddir\n"); 972 942 push @files,"$ddir/$f"; 973 943 } … … 978 948 } 979 949 950 sub pb_list_bfiles { 951 952 my $dir = shift; 953 my $pbpkg = shift; 954 my $bfiles = shift; 955 my $pkgfiles = shift; 956 my $supfiles = shift; 957 958 opendir(BDIR,"$dir") || die "Unable to open dir $dir: $!"; 959 foreach my $f (readdir(BDIR)) { 960 next if ($f =~ /^\./); 961 $bfiles->{$f} = "$dir/$f"; 962 $bfiles->{$f} =~ s~$ENV{'PBROOT'}~~; 963 if (defined $supfiles->{$pbpkg}) { 964 $pkgfiles->{$f} = "$dir/$f" if ($f =~ /$supfiles->{$pbpkg}/); 965 } 966 } 967 closedir(BDIR); 968 } 969 980 970 sub pb_syntax { 981 971
Note:
See TracChangeset
for help on using the changeset viewer.