Changeset 2312 in ProjectBuilder
- Timestamp:
- Sep 6, 2017, 9:08:46 PM (7 years ago)
- Location:
- devel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/VCS.pm
r2308 r2312 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 pb_vcs_compliant pb_vcs_conf_update_v0);38 our @EXPORT = qw(pb_vcs_init 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 pb_vcs_conf_update_v0); 39 39 ($VERSION,$REVISION) = pb_version_init(); 40 40 … … 52 52 53 53 =over 4 54 55 56 =item B<pb_vcs_init> 57 58 This function setup the environment for the VCS system related to the URL given by the pbprojurl configuration parameter. 59 The potential parameter indicates whether we should inititate the context or not. 60 It sets up environement variables (PBPROJDIR, PBDIR, PBREVISION, PBCMSLOGFILE) 61 62 =cut 63 64 sub pb_vcs_init { 65 66 my $pbinit = shift; 67 my $param = shift; 68 69 my ($pbprojurl) = pb_conf_get("pbprojurl"); 70 confess "Undefined pbprojurl for $ENV{'PBPROJ'}\n" if ((not defined $pbprojurl) or (not defined $pbprojurl->{$ENV{'PBPROJ'}})); 71 pb_log(2,"DEBUG: Project URL of $ENV{'PBPROJ'}: $pbprojurl->{$ENV{'PBPROJ'}}\n"); 72 my ($scheme, $account, $host, $port, $path) = pb_get_uri($pbprojurl->{$ENV{'PBPROJ'}}); 73 my $vcscmd = pb_vcs_cmd($scheme); 74 75 my ($pbprojdir) = pb_conf_get_if("pbprojdir"); 76 77 if ((defined $pbprojdir) && (defined $pbprojdir->{$ENV{'PBPROJ'}})) { 78 $ENV{'PBPROJDIR'} = $pbprojdir->{$ENV{'PBPROJ'}}; 79 } else { 80 $ENV{'PBPROJDIR'} = "$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}"; 81 } 82 # Expand potential env variable in it to allow string replacement 83 eval { $ENV{'PBPROJDIR'} =~ s/(\$ENV.+\})/$1/eeg }; 84 85 86 # Computing the default dir for PBDIR. 87 # what we have is PBPROJDIR so work from that. 88 # Tree identical between PBCONFDIR and PBROOTDIR on one side and 89 # PBPROJDIR and PBDIR on the other side. 90 91 my $tmp = $ENV{'PBROOTDIR'}; 92 $tmp =~ s|^$ENV{'PBCONFDIR'}/||; 93 # If no subdir, then replace again 94 $tmp =~ s|^$ENV{'PBCONFDIR'}||; 95 96 # 97 # Check project cms compliance 98 # 99 my $turl = "$pbprojurl->{$ENV{'PBPROJ'}}/$tmp"; 100 $turl = $pbprojurl->{$ENV{'PBPROJ'}} if ($scheme =~ /^(flat)|(ftp)|(http)|(https)|(file)|(git)\b/o); 101 # git svn is like svn 102 $turl = "$pbprojurl->{$ENV{'PBPROJ'}}/$tmp" if ($scheme =~ /^git\+svn/o); 103 pb_vcs_compliant(undef,'PBDIR',"$ENV{'PBPROJDIR'}/$tmp",$turl,$pbinit); 104 105 106 if ($scheme =~ /^hg/) { 107 $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd identify )`; 108 chomp($tmp); 109 $tmp =~ s/^.* //; 110 $ENV{'PBREVISION'}=$tmp; 111 $ENV{'PBCMSLOGFILE'}="hg.log"; 112 } elsif ($scheme =~ /^git/) { 113 if ($scheme =~ /svn/) { 114 $tmp = `(cd "$ENV{'PBDIR'}" ; LANGUAGE=C $vcscmd info | grep -E '^Revision:' | cut -d: -f2)`; 115 $tmp =~ s/\s+//; 116 } else { 117 $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd log | head -1 | cut -f2)`; 118 $tmp =~ s/^.* //; 119 # Reduce length of commit id to 8 digit 120 $tmp = substr($tmp,1,8); 121 } 122 chomp($tmp); 123 $ENV{'PBREVISION'}=$tmp; 124 $ENV{'PBCMSLOGFILE'}="git.log"; 125 } elsif ($scheme =~ /^(flat)|(ftp)|(http)|(https)|(file)\b/o) { 126 $ENV{'PBREVISION'}="flat"; 127 $ENV{'PBCMSLOGFILE'}="flat.log"; 128 } elsif ($scheme =~ /^svn/) { 129 # svnversion more precise than svn info if sbx 130 if ((defined $param) && ($param eq "CMS")) { 131 $tmp = `(LANGUAGE=C $vcscmd info $pbprojurl->{$ENV{'PBPROJ'}} | grep -E '^Revision:' | cut -d: -f2)`; 132 $tmp =~ s/\s+//; 133 } else { 134 $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd"version" .)`; 135 } 136 chomp($tmp); 137 $ENV{'PBREVISION'}=$tmp; 138 $ENV{'PBCMSLOGFILE'}="svn.log"; 139 } elsif ($scheme =~ /^svk/) { 140 $tmp = `(cd "$ENV{'PBDIR'}" ; LANGUAGE=C $vcscmd info . | grep -E '^Revision:' | cut -d: -f2)`; 141 $tmp =~ s/\s+//; 142 chomp($tmp); 143 $ENV{'PBREVISION'}=$tmp; 144 $ENV{'PBCMSLOGFILE'}="svk.log"; 145 } elsif ($scheme =~ /^cvs/) { 146 # Way too slow 147 #$ENV{'PBREVISION'}=`(cd "$ENV{'PBROOTDIR'}" ; cvs rannotate -f . 2>&1 | awk '{print \$1}' | grep -E '^[0-9]' | cut -d. -f2 |sort -nu | tail -1)`; 148 #chomp($ENV{'PBREVISION'}); 149 $ENV{'PBREVISION'}="cvs"; 150 $ENV{'PBCMSLOGFILE'}="cvs.log"; 151 $ENV{'CVS_RSH'} = "ssh" if ($scheme =~ /ssh/); 152 } else { 153 die "cms $scheme unknown"; 154 } 155 156 pb_log(1,"pb_vcs_init returns $scheme,$pbprojurl->{$ENV{'PBPROJ'}}\n"); 157 return($scheme,$pbprojurl->{$ENV{'PBPROJ'}}); 158 } 159 54 160 55 161 =item B<pb_vcs_export> … … 660 766 The second parameter is the environment variable this key will populate. 661 767 The third parameter is the location of the pbconf dir. 662 The fourth parameter is the URI of the CMS content related to the pbconf dir.768 The fourth parameter is the URI of the VCS content related to the pbconf dir. 663 769 The fifth parameter indicates whether we should inititate the context or not. 664 770 -
devel/pb/bin/pb
r2303 r2312 1181 1181 } 1182 1182 1183 my ($scheme, $uri) = pb_ cms_init($pbinit,$param);1183 my ($scheme, $uri) = pb_vcs_init($pbinit,$param); 1184 1184 1185 1185 # We need 2 lines here … … 3538 3538 3539 3539 # Need this call for PBDIR 3540 my ($scheme2,$uri) = pb_ cms_init($pbinit);3540 my ($scheme2,$uri) = pb_vcs_init($pbinit); 3541 3541 3542 3542 my ($pbconf,$pbprojurl) = pb_conf_get("pbconfurl","pbprojurl"); … … 4300 4300 my $chglog; 4301 4301 4302 pb_ cms_init($pbinit);4302 pb_vcs_init($pbinit); 4303 4303 # Get project info on log file and generate tmp files used later on 4304 4304 $chglog = "$ENV{'PBROOTDIR'}/$pbpkg/pbcl"; -
devel/pb/lib/ProjectBuilder/CMS.pm
r2300 r2312 35 35 36 36 our @ISA = qw(Exporter); 37 our @EXPORT = qw(pb_cms_ init pb_cms_get_pkg pb_cms_get_real_pkg pb_cms_log);37 our @EXPORT = qw(pb_cms_get_pkg pb_cms_get_real_pkg pb_cms_log); 38 38 ($VERSION,$REVISION) = pb_version_init(); 39 39 … … 51 51 52 52 =over 4 53 54 =item B<pb_cms_init>55 56 This function setup the environment for the CMS system related to the URL given by the pbprojurl configuration parameter.57 The potential parameter indicates whether we should inititate the context or not.58 It sets up environement variables (PBPROJDIR, PBDIR, PBREVISION, PBCMSLOGFILE)59 60 =cut61 62 sub pb_cms_init {63 64 my $pbinit = shift;65 my $param = shift;66 67 my ($pbprojurl) = pb_conf_get("pbprojurl");68 confess "Undefined pbprojurl for $ENV{'PBPROJ'}\n" if ((not defined $pbprojurl) or (not defined $pbprojurl->{$ENV{'PBPROJ'}}));69 pb_log(2,"DEBUG: Project URL of $ENV{'PBPROJ'}: $pbprojurl->{$ENV{'PBPROJ'}}\n");70 my ($scheme, $account, $host, $port, $path) = pb_get_uri($pbprojurl->{$ENV{'PBPROJ'}});71 my $vcscmd = pb_vcs_cmd($scheme);72 73 my ($pbprojdir) = pb_conf_get_if("pbprojdir");74 75 if ((defined $pbprojdir) && (defined $pbprojdir->{$ENV{'PBPROJ'}})) {76 $ENV{'PBPROJDIR'} = $pbprojdir->{$ENV{'PBPROJ'}};77 } else {78 $ENV{'PBPROJDIR'} = "$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}";79 }80 # Expand potential env variable in it to allow string replacement81 eval { $ENV{'PBPROJDIR'} =~ s/(\$ENV.+\})/$1/eeg };82 83 84 # Computing the default dir for PBDIR.85 # what we have is PBPROJDIR so work from that.86 # Tree identical between PBCONFDIR and PBROOTDIR on one side and87 # PBPROJDIR and PBDIR on the other side.88 89 my $tmp = $ENV{'PBROOTDIR'};90 $tmp =~ s|^$ENV{'PBCONFDIR'}/||;91 # If no subdir, then replace again92 $tmp =~ s|^$ENV{'PBCONFDIR'}||;93 94 #95 # Check project cms compliance96 #97 my $turl = "$pbprojurl->{$ENV{'PBPROJ'}}/$tmp";98 $turl = $pbprojurl->{$ENV{'PBPROJ'}} if ($scheme =~ /^(flat)|(ftp)|(http)|(https)|(file)|(git)\b/o);99 # git svn is like svn100 $turl = "$pbprojurl->{$ENV{'PBPROJ'}}/$tmp" if ($scheme =~ /^git\+svn/o);101 pb_vcs_compliant(undef,'PBDIR',"$ENV{'PBPROJDIR'}/$tmp",$turl,$pbinit);102 103 104 if ($scheme =~ /^hg/) {105 $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd identify )`;106 chomp($tmp);107 $tmp =~ s/^.* //;108 $ENV{'PBREVISION'}=$tmp;109 $ENV{'PBCMSLOGFILE'}="hg.log";110 } elsif ($scheme =~ /^git/) {111 if ($scheme =~ /svn/) {112 $tmp = `(cd "$ENV{'PBDIR'}" ; LANGUAGE=C $vcscmd info | grep -E '^Revision:' | cut -d: -f2)`;113 $tmp =~ s/\s+//;114 } else {115 $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd log | head -1 | cut -f2)`;116 $tmp =~ s/^.* //;117 # Reduce length of commit id to 8 digit118 $tmp = substr($tmp,1,8);119 }120 chomp($tmp);121 $ENV{'PBREVISION'}=$tmp;122 $ENV{'PBCMSLOGFILE'}="git.log";123 } elsif ($scheme =~ /^(flat)|(ftp)|(http)|(https)|(file)\b/o) {124 $ENV{'PBREVISION'}="flat";125 $ENV{'PBCMSLOGFILE'}="flat.log";126 } elsif ($scheme =~ /^svn/) {127 # svnversion more precise than svn info if sbx128 if ((defined $param) && ($param eq "CMS")) {129 $tmp = `(LANGUAGE=C $vcscmd info $pbprojurl->{$ENV{'PBPROJ'}} | grep -E '^Revision:' | cut -d: -f2)`;130 $tmp =~ s/\s+//;131 } else {132 $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd"version" .)`;133 }134 chomp($tmp);135 $ENV{'PBREVISION'}=$tmp;136 $ENV{'PBCMSLOGFILE'}="svn.log";137 } elsif ($scheme =~ /^svk/) {138 $tmp = `(cd "$ENV{'PBDIR'}" ; LANGUAGE=C $vcscmd info . | grep -E '^Revision:' | cut -d: -f2)`;139 $tmp =~ s/\s+//;140 chomp($tmp);141 $ENV{'PBREVISION'}=$tmp;142 $ENV{'PBCMSLOGFILE'}="svk.log";143 } elsif ($scheme =~ /^cvs/) {144 # Way too slow145 #$ENV{'PBREVISION'}=`(cd "$ENV{'PBROOTDIR'}" ; cvs rannotate -f . 2>&1 | awk '{print \$1}' | grep -E '^[0-9]' | cut -d. -f2 |sort -nu | tail -1)`;146 #chomp($ENV{'PBREVISION'});147 $ENV{'PBREVISION'}="cvs";148 $ENV{'PBCMSLOGFILE'}="cvs.log";149 $ENV{'CVS_RSH'} = "ssh" if ($scheme =~ /ssh/);150 } else {151 die "cms $scheme unknown";152 }153 154 pb_log(1,"pb_cms_init returns $scheme,$pbprojurl->{$ENV{'PBPROJ'}}\n");155 return($scheme,$pbprojurl->{$ENV{'PBPROJ'}});156 }157 53 158 54 =item B<pb_cms_get_pkg>
Note:
See TracChangeset
for help on using the changeset viewer.