[5] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
[405] | 3 | # Project Builder CMS module
|
---|
| 4 | # CMS subroutines brought by the the Project-Builder project
|
---|
| 5 | # which can be easily used by pbinit scripts
|
---|
[5] | 6 | #
|
---|
| 7 | # $Id$
|
---|
| 8 | #
|
---|
| 9 | # Copyright B. Cornec 2007
|
---|
| 10 | # Provided under the GPL v2
|
---|
| 11 |
|
---|
[405] | 12 | package ProjectBuilder::CMS;
|
---|
[9] | 13 |
|
---|
[18] | 14 | use strict 'vars';
|
---|
[9] | 15 | use Data::Dumper;
|
---|
| 16 | use English;
|
---|
[16] | 17 | use File::Basename;
|
---|
[500] | 18 | use File::Copy;
|
---|
[13] | 19 | use POSIX qw(strftime);
|
---|
[17] | 20 | use lib qw (lib);
|
---|
[318] | 21 | use ProjectBuilder::Base;
|
---|
[405] | 22 | use ProjectBuilder::Conf;
|
---|
[5] | 23 |
|
---|
[405] | 24 | # Inherit from the "Exporter" module which handles exporting functions.
|
---|
| 25 |
|
---|
| 26 | use Exporter;
|
---|
| 27 |
|
---|
| 28 | # Export, by default, all the functions into the namespace of
|
---|
| 29 | # any code which uses this module.
|
---|
| 30 |
|
---|
| 31 | our @ISA = qw(Exporter);
|
---|
[539] | 32 | our @EXPORT = qw(pb_cms_init pb_cms_export pb_cms_get_uri pb_cms_copy pb_cms_checkout pb_cms_up pb_cms_checkin pb_cms_isdiff pb_cms_get_pkg pb_cms_get_real_pkg pb_cms_compliant pb_cms_log pb_cms_add);
|
---|
[5] | 33 |
|
---|
[331] | 34 | =pod
|
---|
| 35 |
|
---|
| 36 | =head1 NAME
|
---|
| 37 |
|
---|
[409] | 38 | ProjectBuilder::CMS, part of the project-builder.org
|
---|
[331] | 39 |
|
---|
| 40 | =head1 DESCRIPTION
|
---|
| 41 |
|
---|
[405] | 42 | This modules provides configuration management system functions suitable for pbinit calls.
|
---|
[331] | 43 |
|
---|
[409] | 44 | =head1 USAGE
|
---|
| 45 |
|
---|
| 46 | =over 4
|
---|
| 47 |
|
---|
| 48 | =item B<pb_cms_init>
|
---|
| 49 |
|
---|
| 50 | This function setup the environment for the CMS system related to the URL given by the pburl configuration parameter.
|
---|
| 51 | The potential parameter indicates whether we should inititate the context or not.
|
---|
| 52 | It sets up environement variables (PBPROJDIR, PBDIR, PBREVISION, PBCMSLOGFILE)
|
---|
| 53 |
|
---|
[331] | 54 | =cut
|
---|
| 55 |
|
---|
[395] | 56 | sub pb_cms_init {
|
---|
| 57 |
|
---|
| 58 | my $pbinit = shift || undef;
|
---|
| 59 |
|
---|
| 60 | my ($pburl) = pb_conf_get("pburl");
|
---|
| 61 | pb_log(2,"DEBUG: Project URL of $ENV{'PBPROJ'}: $pburl->{$ENV{'PBPROJ'}}\n");
|
---|
| 62 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($pburl->{$ENV{'PBPROJ'}});
|
---|
[661] | 63 | my $vcscmd = pb_cms_cmd($scheme);
|
---|
[395] | 64 |
|
---|
| 65 | my ($pbprojdir) = pb_conf_get_if("pbprojdir");
|
---|
| 66 |
|
---|
| 67 | if ((defined $pbprojdir) && (defined $pbprojdir->{$ENV{'PBPROJ'}})) {
|
---|
| 68 | $ENV{'PBPROJDIR'} = $pbprojdir->{$ENV{'PBPROJ'}};
|
---|
| 69 | } else {
|
---|
| 70 | $ENV{'PBPROJDIR'} = "$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}";
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | # Computing the default dir for PBDIR.
|
---|
| 74 | # what we have is PBPROJDIR so work from that.
|
---|
| 75 | # Tree identical between PBCONFDIR and PBROOTDIR on one side and
|
---|
| 76 | # PBPROJDIR and PBDIR on the other side.
|
---|
| 77 |
|
---|
| 78 | my $tmp = $ENV{'PBROOTDIR'};
|
---|
| 79 | $tmp =~ s|^$ENV{'PBCONFDIR'}||;
|
---|
| 80 |
|
---|
| 81 | #
|
---|
| 82 | # Check project cms compliance
|
---|
| 83 | #
|
---|
| 84 | pb_cms_compliant(undef,'PBDIR',"$ENV{'PBPROJDIR'}/$tmp",$pburl->{$ENV{'PBPROJ'}},$pbinit);
|
---|
| 85 |
|
---|
[661] | 86 |
|
---|
[612] | 87 | if ($scheme =~ /^hg/) {
|
---|
[661] | 88 | $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd identify )`;
|
---|
[395] | 89 | chomp($tmp);
|
---|
[612] | 90 | $tmp =~ s/^.* //;
|
---|
[395] | 91 | $ENV{'PBREVISION'}=$tmp;
|
---|
[612] | 92 | $ENV{'PBCMSLOGFILE'}="hg.log";
|
---|
[661] | 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";
|
---|
[395] | 99 | } elsif (($scheme eq "file") || ($scheme eq "ftp") || ($scheme eq "http")) {
|
---|
| 100 | $ENV{'PBREVISION'}="flat";
|
---|
| 101 | $ENV{'PBCMSLOGFILE'}="flat.log";
|
---|
[612] | 102 | } elsif ($scheme =~ /^svn/) {
|
---|
[626] | 103 | # svnversion more precise than svn info
|
---|
[661] | 104 | $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd"version" .)`;
|
---|
[612] | 105 | chomp($tmp);
|
---|
| 106 | $ENV{'PBREVISION'}=$tmp;
|
---|
| 107 | $ENV{'PBCMSLOGFILE'}="svn.log";
|
---|
[395] | 108 | } elsif ($scheme =~ /^cvs/) {
|
---|
| 109 | # Way too slow
|
---|
| 110 | #$ENV{'PBREVISION'}=`(cd "$ENV{'PBROOTDIR'}" ; cvs rannotate -f . 2>&1 | awk '{print \$1}' | grep -E '^[0-9]' | cut -d. -f2 |sort -nu | tail -1)`;
|
---|
| 111 | #chomp($ENV{'PBREVISION'});
|
---|
| 112 | $ENV{'PBREVISION'}="cvs";
|
---|
| 113 | $ENV{'PBCMSLOGFILE'}="cvs.log";
|
---|
| 114 | $ENV{'CVS_RSH'} = "ssh" if ($scheme =~ /ssh/);
|
---|
| 115 | } else {
|
---|
| 116 | die "cms $scheme unknown";
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | return($scheme,$pburl->{$ENV{'PBPROJ'}});
|
---|
| 120 | }
|
---|
| 121 |
|
---|
[409] | 122 | =item B<pb_cms_export>
|
---|
| 123 |
|
---|
| 124 | This function exports a CMS content to a directory.
|
---|
| 125 | The first parameter is the URL of the CMS content.
|
---|
[500] | 126 | The second parameter is the directory in which it is locally exposed (result of a checkout). If undef, then use the original CMS content.
|
---|
[409] | 127 | The third parameter is the directory where we want to deliver it (result of export).
|
---|
[537] | 128 | It returns the original tar file if we need to preserve it and undef if we use the produced one.
|
---|
[409] | 129 |
|
---|
| 130 | =cut
|
---|
| 131 |
|
---|
[395] | 132 | sub pb_cms_export {
|
---|
| 133 |
|
---|
| 134 | my $uri = shift;
|
---|
| 135 | my $source = shift;
|
---|
| 136 | my $destdir = shift;
|
---|
| 137 | my $tmp;
|
---|
| 138 | my $tmp1;
|
---|
| 139 |
|
---|
| 140 | my @date = pb_get_date();
|
---|
| 141 | # If it's not flat, then we have a real uri as source
|
---|
| 142 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri);
|
---|
[661] | 143 | my $vcscmd = pb_cms_cmd($scheme);
|
---|
| 144 | $uri = pb_cms_mod_socks($uri);
|
---|
[395] | 145 |
|
---|
| 146 | if ($scheme =~ /^svn/) {
|
---|
[500] | 147 | if (defined $source) {
|
---|
| 148 | if (-d $source) {
|
---|
| 149 | $tmp = $destdir;
|
---|
| 150 | } else {
|
---|
| 151 | $tmp = "$destdir/".basename($source);
|
---|
| 152 | }
|
---|
[661] | 153 | $source = pb_cms_mod_http($source,"svn");
|
---|
| 154 | pb_system("$vcscmd export $source $tmp","Exporting $source from SVN to $tmp ");
|
---|
[395] | 155 | } else {
|
---|
[661] | 156 | $uri = pb_cms_mod_http($uri,"svn");
|
---|
| 157 | pb_system("$vcscmd export $uri $destdir","Exporting $uri from SVN to $destdir ");
|
---|
[395] | 158 | }
|
---|
| 159 | } elsif ($scheme eq "dir") {
|
---|
[681] | 160 | pb_system("cp -r $path $destdir","Copying $uri from DIR to $destdir ");
|
---|
[395] | 161 | } elsif (($scheme eq "http") || ($scheme eq "ftp")) {
|
---|
| 162 | my $f = basename($path);
|
---|
| 163 | unlink "$ENV{'PBTMP'}/$f";
|
---|
[661] | 164 | pb_system("$vcscmd $ENV{'PBTMP'}/$f $uri","Downloading $uri with $vcscmd to $ENV{'PBTMP'}/$f\n");
|
---|
[537] | 165 | # We want to preserve the original tar file
|
---|
[395] | 166 | pb_cms_export("file://$ENV{'PBTMP'}/$f",$source,$destdir);
|
---|
[537] | 167 | return("$ENV{'PBTMP'}/$f");
|
---|
[395] | 168 | } elsif ($scheme eq "file") {
|
---|
| 169 | use File::MimeInfo;
|
---|
| 170 | my $mm = mimetype($path);
|
---|
| 171 | pb_log(2,"mimetype: $mm\n");
|
---|
| 172 |
|
---|
[500] | 173 | if (defined $source) {
|
---|
| 174 | # Check whether the file is well formed
|
---|
| 175 | # (containing already a directory with the project-version name)
|
---|
[537] | 176 | #
|
---|
| 177 | # If it's not the case, we try to adapt, but distro needing
|
---|
| 178 | # to verify the checksum will have issues (Fedora)
|
---|
| 179 | # Then upstream should be notified that they need to change their rules
|
---|
[500] | 180 | my ($pbwf) = pb_conf_get_if("pbwf");
|
---|
| 181 | if ((defined $pbwf) && (defined $pbwf->{$ENV{'PBPROJ'}})) {
|
---|
| 182 | $destdir = dirname($destdir);
|
---|
| 183 | }
|
---|
[395] | 184 | }
|
---|
[537] | 185 | pb_mkdir_p($destdir);
|
---|
[395] | 186 |
|
---|
| 187 | if ($mm =~ /\/x-bzip-compressed-tar$/) {
|
---|
| 188 | # tar+bzip2
|
---|
[590] | 189 | pb_system("cd $destdir ; tar xfj $path","Extracting $path in $destdir ");
|
---|
[395] | 190 | } elsif ($mm =~ /\/x-lzma-compressed-tar$/) {
|
---|
| 191 | # tar+lzma
|
---|
[590] | 192 | pb_system("cd $destdir ; tar xfY $path","Extracting $path in $destdir ");
|
---|
[395] | 193 | } elsif ($mm =~ /\/x-compressed-tar$/) {
|
---|
| 194 | # tar+gzip
|
---|
[590] | 195 | pb_system("cd $destdir ; tar xfz $path","Extracting $path in $destdir ");
|
---|
[395] | 196 | } elsif ($mm =~ /\/x-tar$/) {
|
---|
| 197 | # tar
|
---|
[590] | 198 | pb_system("cd $destdir ; tar xf $path","Extracting $path in $destdir ");
|
---|
[395] | 199 | } elsif ($mm =~ /\/zip$/) {
|
---|
| 200 | # zip
|
---|
[590] | 201 | pb_system("cd $destdir ; unzip $path","Extracting $path in $destdir ");
|
---|
[500] | 202 | } else {
|
---|
| 203 | # simple file: copy it (patch e.g.)
|
---|
| 204 | copy($path,$destdir);
|
---|
[395] | 205 | }
|
---|
[612] | 206 | } elsif ($scheme =~ /^hg/) {
|
---|
| 207 | if (defined $source) {
|
---|
| 208 | if (-d $source) {
|
---|
| 209 | $tmp = $destdir;
|
---|
| 210 | } else {
|
---|
| 211 | $tmp = "$destdir/".basename($source);
|
---|
| 212 | }
|
---|
[661] | 213 | $source = pb_cms_mod_http($source,"hg");
|
---|
| 214 | pb_system("cd $source ; $vcscmd archive $tmp","Exporting $source from Mercurial to $tmp ");
|
---|
[612] | 215 | } else {
|
---|
[661] | 216 | $uri = pb_cms_mod_http($uri,"hg");
|
---|
| 217 | pb_system("$vcscmd clone $uri $destdir","Exporting $uri from Mercurial to $destdir ");
|
---|
[612] | 218 | }
|
---|
[661] | 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 ");
|
---|
| 231 | }
|
---|
[395] | 232 | } elsif ($scheme =~ /^cvs/) {
|
---|
| 233 | # CVS needs a relative path !
|
---|
| 234 | my $dir=dirname($destdir);
|
---|
| 235 | my $base=basename($destdir);
|
---|
[500] | 236 | if (defined $source) {
|
---|
| 237 | # CVS also needs a modules name not a dir
|
---|
[395] | 238 | $tmp1 = basename($source);
|
---|
[500] | 239 | } else {
|
---|
| 240 | # Probably not right, should be checked, but that way I'll notice it :-)
|
---|
| 241 | $tmp1 = $uri;
|
---|
| 242 | }
|
---|
[395] | 243 | # If we're working on the CVS itself
|
---|
| 244 | my $cvstag = basename($ENV{'PBROOTDIR'});
|
---|
| 245 | my $cvsopt = "";
|
---|
| 246 | if ($cvstag eq "cvs") {
|
---|
| 247 | my $pbdate = strftime("%Y-%m-%d %H:%M:%S", @date);
|
---|
| 248 | $cvsopt = "-D \"$pbdate\"";
|
---|
| 249 | } else {
|
---|
| 250 | # we're working on a tag which should be the last part of PBROOTDIR
|
---|
| 251 | $cvsopt = "-r $cvstag";
|
---|
| 252 | }
|
---|
[661] | 253 | pb_system("cd $dir ; $vcscmd -d $account\@$host:$path export $cvsopt -d $base $tmp1","Exporting $tmp1 from $source under CVS to $destdir ");
|
---|
[395] | 254 | } else {
|
---|
| 255 | die "cms $scheme unknown";
|
---|
| 256 | }
|
---|
[537] | 257 | return(undef);
|
---|
[395] | 258 | }
|
---|
| 259 |
|
---|
[409] | 260 | =item B<pb_cms_get_uri>
|
---|
| 261 |
|
---|
| 262 | This function is only called with a real CMS system and gives the URL stored in the checked out directory.
|
---|
| 263 | The first parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)
|
---|
| 264 | The second parameter is the directory in which it is locally exposed (result of a checkout).
|
---|
| 265 |
|
---|
| 266 | =cut
|
---|
| 267 |
|
---|
[395] | 268 | sub pb_cms_get_uri {
|
---|
| 269 |
|
---|
| 270 | my $scheme = shift;
|
---|
| 271 | my $dir = shift;
|
---|
| 272 |
|
---|
| 273 | my $res = "";
|
---|
| 274 | my $void = "";
|
---|
[661] | 275 | my $vcscmd = pb_cms_cmd($scheme);
|
---|
[395] | 276 |
|
---|
| 277 | if ($scheme =~ /^svn/) {
|
---|
[661] | 278 | open(PIPE,"LANGUAGE=C $vcscmd info $dir |") || return("");
|
---|
[395] | 279 | while (<PIPE>) {
|
---|
| 280 | ($void,$res) = split(/^URL:/) if (/^URL:/);
|
---|
| 281 | }
|
---|
| 282 | $res =~ s/^\s*//;
|
---|
| 283 | close(PIPE);
|
---|
| 284 | chomp($res);
|
---|
[612] | 285 | } elsif ($scheme =~ /^hg/) {
|
---|
| 286 | open(HGRC,".hg/hgrc/") || return("");
|
---|
| 287 | while (<HGRC>) {
|
---|
| 288 | ($void,$res) = split(/^default.*=/) if (/^default.*=/);
|
---|
| 289 | }
|
---|
| 290 | close(HGRC);
|
---|
| 291 | chomp($res);
|
---|
[661] | 292 | } elsif ($scheme =~ /^git/) {
|
---|
| 293 | open(GITRC,".git/gitrc/") || return("");
|
---|
| 294 | while (<GITRC>) {
|
---|
| 295 | ($void,$res) = split(/^default.*=/) if (/^default.*=/);
|
---|
| 296 | }
|
---|
| 297 | close(GITRC);
|
---|
| 298 | chomp($res);
|
---|
[395] | 299 | } elsif ($scheme =~ /^cvs/) {
|
---|
| 300 | # This path is always the root path of CVS, but we may be below
|
---|
| 301 | open(FILE,"$dir/CVS/Root") || die "$dir isn't CVS controlled";
|
---|
| 302 | $res = <FILE>;
|
---|
| 303 | chomp($res);
|
---|
| 304 | close(FILE);
|
---|
| 305 | # Find where we are in the tree
|
---|
| 306 | my $rdir = $dir;
|
---|
| 307 | while ((! -d "$rdir/CVSROOT") && ($rdir ne "/")) {
|
---|
| 308 | $rdir = dirname($rdir);
|
---|
| 309 | }
|
---|
| 310 | die "Unable to find a CVSROOT dir in the parents of $dir" if (! -d "$rdir/CVSROOT");
|
---|
| 311 | #compute our place under that root dir - should be a relative path
|
---|
| 312 | $dir =~ s|^$rdir||;
|
---|
| 313 | my $suffix = "";
|
---|
| 314 | $suffix = "$dir" if ($dir ne "");
|
---|
| 315 |
|
---|
| 316 | my $prefix = "";
|
---|
| 317 | if ($scheme =~ /ssh/) {
|
---|
| 318 | $prefix = "cvs+ssh://";
|
---|
| 319 | } else {
|
---|
| 320 | $prefix = "cvs://";
|
---|
| 321 | }
|
---|
| 322 | $res = $prefix.$res.$suffix;
|
---|
| 323 | } else {
|
---|
| 324 | die "cms $scheme unknown";
|
---|
| 325 | }
|
---|
| 326 | pb_log(2,"Found CMS info: $res\n");
|
---|
| 327 | return($res);
|
---|
| 328 | }
|
---|
| 329 |
|
---|
[409] | 330 | =item B<pb_cms_copy>
|
---|
| 331 |
|
---|
| 332 | This function copies a CMS content to another.
|
---|
| 333 | The first parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)
|
---|
| 334 | The second parameter is the URL of the original CMS content.
|
---|
| 335 | The third parameter is the URL of the destination CMS content.
|
---|
| 336 |
|
---|
[612] | 337 | Only coded for SVN now as used for pbconf itself not the project
|
---|
[409] | 338 |
|
---|
| 339 | =cut
|
---|
| 340 |
|
---|
[395] | 341 | sub pb_cms_copy {
|
---|
| 342 | my $scheme = shift;
|
---|
| 343 | my $oldurl = shift;
|
---|
| 344 | my $newurl = shift;
|
---|
[661] | 345 | my $vcscmd = pb_cms_cmd($scheme);
|
---|
| 346 | $oldurl = pb_cms_mod_socks($oldurl);
|
---|
| 347 | $newurl = pb_cms_mod_socks($newurl);
|
---|
[395] | 348 |
|
---|
| 349 | if ($scheme =~ /^svn/) {
|
---|
[661] | 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 ");
|
---|
[395] | 353 | } elsif ($scheme eq "flat") {
|
---|
| 354 | } elsif ($scheme =~ /^cvs/) {
|
---|
| 355 | } else {
|
---|
| 356 | die "cms $scheme unknown";
|
---|
| 357 | }
|
---|
| 358 | }
|
---|
| 359 |
|
---|
[409] | 360 | =item B<pb_cms_checkout>
|
---|
| 361 |
|
---|
| 362 | This function checks a CMS content out to a directory.
|
---|
| 363 | The first parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)
|
---|
| 364 | The second parameter is the URL of the CMS content.
|
---|
| 365 | The third parameter is the directory where we want to deliver it (result of export).
|
---|
| 366 |
|
---|
| 367 | =cut
|
---|
| 368 |
|
---|
[395] | 369 | sub pb_cms_checkout {
|
---|
| 370 | my $scheme = shift;
|
---|
| 371 | my $url = shift;
|
---|
| 372 | my $destination = shift;
|
---|
[661] | 373 | my $vcscmd = pb_cms_cmd($scheme);
|
---|
| 374 | $url = pb_cms_mod_socks($url);
|
---|
[395] | 375 |
|
---|
| 376 | if ($scheme =~ /^svn/) {
|
---|
[661] | 377 | $url = pb_cms_mod_http($url,"svn");
|
---|
| 378 | pb_system("$vcscmd co $url $destination","Checking out $url to $destination ");
|
---|
[612] | 379 | } elsif ($scheme =~ /^hg/) {
|
---|
[661] | 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 ");
|
---|
[395] | 385 | } elsif (($scheme eq "ftp") || ($scheme eq "http")) {
|
---|
| 386 | return;
|
---|
| 387 | } elsif ($scheme =~ /^cvs/) {
|
---|
[527] | 388 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($url);
|
---|
| 389 |
|
---|
| 390 | # If we're working on the CVS itself
|
---|
| 391 | my $cvstag = basename($ENV{'PBROOTDIR'});
|
---|
| 392 | my $cvsopt = "";
|
---|
| 393 | if ($cvstag eq "cvs") {
|
---|
| 394 | my @date = pb_get_date();
|
---|
| 395 | my $pbdate = strftime("%Y-%m-%d %H:%M:%S", @date);
|
---|
| 396 | $cvsopt = "-D \"$pbdate\"";
|
---|
| 397 | } else {
|
---|
| 398 | # we're working on a tag which should be the last part of PBROOTDIR
|
---|
| 399 | $cvsopt = "-r $cvstag";
|
---|
| 400 | }
|
---|
| 401 | pb_mkdir_p("$destination");
|
---|
[661] | 402 | pb_system("cd $destination ; $vcscmd -d $account\@$host:$path co $cvsopt .","Checking out $url to $destination ");
|
---|
[500] | 403 | } elsif ($scheme =~ /^file/) {
|
---|
| 404 | pb_cms_export($url,undef,$destination);
|
---|
[395] | 405 | } else {
|
---|
| 406 | die "cms $scheme unknown";
|
---|
| 407 | }
|
---|
| 408 | }
|
---|
| 409 |
|
---|
[409] | 410 | =item B<pb_cms_up>
|
---|
| 411 |
|
---|
| 412 | This function updates a local directory with the CMS content.
|
---|
| 413 | The first parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)
|
---|
| 414 | The second parameter is the directory to update.
|
---|
| 415 |
|
---|
| 416 | =cut
|
---|
| 417 |
|
---|
[395] | 418 | sub pb_cms_up {
|
---|
| 419 | my $scheme = shift;
|
---|
| 420 | my $dir = shift;
|
---|
[661] | 421 | my $vcscmd = pb_cms_cmd($scheme);
|
---|
[395] | 422 |
|
---|
[661] | 423 | if (($scheme =~ /^svn/) || ($scheme =~ /^hg/) || ($scheme =~ /^git/) || ($scheme =~ /^cvs/)) {
|
---|
| 424 | pb_system("$vcscmd up $dir","Updating $dir ");
|
---|
[395] | 425 | } elsif ($scheme eq "flat") {
|
---|
| 426 | } else {
|
---|
| 427 | die "cms $scheme unknown";
|
---|
| 428 | }
|
---|
| 429 | }
|
---|
| 430 |
|
---|
[409] | 431 | =item B<pb_cms_checkin>
|
---|
| 432 |
|
---|
| 433 | This function updates a CMS content from a local directory.
|
---|
| 434 | The first parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)
|
---|
| 435 | The second parameter is the directory to update from.
|
---|
[452] | 436 | The third parameter indicates if we are in a new version creation (undef) or in a new project creation (1)
|
---|
[409] | 437 |
|
---|
| 438 | =cut
|
---|
| 439 |
|
---|
[395] | 440 | sub pb_cms_checkin {
|
---|
| 441 | my $scheme = shift;
|
---|
| 442 | my $dir = shift;
|
---|
[452] | 443 | my $pbinit = shift || undef;
|
---|
[661] | 444 | my $vcscmd = pb_cms_cmd($scheme);
|
---|
[395] | 445 |
|
---|
| 446 | my $ver = basename($dir);
|
---|
[452] | 447 | my $msg = "updated to $ver";
|
---|
| 448 | $msg = "Project $ENV{PBPROJ} creation" if (defined $pbinit);
|
---|
| 449 |
|
---|
[661] | 450 | if (($scheme =~ /^svn/) || ($scheme =~ /^hg/) || ($scheme =~ /^git/) || ($scheme =~ /^cvs/)) {
|
---|
| 451 | pb_system("cd $dir ; $vcscmd ci -m \"$msg\" .","Checking in $dir ");
|
---|
[395] | 452 | } elsif ($scheme eq "flat") {
|
---|
| 453 | } else {
|
---|
| 454 | die "cms $scheme unknown";
|
---|
| 455 | }
|
---|
| 456 | pb_cms_up($scheme,$dir);
|
---|
| 457 | }
|
---|
| 458 |
|
---|
[452] | 459 | =item B<pb_cms_add>
|
---|
| 460 |
|
---|
| 461 | This function adds to a CMS content from a local directory.
|
---|
| 462 | The first parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)
|
---|
| 463 | The second parameter is the directory/file to add.
|
---|
| 464 |
|
---|
| 465 | =cut
|
---|
| 466 |
|
---|
| 467 | sub pb_cms_add {
|
---|
| 468 | my $scheme = shift;
|
---|
| 469 | my $f = shift;
|
---|
[661] | 470 | my $vcscmd = pb_cms_cmd($scheme);
|
---|
[452] | 471 |
|
---|
[661] | 472 | if (($scheme =~ /^svn/) || ($scheme =~ /^hg/) || ($scheme =~ /^git/) || ($scheme =~ /^cvs/)) {
|
---|
| 473 | pb_system("$vcscmd add $f","Adding $f to VCS ");
|
---|
[452] | 474 | } elsif ($scheme eq "flat") {
|
---|
| 475 | } else {
|
---|
| 476 | die "cms $scheme unknown";
|
---|
| 477 | }
|
---|
| 478 | pb_cms_up($scheme,$f);
|
---|
| 479 | }
|
---|
| 480 |
|
---|
[409] | 481 | =item B<pb_cms_isdiff>
|
---|
| 482 |
|
---|
| 483 | This function returns a integer indicating the number f differences between the CMS content and the local directory where it's checked out.
|
---|
| 484 | The first parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)
|
---|
| 485 | The second parameter is the directory to consider.
|
---|
| 486 |
|
---|
| 487 | =cut
|
---|
| 488 |
|
---|
[395] | 489 | sub pb_cms_isdiff {
|
---|
| 490 | my $scheme = shift;
|
---|
| 491 | my $dir =shift;
|
---|
[661] | 492 | my $vcscmd = pb_cms_cmd($scheme);
|
---|
[395] | 493 |
|
---|
[661] | 494 | if (($scheme =~ /^svn/) || ($scheme =~ /^hg/) || ($scheme =~ /^git/) || ($scheme =~ /^cvs/)) {
|
---|
| 495 | open(PIPE,"$vcscmd diff $dir |") || die "Unable to get $vcscmd diff from $dir";
|
---|
[395] | 496 | my $l = 0;
|
---|
| 497 | while (<PIPE>) {
|
---|
[661] | 498 | # Skipping normal messages in case of CVS
|
---|
| 499 | next if (/^cvs diff:/);
|
---|
[395] | 500 | $l++;
|
---|
| 501 | }
|
---|
| 502 | return($l);
|
---|
| 503 | } elsif ($scheme eq "flat") {
|
---|
| 504 | } else {
|
---|
| 505 | die "cms $scheme unknown";
|
---|
| 506 | }
|
---|
| 507 | }
|
---|
| 508 |
|
---|
[539] | 509 | =item B<pb_cms_get_pkg>
|
---|
[409] | 510 |
|
---|
| 511 | This function returns the list of packages we are working on in a CMS action.
|
---|
| 512 | The first parameter is the default list of packages from the configuration file.
|
---|
| 513 | The second parameter is the optional list of packages from the configuration file.
|
---|
| 514 |
|
---|
| 515 | =cut
|
---|
| 516 |
|
---|
[395] | 517 | sub pb_cms_get_pkg {
|
---|
| 518 |
|
---|
| 519 | my @pkgs = ();
|
---|
| 520 | my $defpkgdir = shift || undef;
|
---|
| 521 | my $extpkgdir = shift || undef;
|
---|
| 522 |
|
---|
| 523 | # Get packages list
|
---|
| 524 | if (not defined $ARGV[0]) {
|
---|
| 525 | @pkgs = keys %$defpkgdir if (defined $defpkgdir);
|
---|
| 526 | } elsif ($ARGV[0] =~ /^all$/) {
|
---|
| 527 | @pkgs = keys %$defpkgdir if (defined $defpkgdir);
|
---|
| 528 | push(@pkgs, keys %$extpkgdir) if (defined $extpkgdir);
|
---|
| 529 | } else {
|
---|
| 530 | @pkgs = @ARGV;
|
---|
| 531 | }
|
---|
| 532 | pb_log(0,"Packages: ".join(',',@pkgs)."\n");
|
---|
| 533 | return(\@pkgs);
|
---|
| 534 | }
|
---|
| 535 |
|
---|
[539] | 536 | =item B<pb_cms_get_real_pkg>
|
---|
| 537 |
|
---|
| 538 | This function returns the real name of a virtual package we are working on in a CMS action.
|
---|
| 539 | It supports the following types: perl.
|
---|
| 540 | The first parameter is the virtual package name
|
---|
| 541 |
|
---|
| 542 | =cut
|
---|
| 543 |
|
---|
| 544 | sub pb_cms_get_real_pkg {
|
---|
| 545 |
|
---|
| 546 | my $pbpkg = shift || undef;
|
---|
| 547 | my $dtype = shift;
|
---|
| 548 | my $pbpkgreal = $pbpkg;
|
---|
| 549 |
|
---|
| 550 | my @nametype = pb_conf_get_if("namingtype");
|
---|
| 551 | my $type = $nametype[0]->{$pbpkg};
|
---|
| 552 | if (defined $type) {
|
---|
| 553 | if ($type eq "perl") {
|
---|
| 554 | if ($dtype eq "rpm") {
|
---|
| 555 | $pbpkgreal = "perl-".$pbpkg;
|
---|
| 556 | } elsif ($dtype eq "deb") {
|
---|
[544] | 557 | # Only lower case allowed in Debian
|
---|
| 558 | # Cf: http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Package
|
---|
[539] | 559 | $pbpkgreal = "lib".lc($pbpkg)."-perl";
|
---|
| 560 | } elsif ($dtype eq "ebuild") {
|
---|
| 561 | $pbpkgreal = $pbpkg;
|
---|
| 562 | } else {
|
---|
| 563 | die "pb_cms_get_real_pkg not implemented for $dtype yet";
|
---|
| 564 | }
|
---|
| 565 | } else {
|
---|
| 566 | die "nametype $type not implemented yet";
|
---|
| 567 | }
|
---|
| 568 | }
|
---|
| 569 |
|
---|
| 570 | pb_log(2,"Real Package: $pbpkgreal\n");
|
---|
| 571 | return($pbpkgreal);
|
---|
| 572 | }
|
---|
| 573 |
|
---|
[409] | 574 | =item B<pb_cms_compliant>
|
---|
| 575 |
|
---|
| 576 | This function checks the compliance of the project and the pbconf directory.
|
---|
| 577 | The first parameter is the key name of the value that needs to be read in the configuration file.
|
---|
| 578 | The second parameter is the environment variable this key will populate.
|
---|
| 579 | The third parameter is the location of the pbconf dir.
|
---|
| 580 | The fourth parameter is the URI of the CMS content related to the pbconf dir.
|
---|
| 581 | The fifth parameter indicates whether we should inititate the context or not.
|
---|
| 582 |
|
---|
| 583 | =cut
|
---|
| 584 |
|
---|
[395] | 585 | sub pb_cms_compliant {
|
---|
| 586 |
|
---|
| 587 | my $param = shift;
|
---|
| 588 | my $envar = shift;
|
---|
| 589 | my $defdir = shift;
|
---|
| 590 | my $uri = shift;
|
---|
| 591 | my $pbinit = shift;
|
---|
| 592 | my %pdir;
|
---|
| 593 |
|
---|
| 594 | my ($pdir) = pb_conf_get_if($param) if (defined $param);
|
---|
| 595 | if (defined $pdir) {
|
---|
| 596 | %pdir = %$pdir;
|
---|
| 597 | }
|
---|
| 598 |
|
---|
| 599 |
|
---|
| 600 | if ((defined $pdir) && (%pdir) && (defined $pdir{$ENV{'PBPROJ'}})) {
|
---|
| 601 | # That's always the environment variable that will be used
|
---|
| 602 | $ENV{$envar} = $pdir{$ENV{'PBPROJ'}};
|
---|
| 603 | } else {
|
---|
| 604 | if (defined $param) {
|
---|
| 605 | pb_log(1,"WARNING: no $param defined, using $defdir\n");
|
---|
| 606 | pb_log(1," Please create a $param reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
|
---|
| 607 | pb_log(1," if you want to use another directory\n");
|
---|
| 608 | }
|
---|
| 609 | $ENV{$envar} = "$defdir";
|
---|
| 610 | }
|
---|
| 611 |
|
---|
| 612 | # Expand potential env variable in it
|
---|
| 613 | eval { $ENV{$envar} =~ s/(\$ENV.+\})/$1/eeg };
|
---|
| 614 | pb_log(2,"$envar: $ENV{$envar}\n");
|
---|
| 615 |
|
---|
| 616 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri);
|
---|
| 617 |
|
---|
| 618 | if ((! -d "$ENV{$envar}") || (defined $pbinit)) {
|
---|
| 619 | if (defined $pbinit) {
|
---|
| 620 | pb_mkdir_p("$ENV{$envar}");
|
---|
| 621 | } else {
|
---|
[736] | 622 | # Either we have a version in the uri, and it should be the same
|
---|
| 623 | # as the one in the envar. Or we should add the version to the uri
|
---|
| 624 | if (basename($uri) ne basename($ENV{$envar})) {
|
---|
| 625 | $uri .= "/".basename($ENV{$envar})
|
---|
| 626 | }
|
---|
[395] | 627 | pb_log(1,"Checking out $uri\n");
|
---|
| 628 | pb_cms_checkout($scheme,$uri,$ENV{$envar});
|
---|
| 629 | }
|
---|
[661] | 630 | } elsif (($scheme !~ /^cvs/) || ($scheme !~ /^svn/) || ($scheme !~ /^hg/) || ($scheme !~ /^git/) ) {
|
---|
[395] | 631 | # Do not compare if it's not a real cms
|
---|
| 632 | return;
|
---|
| 633 | } else {
|
---|
| 634 | pb_log(1,"$uri found locally, checking content\n");
|
---|
| 635 | my $cmsurl = pb_cms_get_uri($scheme,$ENV{$envar});
|
---|
| 636 | my ($scheme2, $account2, $host2, $port2, $path2) = pb_get_uri($cmsurl);
|
---|
| 637 | if ($cmsurl ne $uri) {
|
---|
| 638 | # The local content doesn't correpond to the repository
|
---|
| 639 | pb_log(0,"ERROR: Inconsistency detected:\n");
|
---|
| 640 | pb_log(0," * $ENV{$envar} refers to $cmsurl but\n");
|
---|
| 641 | pb_log(0," * $ENV{'PBETC'} refers to $uri\n");
|
---|
| 642 | die "Project $ENV{'PBPROJ'} is not Project-Builder compliant.";
|
---|
| 643 | } else {
|
---|
| 644 | pb_log(1,"Content correct - doing nothing - you may want to update your repository however\n");
|
---|
| 645 | # they match - do nothing - there may be local changes
|
---|
| 646 | }
|
---|
| 647 | }
|
---|
| 648 | }
|
---|
| 649 |
|
---|
[409] | 650 | =item B<pb_cms_create_authors>
|
---|
| 651 |
|
---|
| 652 | This function creates a AUTHORS files for the project. It call it AUTHORS.pb if an AUTHORS file already exists.
|
---|
| 653 | The first parameter is the source file for authors information.
|
---|
| 654 | The second parameter is the directory where to create the final AUTHORS file.
|
---|
| 655 | The third parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)
|
---|
| 656 |
|
---|
| 657 | =cut
|
---|
| 658 |
|
---|
[405] | 659 | sub pb_cms_create_authors {
|
---|
[395] | 660 |
|
---|
[405] | 661 | my $authors=shift;
|
---|
| 662 | my $dest=shift;
|
---|
| 663 | my $scheme=shift;
|
---|
[395] | 664 |
|
---|
[405] | 665 | return if ($authors eq "/dev/null");
|
---|
| 666 | open(SAUTH,$authors) || die "Unable to open $authors";
|
---|
[409] | 667 | # Save a potentially existing AUTHORS file and write instead to AUTHORS.pb
|
---|
[405] | 668 | my $ext = "";
|
---|
| 669 | if (-f "$dest/AUTHORS") {
|
---|
| 670 | $ext = ".pb";
|
---|
[395] | 671 | }
|
---|
[405] | 672 | open(DAUTH,"> $dest/AUTHORS$ext") || die "Unable to create $dest/AUTHORS$ext";
|
---|
| 673 | print DAUTH "Authors of the project are:\n";
|
---|
| 674 | print DAUTH "===========================\n";
|
---|
| 675 | while (<SAUTH>) {
|
---|
| 676 | my ($nick,$gcos) = split(/:/);
|
---|
| 677 | chomp($gcos);
|
---|
| 678 | print DAUTH "$gcos";
|
---|
| 679 | if (defined $scheme) {
|
---|
| 680 | # Do not give a scheme for flat types
|
---|
| 681 | my $endstr="";
|
---|
| 682 | if ("$ENV{'PBREVISION'}" ne "flat") {
|
---|
| 683 | $endstr = " under $scheme";
|
---|
| 684 | }
|
---|
| 685 | print DAUTH " ($nick$endstr)\n";
|
---|
| 686 | } else {
|
---|
| 687 | print DAUTH "\n";
|
---|
| 688 | }
|
---|
[395] | 689 | }
|
---|
[405] | 690 | close(DAUTH);
|
---|
| 691 | close(SAUTH);
|
---|
[395] | 692 | }
|
---|
| 693 |
|
---|
[409] | 694 | =item B<pb_cms_log>
|
---|
| 695 |
|
---|
| 696 | This function creates a ChangeLog file for the project.
|
---|
| 697 | The first parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)
|
---|
| 698 | The second parameter is the directory where the CMS content was checked out.
|
---|
| 699 | The third parameter is the directory where to create the final ChangeLog file.
|
---|
| 700 | The fourth parameter is unused.
|
---|
| 701 | The fifth parameter is the source file for authors information.
|
---|
| 702 |
|
---|
| 703 | It may use a tool like svn2cl or cvs2cl to generate it if present, or the log file from the CMS if not.
|
---|
| 704 |
|
---|
| 705 | =cut
|
---|
| 706 |
|
---|
| 707 |
|
---|
[405] | 708 | sub pb_cms_log {
|
---|
[395] | 709 |
|
---|
[405] | 710 | my $scheme = shift;
|
---|
| 711 | my $pkgdir = shift;
|
---|
| 712 | my $dest = shift;
|
---|
| 713 | my $chglog = shift;
|
---|
| 714 | my $authors = shift;
|
---|
[448] | 715 | my $testver = shift || undef;
|
---|
[395] | 716 |
|
---|
[405] | 717 | pb_cms_create_authors($authors,$dest,$scheme);
|
---|
[661] | 718 | my $vcscmd = pb_cms_cmd($scheme);
|
---|
[395] | 719 |
|
---|
[448] | 720 | if ((defined $testver) && (defined $testver->{$ENV{'PBPROJ'}}) && ($testver->{$ENV{'PBPROJ'}} =~ /true/i)) {
|
---|
| 721 | if (! -f "$dest/ChangeLog") {
|
---|
| 722 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 723 | # We need a minimal version for debian type of build
|
---|
| 724 | print CL "\n";
|
---|
| 725 | print CL "\n";
|
---|
| 726 | print CL "\n";
|
---|
| 727 | print CL "\n";
|
---|
| 728 | print CL "1990-01-01 none\n";
|
---|
| 729 | print CL "\n";
|
---|
| 730 | print CL " * test version\n";
|
---|
| 731 | print CL "\n";
|
---|
| 732 | close(CL);
|
---|
| 733 | pb_log(0,"Generating fake ChangeLog for test version\n");
|
---|
| 734 | open(CL,"> $dest/$ENV{'PBCMSLOGFILE'}") || die "Unable to create $dest/$ENV{'PBCMSLOGFILE'}";
|
---|
| 735 | close(CL);
|
---|
| 736 | }
|
---|
| 737 | }
|
---|
| 738 |
|
---|
[405] | 739 | if ($scheme =~ /^svn/) {
|
---|
| 740 | if (! -f "$dest/ChangeLog") {
|
---|
[448] | 741 | # In case we have no network, just create an empty one before to allow correct build
|
---|
| 742 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 743 | close(CL);
|
---|
[405] | 744 | if (-x "/usr/bin/svn2cl") {
|
---|
| 745 | pb_system("/usr/bin/svn2cl --group-by-day --authors=$authors -i -o $dest/ChangeLog $pkgdir","Generating ChangeLog from SVN with svn2cl");
|
---|
[395] | 746 | } else {
|
---|
[405] | 747 | # To be written from pbcl
|
---|
[661] | 748 | pb_system("$vcscmd log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVN");
|
---|
[395] | 749 | }
|
---|
[405] | 750 | }
|
---|
[612] | 751 | } elsif ($scheme =~ /^hg/) {
|
---|
| 752 | if (! -f "$dest/ChangeLog") {
|
---|
| 753 | # In case we have no network, just create an empty one before to allow correct build
|
---|
| 754 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 755 | close(CL);
|
---|
[661] | 756 | pb_system("$vcscmd log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVN");
|
---|
[612] | 757 | }
|
---|
[661] | 758 | } elsif ($scheme =~ /^git/) {
|
---|
| 759 | if (! -f "$dest/ChangeLog") {
|
---|
| 760 | # In case we have no network, just create an empty one before to allow correct build
|
---|
| 761 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 762 | close(CL);
|
---|
| 763 | pb_system("$vcscmd log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from GIT");
|
---|
| 764 | }
|
---|
[405] | 765 | } elsif (($scheme eq "file") || ($scheme eq "dir") || ($scheme eq "http") || ($scheme eq "ftp")) {
|
---|
| 766 | if (! -f "$dest/ChangeLog") {
|
---|
| 767 | pb_system("echo ChangeLog for $pkgdir > $dest/ChangeLog","Empty ChangeLog file created");
|
---|
| 768 | }
|
---|
| 769 | } elsif ($scheme =~ /^cvs/) {
|
---|
| 770 | my $tmp=basename($pkgdir);
|
---|
| 771 | # CVS needs a relative path !
|
---|
| 772 | if (! -f "$dest/ChangeLog") {
|
---|
[448] | 773 | # In case we have no network, just create an empty one before to allow correct build
|
---|
| 774 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 775 | close(CL);
|
---|
[405] | 776 | if (-x "/usr/bin/cvs2cl") {
|
---|
| 777 | pb_system("/usr/bin/cvs2cl --group-by-day -U $authors -f $dest/ChangeLog $pkgdir","Generating ChangeLog from CVS with cvs2cl");
|
---|
[395] | 778 | } else {
|
---|
[405] | 779 | # To be written from pbcl
|
---|
[661] | 780 | pb_system("$vcscmd log $tmp > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from CVS");
|
---|
[395] | 781 | }
|
---|
| 782 | }
|
---|
[405] | 783 | } else {
|
---|
| 784 | die "cms $scheme unknown";
|
---|
[395] | 785 | }
|
---|
| 786 | }
|
---|
[405] | 787 |
|
---|
[661] | 788 | sub pb_cms_mod_http {
|
---|
[600] | 789 |
|
---|
| 790 | my $url = shift;
|
---|
[661] | 791 | my $proto = shift;
|
---|
[600] | 792 |
|
---|
[661] | 793 | $url =~ s/^$proto\+(http[s]*):/$1:/;
|
---|
[600] | 794 | return($url);
|
---|
| 795 | }
|
---|
| 796 |
|
---|
[661] | 797 | sub pb_cms_mod_socks {
|
---|
[612] | 798 |
|
---|
| 799 | my $url = shift;
|
---|
| 800 |
|
---|
[661] | 801 | $url =~ s/^([A-z0-9]+)\+(socks):/$1:/;
|
---|
[612] | 802 | return($url);
|
---|
| 803 | }
|
---|
| 804 |
|
---|
[661] | 805 |
|
---|
| 806 | sub pb_cms_cmd {
|
---|
| 807 |
|
---|
| 808 | my $scheme = shift;
|
---|
| 809 | my $cmd = "";
|
---|
| 810 |
|
---|
| 811 | # If there is a socks proxy to use
|
---|
| 812 | if ($scheme =~ /socks/) {
|
---|
| 813 | # Get the socks proxy command from the conf file
|
---|
| 814 | my ($pbsockcmd) = pb_conf_get("pbsockscmd");
|
---|
| 815 | $cmd = "$pbsockcmd->{$ENV{'PBPROJ'}} ";
|
---|
| 816 | }
|
---|
| 817 |
|
---|
| 818 | if ($scheme =~ /hg/) {
|
---|
| 819 | return($cmd."hg")
|
---|
| 820 | } elsif ($scheme =~ /git/) {
|
---|
| 821 | return($cmd."git")
|
---|
| 822 | } elsif ($scheme =~ /svn/) {
|
---|
| 823 | return($cmd."svn")
|
---|
| 824 | } elsif ($scheme =~ /cvs/) {
|
---|
| 825 | return($cmd."cvs")
|
---|
| 826 | } elsif (($scheme =~ /http/) || ($scheme =~ /ftp/)) {
|
---|
| 827 | if (-x "/usr/bin/wget") {
|
---|
| 828 | return($cmd."/usr/bin/wget -nv -O ");
|
---|
| 829 | } elsif (-x "/usr/bin/curl") {
|
---|
| 830 | return($cmd."/usr/bin/curl -o ");
|
---|
| 831 | } else {
|
---|
| 832 | die "Unable to handle $scheme.\nNo wget/curl available, please install one of those";
|
---|
| 833 | }
|
---|
| 834 | } else {
|
---|
| 835 | return($cmd);
|
---|
| 836 | }
|
---|
| 837 | }
|
---|
| 838 |
|
---|
| 839 |
|
---|
| 840 |
|
---|
[409] | 841 | =back
|
---|
| 842 |
|
---|
| 843 | =head1 WEB SITES
|
---|
| 844 |
|
---|
| 845 | The main Web site of the project is available at L<http://www.project-builder.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.project-builder.org/>.
|
---|
| 846 |
|
---|
| 847 | =head1 USER MAILING LIST
|
---|
| 848 |
|
---|
| 849 | None exists for the moment.
|
---|
| 850 |
|
---|
| 851 | =head1 AUTHORS
|
---|
| 852 |
|
---|
| 853 | The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
|
---|
| 854 |
|
---|
| 855 | =head1 COPYRIGHT
|
---|
| 856 |
|
---|
| 857 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
| 858 | described in the file C<COPYING> included with the distribution.
|
---|
| 859 |
|
---|
| 860 | =cut
|
---|
| 861 |
|
---|
[395] | 862 | 1;
|
---|