Changeset 661 in ProjectBuilder for devel/pb/lib
- Timestamp:
- Feb 5, 2009, 1:57:26 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/lib/ProjectBuilder/CMS.pm
r626 r661 61 61 pb_log(2,"DEBUG: Project URL of $ENV{'PBPROJ'}: $pburl->{$ENV{'PBPROJ'}}\n"); 62 62 my ($scheme, $account, $host, $port, $path) = pb_get_uri($pburl->{$ENV{'PBPROJ'}}); 63 my $vcscmd = pb_cms_cmd($scheme); 63 64 64 65 my ($pbprojdir) = pb_conf_get_if("pbprojdir"); … … 83 84 pb_cms_compliant(undef,'PBDIR',"$ENV{'PBPROJDIR'}/$tmp",$pburl->{$ENV{'PBPROJ'}},$pbinit); 84 85 86 85 87 if ($scheme =~ /^hg/) { 86 $tmp = `(cd "$ENV{'PBDIR'}" ; hgidentify )`;88 $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd identify )`; 87 89 chomp($tmp); 88 90 $tmp =~ s/^.* //; 89 91 $ENV{'PBREVISION'}=$tmp; 90 92 $ENV{'PBCMSLOGFILE'}="hg.log"; 93 } elsif ($scheme =~ /^git/) { 94 $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd log | head -1 | cut -f2)`; 95 chomp($tmp); 96 $tmp =~ s/^.* //; 97 $ENV{'PBREVISION'}=$tmp; 98 $ENV{'PBCMSLOGFILE'}="git.log"; 91 99 } elsif (($scheme eq "file") || ($scheme eq "ftp") || ($scheme eq "http")) { 92 100 $ENV{'PBREVISION'}="flat"; … … 94 102 } elsif ($scheme =~ /^svn/) { 95 103 # svnversion more precise than svn info 96 $tmp = `(cd "$ENV{'PBDIR'}" ; svnversion.)`;104 $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd"version" .)`; 97 105 chomp($tmp); 98 106 $ENV{'PBREVISION'}=$tmp; … … 133 141 # If it's not flat, then we have a real uri as source 134 142 my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri); 143 my $vcscmd = pb_cms_cmd($scheme); 144 $uri = pb_cms_mod_socks($uri); 135 145 136 146 if ($scheme =~ /^svn/) { … … 141 151 $tmp = "$destdir/".basename($source); 142 152 } 143 $source = pb_cms_mod_ svn_http($source);144 pb_system(" svnexport $source $tmp","Exporting $source from SVN to $tmp ");145 } else { 146 $uri = pb_cms_mod_ svn_http($uri);147 pb_system(" svnexport $uri $destdir","Exporting $uri from SVN to $destdir ");153 $source = pb_cms_mod_http($source,"svn"); 154 pb_system("$vcscmd export $source $tmp","Exporting $source from SVN to $tmp "); 155 } else { 156 $uri = pb_cms_mod_http($uri,"svn"); 157 pb_system("$vcscmd export $uri $destdir","Exporting $uri from SVN to $destdir "); 148 158 } 149 159 } elsif ($scheme eq "dir") { … … 152 162 my $f = basename($path); 153 163 unlink "$ENV{'PBTMP'}/$f"; 154 if (-x "/usr/bin/wget") { 155 pb_system("/usr/bin/wget -nv -O $ENV{'PBTMP'}/$f $uri"," "); 156 } elsif (-x "/usr/bin/curl") { 157 pb_system("/usr/bin/curl $uri -o $ENV{'PBTMP'}/$f","Downloading $uri with curl to $ENV{'PBTMP'}/$f\n"); 158 } else { 159 die "Unable to download $uri.\nNo wget/curl available, please install one of those"; 160 } 164 pb_system("$vcscmd $ENV{'PBTMP'}/$f $uri","Downloading $uri with $vcscmd to $ENV{'PBTMP'}/$f\n"); 161 165 # We want to preserve the original tar file 162 166 pb_cms_export("file://$ENV{'PBTMP'}/$f",$source,$destdir); … … 207 211 $tmp = "$destdir/".basename($source); 208 212 } 209 $source = pb_cms_mod_hg_http($source); 210 pb_system("cd $source ; hg archive $tmp","Exporting $source from Mercurial to $tmp "); 211 } else { 212 $uri = pb_cms_mod_hg_http($uri); 213 pb_system("hg clone $uri $destdir","Exporting $uri from Mercurial to $destdir "); 213 $source = pb_cms_mod_http($source,"hg"); 214 pb_system("cd $source ; $vcscmd archive $tmp","Exporting $source from Mercurial to $tmp "); 215 } else { 216 $uri = pb_cms_mod_http($uri,"hg"); 217 pb_system("$vcscmd clone $uri $destdir","Exporting $uri from Mercurial to $destdir "); 218 } 219 } elsif ($scheme =~ /^git/) { 220 if (defined $source) { 221 if (-d $source) { 222 $tmp = $destdir; 223 } else { 224 $tmp = "$destdir/".basename($source); 225 } 226 $source = pb_cms_mod_http($source,"git"); 227 pb_system("cd $source ; $vcscmd archive --format=tar HEAD | (mkdir $tmp && cd $tmp && tar xf -)","Exporting $source/HEAD from GIT to $tmp "); 228 } else { 229 $uri = pb_cms_mod_http($uri,"git"); 230 pb_system("$vcscmd clone $uri $destdir","Exporting $uri from GIT to $destdir "); 214 231 } 215 232 } elsif ($scheme =~ /^cvs/) { … … 234 251 $cvsopt = "-r $cvstag"; 235 252 } 236 pb_system("cd $dir ; cvs-d $account\@$host:$path export $cvsopt -d $base $tmp1","Exporting $tmp1 from $source under CVS to $destdir ");253 pb_system("cd $dir ; $vcscmd -d $account\@$host:$path export $cvsopt -d $base $tmp1","Exporting $tmp1 from $source under CVS to $destdir "); 237 254 } else { 238 255 die "cms $scheme unknown"; … … 256 273 my $res = ""; 257 274 my $void = ""; 275 my $vcscmd = pb_cms_cmd($scheme); 258 276 259 277 if ($scheme =~ /^svn/) { 260 open(PIPE,"LANGUAGE=C svninfo $dir |") || return("");278 open(PIPE,"LANGUAGE=C $vcscmd info $dir |") || return(""); 261 279 while (<PIPE>) { 262 280 ($void,$res) = split(/^URL:/) if (/^URL:/); … … 271 289 } 272 290 close(HGRC); 291 chomp($res); 292 } elsif ($scheme =~ /^git/) { 293 open(GITRC,".git/gitrc/") || return(""); 294 while (<GITRC>) { 295 ($void,$res) = split(/^default.*=/) if (/^default.*=/); 296 } 297 close(GITRC); 273 298 chomp($res); 274 299 } elsif ($scheme =~ /^cvs/) { … … 318 343 my $oldurl = shift; 319 344 my $newurl = shift; 345 my $vcscmd = pb_cms_cmd($scheme); 346 $oldurl = pb_cms_mod_socks($oldurl); 347 $newurl = pb_cms_mod_socks($newurl); 320 348 321 349 if ($scheme =~ /^svn/) { 322 $oldurl = pb_cms_mod_ svn_http($oldurl);323 $newurl = pb_cms_mod_ svn_http($newurl);324 pb_system(" svncopy -m \"Creation of $newurl from $oldurl\" $oldurl $newurl","Copying $oldurl to $newurl ");350 $oldurl = pb_cms_mod_http($oldurl,"svn"); 351 $newurl = pb_cms_mod_http($newurl,"svn"); 352 pb_system("$vcscmd copy -m \"Creation of $newurl from $oldurl\" $oldurl $newurl","Copying $oldurl to $newurl "); 325 353 } elsif ($scheme eq "flat") { 326 354 } elsif ($scheme =~ /^cvs/) { … … 343 371 my $url = shift; 344 372 my $destination = shift; 373 my $vcscmd = pb_cms_cmd($scheme); 374 $url = pb_cms_mod_socks($url); 345 375 346 376 if ($scheme =~ /^svn/) { 347 $url = pb_cms_mod_ svn_http($url);348 pb_system(" svnco $url $destination","Checking out $url to $destination ");377 $url = pb_cms_mod_http($url,"svn"); 378 pb_system("$vcscmd co $url $destination","Checking out $url to $destination "); 349 379 } elsif ($scheme =~ /^hg/) { 350 $url = pb_cms_mod_hg_http($url); 351 pb_system("hg clone $url $destination","Checking out $url to $destination "); 380 $url = pb_cms_mod_http($url,"hg"); 381 pb_system("$vcscmd clone $url $destination","Checking out $url to $destination "); 382 } elsif ($scheme =~ /^git/) { 383 $url = pb_cms_mod_http($url,"git"); 384 pb_system("$vcscmd clone $url $destination","Checking out $url to $destination "); 352 385 } elsif (($scheme eq "ftp") || ($scheme eq "http")) { 353 386 return; … … 367 400 } 368 401 pb_mkdir_p("$destination"); 369 pb_system("cd $destination ; cvs-d $account\@$host:$path co $cvsopt .","Checking out $url to $destination ");402 pb_system("cd $destination ; $vcscmd -d $account\@$host:$path co $cvsopt .","Checking out $url to $destination "); 370 403 } elsif ($scheme =~ /^file/) { 371 404 pb_cms_export($url,undef,$destination); … … 386 419 my $scheme = shift; 387 420 my $dir = shift; 388 389 if ($scheme =~ /^svn/) { 390 pb_system("svn up $dir","Updating $dir "); 421 my $vcscmd = pb_cms_cmd($scheme); 422 423 if (($scheme =~ /^svn/) || ($scheme =~ /^hg/) || ($scheme =~ /^git/) || ($scheme =~ /^cvs/)) { 424 pb_system("$vcscmd up $dir","Updating $dir "); 391 425 } elsif ($scheme eq "flat") { 392 } elsif ($scheme =~ /^hg/) {393 pb_system("cd $dir ; hg up","Updating $dir ");394 } elsif ($scheme =~ /^cvs/) {395 pb_system("cvs up $dir","Updating $dir ");396 426 } else { 397 427 die "cms $scheme unknown"; … … 412 442 my $dir = shift; 413 443 my $pbinit = shift || undef; 444 my $vcscmd = pb_cms_cmd($scheme); 414 445 415 446 my $ver = basename($dir); … … 417 448 $msg = "Project $ENV{PBPROJ} creation" if (defined $pbinit); 418 449 419 if ( $scheme =~ /^svn/) {420 pb_system(" svn ci -m \"$msg\" $dir","Checking in $dir ");450 if (($scheme =~ /^svn/) || ($scheme =~ /^hg/) || ($scheme =~ /^git/) || ($scheme =~ /^cvs/)) { 451 pb_system("cd $dir ; $vcscmd ci -m \"$msg\" .","Checking in $dir "); 421 452 } elsif ($scheme eq "flat") { 422 } elsif ($scheme =~ /^hg/) {423 pb_system("cd $dir ; hg ci -m \"$msg\" .","Checking in $dir ");424 } elsif ($scheme =~ /^cvs/) {425 pb_system("cvs ci -m \"$msg\" $dir","Checking in $dir ");426 453 } else { 427 454 die "cms $scheme unknown"; … … 441 468 my $scheme = shift; 442 469 my $f = shift; 443 444 if ($scheme =~ /^svn/) { 445 pb_system("svn add $f","Adding $f to SVN "); 470 my $vcscmd = pb_cms_cmd($scheme); 471 472 if (($scheme =~ /^svn/) || ($scheme =~ /^hg/) || ($scheme =~ /^git/) || ($scheme =~ /^cvs/)) { 473 pb_system("$vcscmd add $f","Adding $f to VCS "); 446 474 } elsif ($scheme eq "flat") { 447 } elsif ($scheme =~ /^hg/) {448 pb_system("hg add $f","Adding $f to Mercurial ");449 } elsif ($scheme =~ /^cvs/) {450 pb_system("cvs add $f","Adding $f to CVS ");451 475 } else { 452 476 die "cms $scheme unknown"; … … 466 490 my $scheme = shift; 467 491 my $dir =shift; 468 469 if ($scheme =~ /^svn/) { 470 open(PIPE,"svn diff $dir |") || die "Unable to get svn diff from $dir"; 492 my $vcscmd = pb_cms_cmd($scheme); 493 494 if (($scheme =~ /^svn/) || ($scheme =~ /^hg/) || ($scheme =~ /^git/) || ($scheme =~ /^cvs/)) { 495 open(PIPE,"$vcscmd diff $dir |") || die "Unable to get $vcscmd diff from $dir"; 471 496 my $l = 0; 472 497 while (<PIPE>) { 473 $l++; 474 } 475 return($l); 476 } elsif ($scheme =~ /^hg/) { 477 open(PIPE,"hg diff $dir |") || die "Unable to get hg diff from $dir"; 478 my $l = 0; 479 while (<PIPE>) { 498 # Skipping normal messages in case of CVS 499 next if (/^cvs diff:/); 480 500 $l++; 481 501 } 482 502 return($l); 483 503 } elsif ($scheme eq "flat") { 484 } elsif ($scheme =~ /^cvs/) {485 open(PIPE,"cvs diff $dir |") || die "Unable to get svn diff from $dir";486 my $l = 0;487 while (<PIPE>) {488 # Skipping normal messages489 next if (/^cvs diff:/);490 $l++;491 }492 return($l);493 504 } else { 494 505 die "cms $scheme unknown"; … … 612 623 pb_cms_checkout($scheme,$uri,$ENV{$envar}); 613 624 } 614 } elsif (($scheme !~ /^cvs/) || ($scheme !~ /^svn/) || ($scheme !~ /^hg/)) {625 } elsif (($scheme !~ /^cvs/) || ($scheme !~ /^svn/) || ($scheme !~ /^hg/) || ($scheme !~ /^git/) ) { 615 626 # Do not compare if it's not a real cms 616 627 return; … … 700 711 701 712 pb_cms_create_authors($authors,$dest,$scheme); 713 my $vcscmd = pb_cms_cmd($scheme); 702 714 703 715 if ((defined $testver) && (defined $testver->{$ENV{'PBPROJ'}}) && ($testver->{$ENV{'PBPROJ'}} =~ /true/i)) { … … 729 741 } else { 730 742 # To be written from pbcl 731 pb_system(" svnlog -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVN");743 pb_system("$vcscmd log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVN"); 732 744 } 733 745 } … … 737 749 open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog"; 738 750 close(CL); 739 pb_system("hg log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVN"); 751 pb_system("$vcscmd log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVN"); 752 } 753 } elsif ($scheme =~ /^git/) { 754 if (! -f "$dest/ChangeLog") { 755 # In case we have no network, just create an empty one before to allow correct build 756 open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog"; 757 close(CL); 758 pb_system("$vcscmd log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from GIT"); 740 759 } 741 760 } elsif (($scheme eq "file") || ($scheme eq "dir") || ($scheme eq "http") || ($scheme eq "ftp")) { … … 754 773 } else { 755 774 # To be written from pbcl 756 pb_system(" cvslog $tmp > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from CVS");757 } 758 } 759 } else { 760 die "cms $scheme unknown"; 761 } 762 } 763 764 sub pb_cms_mod_ svn_http {775 pb_system("$vcscmd log $tmp > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from CVS"); 776 } 777 } 778 } else { 779 die "cms $scheme unknown"; 780 } 781 } 782 783 sub pb_cms_mod_http { 765 784 766 785 my $url = shift; 767 768 $url =~ s/^svn\+(http[s]*):/$1:/; 786 my $proto = shift; 787 788 $url =~ s/^$proto\+(http[s]*):/$1:/; 769 789 return($url); 770 790 } 771 791 772 sub pb_cms_mod_ hg_http{792 sub pb_cms_mod_socks { 773 793 774 794 my $url = shift; 775 795 776 $url =~ s/^ hg\+(http[s]*):/$1:/;796 $url =~ s/^([A-z0-9]+)\+(socks):/$1:/; 777 797 return($url); 778 798 } 799 800 801 sub pb_cms_cmd { 802 803 my $scheme = shift; 804 my $cmd = ""; 805 806 # If there is a socks proxy to use 807 if ($scheme =~ /socks/) { 808 # Get the socks proxy command from the conf file 809 my ($pbsockcmd) = pb_conf_get("pbsockscmd"); 810 $cmd = "$pbsockcmd->{$ENV{'PBPROJ'}} "; 811 } 812 813 if ($scheme =~ /hg/) { 814 return($cmd."hg") 815 } elsif ($scheme =~ /git/) { 816 return($cmd."git") 817 } elsif ($scheme =~ /svn/) { 818 return($cmd."svn") 819 } elsif ($scheme =~ /cvs/) { 820 return($cmd."cvs") 821 } elsif (($scheme =~ /http/) || ($scheme =~ /ftp/)) { 822 if (-x "/usr/bin/wget") { 823 return($cmd."/usr/bin/wget -nv -O "); 824 } elsif (-x "/usr/bin/curl") { 825 return($cmd."/usr/bin/curl -o "); 826 } else { 827 die "Unable to handle $scheme.\nNo wget/curl available, please install one of those"; 828 } 829 } else { 830 return($cmd); 831 } 832 } 833 834 779 835 780 836 =back
Note:
See TracChangeset
for help on using the changeset viewer.