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