Changeset 2586 in ProjectBuilder
- Timestamp:
- Apr 3, 2020, 2:02:03 AM (5 years ago)
- Location:
- devel/pb-modules/lib/ProjectBuilder
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Env.pm
r2498 r2586 300 300 301 301 # 302 # Check pbconf cms compliance 302 # Check pbconf cms compliance except when creating a project as this doesn't exist yet 303 303 # 304 304 pb_vcs_compliant("pbconfdir",'PBCONFDIR',"$pbconfpath/pbconf",$pbconf{$ENV{'PBPROJ'}},$pbinit); 305 confess "No PBCONFDIR variable created" if ((not defined $ENV{'PBCONFDIR'}) || ($ENV{'PBCONFDIR'} eq "")); 306 305 307 my ($scheme, $account, $host, $port, $path) = pb_get_uri($pbconf{$ENV{'PBPROJ'}}); 306 308 … … 327 329 confess "$ENV{'PBROOTDIR'} is not a directory" if (not -d $ENV{'PBROOTDIR'}); 328 330 } 329 pb_log(1,"PBROOTDIR =$ENV{'PBROOTDIR'}\n");331 pb_log(1,"PBROOTDIR: $ENV{'PBROOTDIR'}\n"); 330 332 331 333 # Adds that conf file to the list to consider 332 334 if (-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.yml") { 333 pb_conf_add("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.yml") if (-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.yml");335 pb_conf_add("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.yml"); 334 336 } elsif (-f "$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb") { 335 337 pb_vcs_conf_update_v0("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb","$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.yml"); … … 399 401 @pkgs = ("$ENV{'PBPROJ'}") if (not @pkgs); 400 402 401 # Case where the parent dir of PBROOTDIR isn't managed yet in VCS402 pb_mkdir_p(dirname("$ENV{'PBROOTDIR'}"));403 pb_vcs_add_if_not_in($pbconf{$ENV{'PBPROJ'}},dirname("$ENV{'PBROOTDIR'}"));404 403 pb_mkdir_p("$ENV{'PBROOTDIR'}"); 405 pb_vcs_add_if_not_in($pbconf{$ENV{'PBPROJ'}},"$ENV{'PBROOTDIR'}");406 my $msg = "Project $ENV{'PBPROJ'} structure creation";407 pb_vcs_checkin($pbconf{$ENV{'PBPROJ'}},"$ENV{'PBROOTDIR'}",$msg);408 404 open(CONF,"> $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.yml") || confess "Unable to create $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.yml"; 409 405 print CONF << "EOF"; … … 1302 1298 1303 1299 } 1304 pb_vcs_add($pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONFDIR'}); 1305 $msg = "Project $ENV{'PBPROJ'} creation"; 1306 pb_vcs_checkin($pbconf{$ENV{'PBPROJ'}},"$ENV{'PBCONFDIR'}",$msg); 1300 my $msg = "Project $ENV{'PBPROJ'} structure creation"; 1301 opendir(DIR,$ENV{'PBCONFDIR'}) || confess "Unable to open directory $ENV{'PBCONFDIR'}: $!"; 1302 foreach my $f (readdir(DIR)) { 1303 next if ($f =~ /^\./); 1304 pb_vcs_add($scheme,"$ENV{'PBCONFDIR'}/$f"); 1305 } 1306 closedir(DIR); 1307 pb_vcs_checkin($scheme,dirname($ENV{'PBCONFDIR'}),$msg); 1307 1308 } else { 1308 1309 pb_log(0,"ERROR: no pbroot defined, used $ENV{'PBROOTDIR'}, without finding $ENV{'PBPROJ'}.yml in it\n"); -
devel/pb-modules/lib/ProjectBuilder/VCS.pm
r2498 r2586 371 371 my $vcscmd = pb_vcs_cmd($scheme); 372 372 373 pb_log(3,"scheme: $scheme - dir: $dir - vcscmd: $vcscmd\n"); 373 374 if ($scheme =~ /^svn/) { 374 375 open(PIPE,"LANGUAGE=C $vcscmd info $dir 2> /dev/null |") || return(""); 375 376 while (<PIPE>) { 376 ($void,$res) = split(/^URL:/) if (/^URL:/); 377 pb_log(4,"line: $_"); 378 if (/^URL[\s]*:/) { 379 ($void,$res) = split(/^URL[\s]*:/); 380 last; 381 } 377 382 } 378 383 $res =~ s/^\s*//; 379 384 close(PIPE); 380 385 chomp($res); 386 pb_log(3,"res $res\n"); 381 387 } elsif ($scheme =~ /^svk/) { 382 388 open(PIPE,"LANGUAGE=C $vcscmd info $dir 2> /dev/null |") || return(""); … … 402 408 chdir($cwd) || return(""); 403 409 while (<PIPE>) { 404 ($void,$res) = split(/^URL :/) if (/^URL:/);410 ($void,$res) = split(/^URL[\s]*:/) if (/^URL[\s]*:/); 405 411 } 406 412 $res =~ s/^\s*//; … … 614 620 sub pb_vcs_add_if_not_in { 615 621 my $scheme = shift; 616 my @f = @_;617 622 my $vcscmd = pb_vcs_cmd($scheme); 618 623 619 624 if ($scheme =~ /^((hg)|(git)|(svn)|(svk)|(cvs))/o) { 620 for my $f (@ f) {625 for my $f (@_) { 621 626 my $uri = pb_vcs_get_uri($scheme,$f); 622 pb_vcs_add($scheme,$f) if ($uri !~ /^$scheme/); 627 pb_log(3,"f: $f - scheme: $scheme - uri: $uri\n"); 628 my ($scheme2, $a, $h, $p, $n) = pb_get_uri($uri); 629 pb_vcs_add($scheme,$f) if ("$scheme2" ne "$scheme"); 623 630 } 624 631 } elsif ($scheme =~ /^(flat)|(ftp)|(http)|(https)|(file)\b/o) { … … 663 670 push(@f1,dirname($f)) if (-f $f); 664 671 } 672 # Wrong we need to push instead 665 673 pb_vcs_up($scheme,@f1); 666 674 } … … 768 776 } 769 777 778 =item B<pb_vcs_mkdir> 779 780 This function makes a VCS directory 781 The first parameter is the schema of the VCS systems (svn, cvs, svn+ssh, ...) 782 The second parameter is the directory to create. 783 The third parameter is the comment to pass during the commit 784 785 =cut 786 787 sub pb_vcs_mkdir { 788 my $scheme = shift; 789 my $dir = shift; 790 my $msg = shift; 791 my $vcscmd = pb_vcs_cmd($scheme); 792 793 if ($scheme =~ /^((svn)|(cvs)|(svk))/o) { 794 pb_system("$vcscmd mkdir -m \"$msg\" $dir","Making VCS directory $dir"); 795 } elsif ($scheme =~ /^git/) { 796 #pb_system("cd $dir && git init ", "Making VCS directory $dir"); 797 ## + git remote add + git push 798 } elsif ($scheme =~ /^(flat)|(ftp)|(http)|(https)|(file)\b/o) { 799 # Nothing to do. 800 } else { 801 confess "cms $scheme unknown"; 802 } 803 } 804 805 806 770 807 =item B<pb_vcs_compliant> 771 808 … … 777 814 The fifth parameter indicates whether we should inititate the context or not. 778 815 816 Only called for PBCONFDIR and PBDIR 779 817 =cut 780 818 … … 809 847 eval { $ENV{$envar} =~ s/(\$ENV.+\})/$1/eeg }; 810 848 pb_log(2,"$envar: $ENV{$envar}\n"); 849 my $exportdir = $ENV{$envar}; 811 850 812 851 my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri); … … 816 855 pb_log(1,"pb_vcs_compliant useless\n"); 817 856 return; 818 } elsif ((defined $pbinit) || (! -d "$ENV{$envar}")) { 819 my $exportdir = $ENV{$envar}; 857 } elsif ((defined $pbinit) && (! -d "$exportdir")) { 820 858 # Either we have a version in the uri, and it should be the same 821 859 # as the one in the envar. Or we should add the version to the uri … … 824 862 $uri .= "/".basename($exportdir); 825 863 } 826 if ((defined $pbinit) && ($scheme =~ /git/)) { 827 # If initializing remove the potential pbconf part if we treat pbconfdir 828 $exportdir =~ s|pbconf[/]*||; 829 } 830 pb_log(1,"Checking out $uri\n"); 831 # Create structure and remove end dir before exporting 864 832 865 pb_mkdir_p("$exportdir"); 833 pb_rm_rf($exportdir); 866 # Should only have pbconf 867 if ((pb_path_nbfiles(dirname($exportdir)) > 1) && ($envar eq 'PBCONFDIR')) { 868 confess("Directory ".dirname($exportdir)." has content.\nPlease remove it if you want to use that directory\n"); 869 } 870 if (pb_path_nbfiles("$exportdir") > 0) { 871 confess("Directory $exportdir has content.\nPlease remove it if you want to use that directory\n"); 872 } 873 if ($envar eq 'PBCONFDIR') { 874 # Remove the potential pbconf part if we treat pbconfdir 875 $exportdir =~ s|/pbconf[/]*||; 876 $uri =~ s|/pbconf[/]*||; 877 } 878 # Don't add content here as it may conflict later on with PBROOT addition 879 # Done in Env.pm 880 pb_log(0,"Trying to check out (may fail) ".$uri."\n"); 834 881 pb_vcs_checkout($scheme,$uri,$exportdir); 835 if ((defined $pbinit) && ($scheme =~ /git/)) { 836 # And now created the potentially missing pbconf dir 837 pb_mkdir_p("$exportdir/pbconf"); 838 } 882 if (($envar eq 'PBCONFDIR') && (pb_path_nbfiles("$exportdir/pbconf") == 0)) { 883 # Export failed, because there is nothing yet in the repo 884 # we now need to clean stuff before doing mkdir to avoid conflicts 885 pb_rm_rf($exportdir); 886 pb_log(0,"Pushing first $uri\n"); 887 pb_vcs_mkdir($scheme,$uri,"Creating structure directory"); 888 pb_vcs_mkdir($scheme,"$uri/pbconf","Creating structure sub directory"); 889 pb_log(0,"Re-Trying to check out again $uri\n"); 890 pb_vcs_up($scheme,$exportdir); 891 } 892 pb_log(0,"Done\n"); 839 893 } else { 840 894 pb_log(1,"$uri found locally, checking content\n");
Note:
See TracChangeset
for help on using the changeset viewer.