- Timestamp:
- Jan 28, 2014, 9:10:25 AM (11 years ago)
- Location:
- devel
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Env.pm
r1767 r1850 24 24 use ProjectBuilder::Base; 25 25 use ProjectBuilder::Conf; 26 use ProjectBuilder::CMS;27 26 use ProjectBuilder::VCS; 28 27 … … 309 308 # Check pbconf cms compliance 310 309 # 311 pb_ cms_compliant("pbconfdir",'PBCONFDIR',"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/pbconf",$pbconf{$ENV{'PBPROJ'}},$pbinit);310 pb_vcs_compliant("pbconfdir",'PBCONFDIR',"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/pbconf",$pbconf{$ENV{'PBPROJ'}},$pbinit); 312 311 313 312 # Check where is our PBROOTDIR (release tag name can't be guessed the first time) … … 1252 1251 } 1253 1252 pb_vcs_add($pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONFDIR'}); 1254 pb_cms_checkin($pbconf{$ENV{'PBPROJ'}},"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}",$pbinit); 1253 my $msg = "updated to ".basename("$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}"); 1254 $msg = "Project $ENV{'PBPROJ'} creation" if (defined $pbinit); 1255 pb_vcs_checkin($pbconf{$ENV{'PBPROJ'}},"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}",$msg); 1255 1256 } else { 1256 1257 pb_log(0,"ERROR: no pbroot defined, used $ENV{'PBROOTDIR'}, without finding $ENV{'PBPROJ'}.pb in it\n"); -
devel/pb-modules/lib/ProjectBuilder/VCS.pm
r1801 r1850 36 36 37 37 our @ISA = qw(Exporter); 38 our @EXPORT = qw(pb_vcs_export pb_vcs_get_uri pb_vcs_copy pb_vcs_checkout pb_vcs_up pb_vcs_checkin pb_vcs_isdiff pb_vcs_add pb_vcs_add_if_not_in pb_vcs_cmd );38 our @EXPORT = qw(pb_vcs_export pb_vcs_get_uri pb_vcs_copy pb_vcs_checkout pb_vcs_up pb_vcs_checkin pb_vcs_isdiff pb_vcs_add pb_vcs_add_if_not_in pb_vcs_cmd pb_vcs_compliant); 39 39 ($VERSION,$REVISION) = pb_version_init(); 40 40 … … 623 623 } 624 624 625 625 =item B<pb_vcs_compliant> 626 627 This function checks the compliance of the project and the pbconf directory. 628 The first parameter is the key name of the value that needs to be read in the configuration file. 629 The second parameter is the environment variable this key will populate. 630 The third parameter is the location of the pbconf dir. 631 The fourth parameter is the URI of the CMS content related to the pbconf dir. 632 The fifth parameter indicates whether we should inititate the context or not. 633 634 =cut 635 636 sub pb_vcs_compliant { 637 638 my $param = shift; 639 my $envar = shift; 640 my $defdir = shift; 641 my $uri = shift; 642 my $pbinit = shift; 643 my %pdir; 644 645 pb_log(1,"pb_vcs_compliant: envar: $envar - defdir: $defdir - uri: $uri\n"); 646 my ($pdir) = pb_conf_get_if($param) if (defined $param); 647 if (defined $pdir) { 648 %pdir = %$pdir; 649 } 650 651 652 if ((defined $pdir) && (%pdir) && (defined $pdir{$ENV{'PBPROJ'}})) { 653 # That's always the environment variable that will be used 654 $ENV{$envar} = $pdir{$ENV{'PBPROJ'}}; 655 } else { 656 if (defined $param) { 657 pb_log(1,"WARNING: no $param defined, using $defdir\n"); 658 pb_log(1," Please create a $param reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n"); 659 pb_log(1," if you want to use another directory\n"); 660 } 661 $ENV{$envar} = "$defdir"; 662 } 663 664 # Expand potential env variable in it 665 eval { $ENV{$envar} =~ s/(\$ENV.+\})/$1/eeg }; 666 pb_log(2,"$envar: $ENV{$envar}\n"); 667 668 my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri); 669 670 if (($scheme !~ /^cvs/) && ($scheme !~ /^svn/) && ($scheme !~ /^svk/) && ($scheme !~ /^hg/) && ($scheme !~ /^git/)) { 671 # Do not compare if it's not a real cms 672 pb_log(1,"pb_vcs_compliant useless\n"); 673 return; 674 } elsif (defined $pbinit) { 675 pb_mkdir_p("$ENV{$envar}"); 676 } elsif (! -d "$ENV{$envar}") { 677 # Either we have a version in the uri, and it should be the same 678 # as the one in the envar. Or we should add the version to the uri 679 if (basename($uri) ne basename($ENV{$envar})) { 680 $uri .= "/".basename($ENV{$envar}) 681 } 682 pb_log(1,"Checking out $uri\n"); 683 # Create structure and remove end dir before exporting 684 pb_mkdir_p("$ENV{$envar}"); 685 pb_rm_rf($ENV{$envar}); 686 pb_vcs_checkout($scheme,$uri,$ENV{$envar}); 687 } else { 688 pb_log(1,"$uri found locally, checking content\n"); 689 my $cmsurl = pb_vcs_get_uri($scheme,$ENV{$envar}); 690 my ($scheme2, $account2, $host2, $port2, $path2) = pb_get_uri($cmsurl); 691 # For svk, scheme doesn't appear in svk info so remove it here in uri coming from conf file 692 # which needs it to trigger correct behaviour 693 $uri =~ s/^svk://; 694 if (($scheme2 =~ /^git/) || ($scheme2 =~ /^hg/)) { 695 # These VCS manage branches internally not with different tree structures 696 # Assuming it's correct for now. 697 } elsif ($cmsurl ne $uri) { 698 # The local content doesn't correpond to the repository 699 pb_log(0,"ERROR: Inconsistency detected:\n"); 700 pb_log(0," * $ENV{$envar} ($envar) refers to $cmsurl but\n"); 701 pb_log(0," * $ENV{'PBETC'} refers to $uri\n"); 702 die "Project $ENV{'PBPROJ'} is not Project-Builder compliant."; 703 } else { 704 pb_log(1,"Content correct - doing nothing - you may want to update your repository however\n"); 705 # they match - do nothing - there may be local changes 706 } 707 } 708 pb_log(1,"pb_vcs_compliant end\n"); 709 } 710 626 711 627 712 =back -
devel/pb/bin/pb
r1848 r1850 3088 3088 3089 3089 pb_log(2,"Checkin $ENV{'PBCONFDIR'}/$newver\n"); 3090 pb_ cms_checkin($scheme,"$ENV{'PBCONFDIR'}/$newver",undef);3090 pb_vcs_checkin($scheme,"$ENV{'PBCONFDIR'}/$newver","updated to $ENV{'PBCONFDIR'}"); 3091 3091 } 3092 3092 -
devel/pb/lib/ProjectBuilder/CMS.pm
r1801 r1850 35 35 36 36 our @ISA = qw(Exporter); 37 our @EXPORT = qw(pb_cms_init pb_cms_ checkin pb_cms_get_pkg pb_cms_get_real_pkg pb_cms_compliantpb_cms_log);37 our @EXPORT = qw(pb_cms_init pb_cms_get_pkg pb_cms_get_real_pkg pb_cms_log); 38 38 ($VERSION,$REVISION) = pb_version_init(); 39 39 … … 94 94 my $turl = "$pburl->{$ENV{'PBPROJ'}}/$tmp"; 95 95 $turl = $pburl->{$ENV{'PBPROJ'}} if ($scheme =~ /^(flat)|(ftp)|(http)|(file)\b/o); 96 pb_ cms_compliant(undef,'PBDIR',"$ENV{'PBPROJDIR'}/$tmp",$turl,$pbinit);96 pb_vcs_compliant(undef,'PBDIR',"$ENV{'PBPROJDIR'}/$tmp",$turl,$pbinit); 97 97 98 98 … … 147 147 pb_log(1,"pb_cms_init returns $scheme,$pburl->{$ENV{'PBPROJ'}}\n"); 148 148 return($scheme,$pburl->{$ENV{'PBPROJ'}}); 149 }150 151 =item B<pb_cms_checkin>152 153 This function updates a CMS content from a local directory.154 The first parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)155 The second parameter is the directory to update from.156 The third parameter indicates if we are in a new version creation (undef) or in a new project creation (1)157 158 =cut159 160 sub pb_cms_checkin {161 my $scheme = shift;162 my $dir = shift;163 my $pbinit = shift || undef;164 165 my $ver = basename($dir);166 my $msg = "updated to $ver";167 $msg = "Project $ENV{'PBPROJ'} creation" if (defined $pbinit);168 169 pb_vcs_checkin($scheme,$dir,$msg);170 149 } 171 150 … … 239 218 } 240 219 241 =item B<pb_cms_compliant>242 243 This function checks the compliance of the project and the pbconf directory.244 The first parameter is the key name of the value that needs to be read in the configuration file.245 The second parameter is the environment variable this key will populate.246 The third parameter is the location of the pbconf dir.247 The fourth parameter is the URI of the CMS content related to the pbconf dir.248 The fifth parameter indicates whether we should inititate the context or not.249 250 =cut251 252 sub pb_cms_compliant {253 254 my $param = shift;255 my $envar = shift;256 my $defdir = shift;257 my $uri = shift;258 my $pbinit = shift;259 my %pdir;260 261 pb_log(1,"pb_cms_compliant: envar: $envar - defdir: $defdir - uri: $uri\n");262 my ($pdir) = pb_conf_get_if($param) if (defined $param);263 if (defined $pdir) {264 %pdir = %$pdir;265 }266 267 268 if ((defined $pdir) && (%pdir) && (defined $pdir{$ENV{'PBPROJ'}})) {269 # That's always the environment variable that will be used270 $ENV{$envar} = $pdir{$ENV{'PBPROJ'}};271 } else {272 if (defined $param) {273 pb_log(1,"WARNING: no $param defined, using $defdir\n");274 pb_log(1," Please create a $param reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");275 pb_log(1," if you want to use another directory\n");276 }277 $ENV{$envar} = "$defdir";278 }279 280 # Expand potential env variable in it281 eval { $ENV{$envar} =~ s/(\$ENV.+\})/$1/eeg };282 pb_log(2,"$envar: $ENV{$envar}\n");283 284 my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri);285 286 if (($scheme !~ /^cvs/) && ($scheme !~ /^svn/) && ($scheme !~ /^svk/) && ($scheme !~ /^hg/) && ($scheme !~ /^git/)) {287 # Do not compare if it's not a real cms288 pb_log(1,"pb_cms_compliant useless\n");289 return;290 } elsif (defined $pbinit) {291 pb_mkdir_p("$ENV{$envar}");292 } elsif (! -d "$ENV{$envar}") {293 # Either we have a version in the uri, and it should be the same294 # as the one in the envar. Or we should add the version to the uri295 if (basename($uri) ne basename($ENV{$envar})) {296 $uri .= "/".basename($ENV{$envar})297 }298 pb_log(1,"Checking out $uri\n");299 # Create structure and remove end dir before exporting300 pb_mkdir_p("$ENV{$envar}");301 pb_rm_rf($ENV{$envar});302 pb_vcs_checkout($scheme,$uri,$ENV{$envar});303 } else {304 pb_log(1,"$uri found locally, checking content\n");305 my $cmsurl = pb_vcs_get_uri($scheme,$ENV{$envar});306 my ($scheme2, $account2, $host2, $port2, $path2) = pb_get_uri($cmsurl);307 # For svk, scheme doesn't appear in svk info so remove it here in uri coming from conf file308 # which needs it to trigger correct behaviour309 $uri =~ s/^svk://;310 if (($scheme2 =~ /^git/) || ($scheme2 =~ /^hg/)) {311 # These VCS manage branches internally not with different tree structures312 # Assuming it's correct for now.313 } elsif ($cmsurl ne $uri) {314 # The local content doesn't correpond to the repository315 pb_log(0,"ERROR: Inconsistency detected:\n");316 pb_log(0," * $ENV{$envar} ($envar) refers to $cmsurl but\n");317 pb_log(0," * $ENV{'PBETC'} refers to $uri\n");318 die "Project $ENV{'PBPROJ'} is not Project-Builder compliant.";319 } else {320 pb_log(1,"Content correct - doing nothing - you may want to update your repository however\n");321 # they match - do nothing - there may be local changes322 }323 }324 pb_log(1,"pb_cms_compliant end\n");325 }326 327 220 =item B<pb_cms_create_authors> 328 221
Note:
See TracChangeset
for help on using the changeset viewer.