[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);
|
---|
[1148] | 21 | use ProjectBuilder::Version;
|
---|
[318] | 22 | use ProjectBuilder::Base;
|
---|
[405] | 23 | use ProjectBuilder::Conf;
|
---|
[1469] | 24 | use ProjectBuilder::VCS;
|
---|
[5] | 25 |
|
---|
[405] | 26 | # Inherit from the "Exporter" module which handles exporting functions.
|
---|
| 27 |
|
---|
[1156] | 28 | use vars qw($VERSION $REVISION @ISA @EXPORT);
|
---|
[405] | 29 | use Exporter;
|
---|
| 30 |
|
---|
| 31 | # Export, by default, all the functions into the namespace of
|
---|
| 32 | # any code which uses this module.
|
---|
| 33 |
|
---|
| 34 | our @ISA = qw(Exporter);
|
---|
[1469] | 35 | our @EXPORT = qw(pb_cms_init pb_cms_checkin pb_cms_get_pkg pb_cms_get_real_pkg pb_cms_compliant pb_cms_log);
|
---|
[1156] | 36 | ($VERSION,$REVISION) = pb_version_init();
|
---|
[5] | 37 |
|
---|
[331] | 38 | =pod
|
---|
| 39 |
|
---|
| 40 | =head1 NAME
|
---|
| 41 |
|
---|
[409] | 42 | ProjectBuilder::CMS, part of the project-builder.org
|
---|
[331] | 43 |
|
---|
| 44 | =head1 DESCRIPTION
|
---|
| 45 |
|
---|
[405] | 46 | This modules provides configuration management system functions suitable for pbinit calls.
|
---|
[331] | 47 |
|
---|
[409] | 48 | =head1 USAGE
|
---|
| 49 |
|
---|
| 50 | =over 4
|
---|
| 51 |
|
---|
| 52 | =item B<pb_cms_init>
|
---|
| 53 |
|
---|
| 54 | This function setup the environment for the CMS system related to the URL given by the pburl configuration parameter.
|
---|
| 55 | The potential parameter indicates whether we should inititate the context or not.
|
---|
| 56 | It sets up environement variables (PBPROJDIR, PBDIR, PBREVISION, PBCMSLOGFILE)
|
---|
| 57 |
|
---|
[331] | 58 | =cut
|
---|
| 59 |
|
---|
[395] | 60 | sub pb_cms_init {
|
---|
| 61 |
|
---|
| 62 | my $pbinit = shift || undef;
|
---|
[1097] | 63 | my $param = shift || undef;
|
---|
[395] | 64 |
|
---|
| 65 | my ($pburl) = pb_conf_get("pburl");
|
---|
| 66 | pb_log(2,"DEBUG: Project URL of $ENV{'PBPROJ'}: $pburl->{$ENV{'PBPROJ'}}\n");
|
---|
| 67 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($pburl->{$ENV{'PBPROJ'}});
|
---|
[1469] | 68 | my $vcscmd = pb_vcs_cmd($scheme);
|
---|
[395] | 69 |
|
---|
| 70 | my ($pbprojdir) = pb_conf_get_if("pbprojdir");
|
---|
| 71 |
|
---|
| 72 | if ((defined $pbprojdir) && (defined $pbprojdir->{$ENV{'PBPROJ'}})) {
|
---|
| 73 | $ENV{'PBPROJDIR'} = $pbprojdir->{$ENV{'PBPROJ'}};
|
---|
| 74 | } else {
|
---|
| 75 | $ENV{'PBPROJDIR'} = "$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}";
|
---|
| 76 | }
|
---|
[1097] | 77 | # Expand potential env variable in it to allow string replacement
|
---|
| 78 | eval { $ENV{'PBPROJDIR'} =~ s/(\$ENV.+\})/$1/eeg };
|
---|
[395] | 79 |
|
---|
[1097] | 80 |
|
---|
[395] | 81 | # Computing the default dir for PBDIR.
|
---|
| 82 | # what we have is PBPROJDIR so work from that.
|
---|
| 83 | # Tree identical between PBCONFDIR and PBROOTDIR on one side and
|
---|
| 84 | # PBPROJDIR and PBDIR on the other side.
|
---|
| 85 |
|
---|
| 86 | my $tmp = $ENV{'PBROOTDIR'};
|
---|
[1174] | 87 | $tmp =~ s|^$ENV{'PBCONFDIR'}/||;
|
---|
[395] | 88 |
|
---|
| 89 | #
|
---|
| 90 | # Check project cms compliance
|
---|
| 91 | #
|
---|
[1174] | 92 | my $turl = "$pburl->{$ENV{'PBPROJ'}}/$tmp";
|
---|
| 93 | $turl = $pburl->{$ENV{'PBPROJ'}} if (($scheme =~ /^file/) || ($scheme =~ /^(ht|f)tp/));
|
---|
| 94 | pb_cms_compliant(undef,'PBDIR',"$ENV{'PBPROJDIR'}/$tmp",$turl,$pbinit);
|
---|
[395] | 95 |
|
---|
[661] | 96 |
|
---|
[612] | 97 | if ($scheme =~ /^hg/) {
|
---|
[661] | 98 | $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd identify )`;
|
---|
[395] | 99 | chomp($tmp);
|
---|
[612] | 100 | $tmp =~ s/^.* //;
|
---|
[395] | 101 | $ENV{'PBREVISION'}=$tmp;
|
---|
[612] | 102 | $ENV{'PBCMSLOGFILE'}="hg.log";
|
---|
[661] | 103 | } elsif ($scheme =~ /^git/) {
|
---|
| 104 | $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd log | head -1 | cut -f2)`;
|
---|
| 105 | chomp($tmp);
|
---|
| 106 | $tmp =~ s/^.* //;
|
---|
| 107 | $ENV{'PBREVISION'}=$tmp;
|
---|
| 108 | $ENV{'PBCMSLOGFILE'}="git.log";
|
---|
[1174] | 109 | } elsif (($scheme =~ /^file/) || ($scheme eq "ftp") || ($scheme eq "http")) {
|
---|
[395] | 110 | $ENV{'PBREVISION'}="flat";
|
---|
| 111 | $ENV{'PBCMSLOGFILE'}="flat.log";
|
---|
[612] | 112 | } elsif ($scheme =~ /^svn/) {
|
---|
[1097] | 113 | # svnversion more precise than svn info if sbx
|
---|
[1134] | 114 | if ((defined $param) && ($param eq "CMS")) {
|
---|
[1097] | 115 | $tmp = `(LANGUAGE=C $vcscmd info $pburl->{$ENV{'PBPROJ'}} | grep -E '^Revision:' | cut -d: -f2)`;
|
---|
| 116 | $tmp =~ s/\s+//;
|
---|
| 117 | } else {
|
---|
| 118 | $tmp = `(cd "$ENV{'PBDIR'}" ; $vcscmd"version" .)`;
|
---|
| 119 | }
|
---|
[612] | 120 | chomp($tmp);
|
---|
| 121 | $ENV{'PBREVISION'}=$tmp;
|
---|
| 122 | $ENV{'PBCMSLOGFILE'}="svn.log";
|
---|
[780] | 123 | } elsif ($scheme =~ /^svk/) {
|
---|
[1097] | 124 | $tmp = `(cd "$ENV{'PBDIR'}" ; LANGUAGE=C $vcscmd info . | grep -E '^Revision:' | cut -d: -f2)`;
|
---|
[780] | 125 | $tmp =~ s/\s+//;
|
---|
| 126 | chomp($tmp);
|
---|
| 127 | $ENV{'PBREVISION'}=$tmp;
|
---|
| 128 | $ENV{'PBCMSLOGFILE'}="svk.log";
|
---|
[395] | 129 | } elsif ($scheme =~ /^cvs/) {
|
---|
| 130 | # Way too slow
|
---|
| 131 | #$ENV{'PBREVISION'}=`(cd "$ENV{'PBROOTDIR'}" ; cvs rannotate -f . 2>&1 | awk '{print \$1}' | grep -E '^[0-9]' | cut -d. -f2 |sort -nu | tail -1)`;
|
---|
| 132 | #chomp($ENV{'PBREVISION'});
|
---|
| 133 | $ENV{'PBREVISION'}="cvs";
|
---|
| 134 | $ENV{'PBCMSLOGFILE'}="cvs.log";
|
---|
| 135 | $ENV{'CVS_RSH'} = "ssh" if ($scheme =~ /ssh/);
|
---|
| 136 | } else {
|
---|
| 137 | die "cms $scheme unknown";
|
---|
| 138 | }
|
---|
| 139 |
|
---|
[1114] | 140 | pb_log(1,"pb_cms_init returns $scheme,$pburl->{$ENV{'PBPROJ'}}\n");
|
---|
[395] | 141 | return($scheme,$pburl->{$ENV{'PBPROJ'}});
|
---|
| 142 | }
|
---|
| 143 |
|
---|
[409] | 144 | =item B<pb_cms_checkin>
|
---|
| 145 |
|
---|
| 146 | This function updates a CMS content from a local directory.
|
---|
| 147 | The first parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)
|
---|
| 148 | The second parameter is the directory to update from.
|
---|
[452] | 149 | The third parameter indicates if we are in a new version creation (undef) or in a new project creation (1)
|
---|
[409] | 150 |
|
---|
| 151 | =cut
|
---|
| 152 |
|
---|
[395] | 153 | sub pb_cms_checkin {
|
---|
| 154 | my $scheme = shift;
|
---|
| 155 | my $dir = shift;
|
---|
[452] | 156 | my $pbinit = shift || undef;
|
---|
[395] | 157 |
|
---|
| 158 | my $ver = basename($dir);
|
---|
[452] | 159 | my $msg = "updated to $ver";
|
---|
| 160 | $msg = "Project $ENV{PBPROJ} creation" if (defined $pbinit);
|
---|
| 161 |
|
---|
[1469] | 162 | pb_vcs_checkin($scheme,$dir,$msg);
|
---|
[395] | 163 | }
|
---|
| 164 |
|
---|
[539] | 165 | =item B<pb_cms_get_pkg>
|
---|
[409] | 166 |
|
---|
| 167 | This function returns the list of packages we are working on in a CMS action.
|
---|
| 168 | The first parameter is the default list of packages from the configuration file.
|
---|
| 169 | The second parameter is the optional list of packages from the configuration file.
|
---|
| 170 |
|
---|
| 171 | =cut
|
---|
| 172 |
|
---|
[395] | 173 | sub pb_cms_get_pkg {
|
---|
| 174 |
|
---|
| 175 | my @pkgs = ();
|
---|
| 176 | my $defpkgdir = shift || undef;
|
---|
| 177 | my $extpkgdir = shift || undef;
|
---|
| 178 |
|
---|
| 179 | # Get packages list
|
---|
| 180 | if (not defined $ARGV[0]) {
|
---|
| 181 | @pkgs = keys %$defpkgdir if (defined $defpkgdir);
|
---|
| 182 | } elsif ($ARGV[0] =~ /^all$/) {
|
---|
| 183 | @pkgs = keys %$defpkgdir if (defined $defpkgdir);
|
---|
| 184 | push(@pkgs, keys %$extpkgdir) if (defined $extpkgdir);
|
---|
| 185 | } else {
|
---|
| 186 | @pkgs = @ARGV;
|
---|
| 187 | }
|
---|
| 188 | pb_log(0,"Packages: ".join(',',@pkgs)."\n");
|
---|
| 189 | return(\@pkgs);
|
---|
| 190 | }
|
---|
| 191 |
|
---|
[539] | 192 | =item B<pb_cms_get_real_pkg>
|
---|
| 193 |
|
---|
| 194 | This function returns the real name of a virtual package we are working on in a CMS action.
|
---|
| 195 | It supports the following types: perl.
|
---|
| 196 | The first parameter is the virtual package name
|
---|
| 197 |
|
---|
| 198 | =cut
|
---|
| 199 |
|
---|
| 200 | sub pb_cms_get_real_pkg {
|
---|
| 201 |
|
---|
| 202 | my $pbpkg = shift || undef;
|
---|
| 203 | my $dtype = shift;
|
---|
| 204 | my $pbpkgreal = $pbpkg;
|
---|
| 205 |
|
---|
| 206 | my @nametype = pb_conf_get_if("namingtype");
|
---|
| 207 | my $type = $nametype[0]->{$pbpkg};
|
---|
| 208 | if (defined $type) {
|
---|
| 209 | if ($type eq "perl") {
|
---|
| 210 | if ($dtype eq "rpm") {
|
---|
| 211 | $pbpkgreal = "perl-".$pbpkg;
|
---|
| 212 | } elsif ($dtype eq "deb") {
|
---|
[544] | 213 | # Only lower case allowed in Debian
|
---|
| 214 | # Cf: http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Package
|
---|
[539] | 215 | $pbpkgreal = "lib".lc($pbpkg)."-perl";
|
---|
| 216 | } elsif ($dtype eq "ebuild") {
|
---|
| 217 | $pbpkgreal = $pbpkg;
|
---|
[1174] | 218 | } elsif ($dtype eq "hpux") {
|
---|
| 219 | $pbpkgreal = $pbpkg;
|
---|
[873] | 220 | } elsif ($dtype eq "pkg") {
|
---|
| 221 | $pbpkgreal = "PB$pbpkg";
|
---|
[539] | 222 | } else {
|
---|
| 223 | die "pb_cms_get_real_pkg not implemented for $dtype yet";
|
---|
| 224 | }
|
---|
| 225 | } else {
|
---|
| 226 | die "nametype $type not implemented yet";
|
---|
| 227 | }
|
---|
| 228 | }
|
---|
| 229 |
|
---|
[1114] | 230 | pb_log(1,"pb_cms_get_real_pkg returns $pbpkgreal\n");
|
---|
[539] | 231 | return($pbpkgreal);
|
---|
| 232 | }
|
---|
| 233 |
|
---|
[409] | 234 | =item B<pb_cms_compliant>
|
---|
| 235 |
|
---|
| 236 | This function checks the compliance of the project and the pbconf directory.
|
---|
| 237 | The first parameter is the key name of the value that needs to be read in the configuration file.
|
---|
| 238 | The second parameter is the environment variable this key will populate.
|
---|
| 239 | The third parameter is the location of the pbconf dir.
|
---|
| 240 | The fourth parameter is the URI of the CMS content related to the pbconf dir.
|
---|
| 241 | The fifth parameter indicates whether we should inititate the context or not.
|
---|
| 242 |
|
---|
| 243 | =cut
|
---|
| 244 |
|
---|
[395] | 245 | sub pb_cms_compliant {
|
---|
| 246 |
|
---|
| 247 | my $param = shift;
|
---|
| 248 | my $envar = shift;
|
---|
| 249 | my $defdir = shift;
|
---|
| 250 | my $uri = shift;
|
---|
| 251 | my $pbinit = shift;
|
---|
| 252 | my %pdir;
|
---|
| 253 |
|
---|
[1174] | 254 | pb_log(1,"pb_cms_compliant: envar: $envar - defdir: $defdir - uri: $uri\n");
|
---|
[395] | 255 | my ($pdir) = pb_conf_get_if($param) if (defined $param);
|
---|
| 256 | if (defined $pdir) {
|
---|
| 257 | %pdir = %$pdir;
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 |
|
---|
| 261 | if ((defined $pdir) && (%pdir) && (defined $pdir{$ENV{'PBPROJ'}})) {
|
---|
| 262 | # That's always the environment variable that will be used
|
---|
| 263 | $ENV{$envar} = $pdir{$ENV{'PBPROJ'}};
|
---|
| 264 | } else {
|
---|
| 265 | if (defined $param) {
|
---|
| 266 | pb_log(1,"WARNING: no $param defined, using $defdir\n");
|
---|
| 267 | pb_log(1," Please create a $param reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
|
---|
| 268 | pb_log(1," if you want to use another directory\n");
|
---|
| 269 | }
|
---|
| 270 | $ENV{$envar} = "$defdir";
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | # Expand potential env variable in it
|
---|
| 274 | eval { $ENV{$envar} =~ s/(\$ENV.+\})/$1/eeg };
|
---|
| 275 | pb_log(2,"$envar: $ENV{$envar}\n");
|
---|
| 276 |
|
---|
| 277 | my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri);
|
---|
| 278 |
|
---|
[1174] | 279 | if (($scheme !~ /^cvs/) && ($scheme !~ /^svn/) && ($scheme !~ /^svk/) && ($scheme !~ /^hg/) && ($scheme !~ /^git/)) {
|
---|
[1113] | 280 | # Do not compare if it's not a real cms
|
---|
[1174] | 281 | pb_log(1,"pb_cms_compliant useless\n");
|
---|
[1113] | 282 | return;
|
---|
[1172] | 283 | } elsif (defined $pbinit) {
|
---|
| 284 | pb_mkdir_p("$ENV{$envar}");
|
---|
| 285 | } elsif (! -d "$ENV{$envar}") {
|
---|
| 286 | # Either we have a version in the uri, and it should be the same
|
---|
| 287 | # as the one in the envar. Or we should add the version to the uri
|
---|
| 288 | if (basename($uri) ne basename($ENV{$envar})) {
|
---|
| 289 | $uri .= "/".basename($ENV{$envar})
|
---|
[395] | 290 | }
|
---|
[1172] | 291 | pb_log(1,"Checking out $uri\n");
|
---|
[1173] | 292 | # Create structure and remove end dir before exporting
|
---|
| 293 | pb_mkdir_p("$ENV{$envar}");
|
---|
[1208] | 294 | pb_rm_rf($ENV{$envar});
|
---|
[1469] | 295 | pb_vcs_checkout($scheme,$uri,$ENV{$envar});
|
---|
[395] | 296 | } else {
|
---|
| 297 | pb_log(1,"$uri found locally, checking content\n");
|
---|
[1469] | 298 | my $cmsurl = pb_vcs_get_uri($scheme,$ENV{$envar});
|
---|
[395] | 299 | my ($scheme2, $account2, $host2, $port2, $path2) = pb_get_uri($cmsurl);
|
---|
[1176] | 300 | # For svk, scheme doesn't appear in svk info so remove it here in uri coming from conf file
|
---|
| 301 | # which needs it to trigger correct behaviour
|
---|
| 302 | $uri =~ s/^svk://;
|
---|
[1302] | 303 | if (($scheme2 =~ /^git/) || ($scheme2 =~ /^hg/)) {
|
---|
[1487] | 304 | # These VCS manage branches internally not with different tree structures
|
---|
[1302] | 305 | # Assuming it's correct for now.
|
---|
| 306 | } elsif ($cmsurl ne $uri) {
|
---|
[395] | 307 | # The local content doesn't correpond to the repository
|
---|
| 308 | pb_log(0,"ERROR: Inconsistency detected:\n");
|
---|
[1174] | 309 | pb_log(0," * $ENV{$envar} ($envar) refers to $cmsurl but\n");
|
---|
[395] | 310 | pb_log(0," * $ENV{'PBETC'} refers to $uri\n");
|
---|
| 311 | die "Project $ENV{'PBPROJ'} is not Project-Builder compliant.";
|
---|
| 312 | } else {
|
---|
| 313 | pb_log(1,"Content correct - doing nothing - you may want to update your repository however\n");
|
---|
| 314 | # they match - do nothing - there may be local changes
|
---|
| 315 | }
|
---|
| 316 | }
|
---|
[1174] | 317 | pb_log(1,"pb_cms_compliant end\n");
|
---|
[395] | 318 | }
|
---|
| 319 |
|
---|
[409] | 320 | =item B<pb_cms_create_authors>
|
---|
| 321 |
|
---|
| 322 | This function creates a AUTHORS files for the project. It call it AUTHORS.pb if an AUTHORS file already exists.
|
---|
| 323 | The first parameter is the source file for authors information.
|
---|
| 324 | The second parameter is the directory where to create the final AUTHORS file.
|
---|
| 325 | The third parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)
|
---|
| 326 |
|
---|
| 327 | =cut
|
---|
| 328 |
|
---|
[405] | 329 | sub pb_cms_create_authors {
|
---|
[395] | 330 |
|
---|
[405] | 331 | my $authors=shift;
|
---|
| 332 | my $dest=shift;
|
---|
| 333 | my $scheme=shift;
|
---|
[395] | 334 |
|
---|
[405] | 335 | return if ($authors eq "/dev/null");
|
---|
| 336 | open(SAUTH,$authors) || die "Unable to open $authors";
|
---|
[409] | 337 | # Save a potentially existing AUTHORS file and write instead to AUTHORS.pb
|
---|
[405] | 338 | my $ext = "";
|
---|
| 339 | if (-f "$dest/AUTHORS") {
|
---|
| 340 | $ext = ".pb";
|
---|
[395] | 341 | }
|
---|
[405] | 342 | open(DAUTH,"> $dest/AUTHORS$ext") || die "Unable to create $dest/AUTHORS$ext";
|
---|
| 343 | print DAUTH "Authors of the project are:\n";
|
---|
| 344 | print DAUTH "===========================\n";
|
---|
| 345 | while (<SAUTH>) {
|
---|
| 346 | my ($nick,$gcos) = split(/:/);
|
---|
| 347 | chomp($gcos);
|
---|
| 348 | print DAUTH "$gcos";
|
---|
| 349 | if (defined $scheme) {
|
---|
| 350 | # Do not give a scheme for flat types
|
---|
| 351 | my $endstr="";
|
---|
| 352 | if ("$ENV{'PBREVISION'}" ne "flat") {
|
---|
| 353 | $endstr = " under $scheme";
|
---|
| 354 | }
|
---|
| 355 | print DAUTH " ($nick$endstr)\n";
|
---|
| 356 | } else {
|
---|
| 357 | print DAUTH "\n";
|
---|
| 358 | }
|
---|
[395] | 359 | }
|
---|
[405] | 360 | close(DAUTH);
|
---|
| 361 | close(SAUTH);
|
---|
[395] | 362 | }
|
---|
| 363 |
|
---|
[409] | 364 | =item B<pb_cms_log>
|
---|
| 365 |
|
---|
| 366 | This function creates a ChangeLog file for the project.
|
---|
| 367 | The first parameter is the schema of the CMS systems (svn, cvs, svn+ssh, ...)
|
---|
| 368 | The second parameter is the directory where the CMS content was checked out.
|
---|
| 369 | The third parameter is the directory where to create the final ChangeLog file.
|
---|
| 370 | The fourth parameter is unused.
|
---|
| 371 | The fifth parameter is the source file for authors information.
|
---|
| 372 |
|
---|
| 373 | It may use a tool like svn2cl or cvs2cl to generate it if present, or the log file from the CMS if not.
|
---|
| 374 |
|
---|
| 375 | =cut
|
---|
| 376 |
|
---|
| 377 |
|
---|
[405] | 378 | sub pb_cms_log {
|
---|
[395] | 379 |
|
---|
[405] | 380 | my $scheme = shift;
|
---|
| 381 | my $pkgdir = shift;
|
---|
| 382 | my $dest = shift;
|
---|
| 383 | my $chglog = shift;
|
---|
| 384 | my $authors = shift;
|
---|
[448] | 385 | my $testver = shift || undef;
|
---|
[395] | 386 |
|
---|
[405] | 387 | pb_cms_create_authors($authors,$dest,$scheme);
|
---|
[1469] | 388 | my $vcscmd = pb_vcs_cmd($scheme);
|
---|
[395] | 389 |
|
---|
[448] | 390 | if ((defined $testver) && (defined $testver->{$ENV{'PBPROJ'}}) && ($testver->{$ENV{'PBPROJ'}} =~ /true/i)) {
|
---|
| 391 | if (! -f "$dest/ChangeLog") {
|
---|
| 392 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 393 | # We need a minimal version for debian type of build
|
---|
| 394 | print CL "\n";
|
---|
| 395 | print CL "\n";
|
---|
| 396 | print CL "\n";
|
---|
| 397 | print CL "\n";
|
---|
| 398 | print CL "1990-01-01 none\n";
|
---|
| 399 | print CL "\n";
|
---|
| 400 | print CL " * test version\n";
|
---|
| 401 | print CL "\n";
|
---|
| 402 | close(CL);
|
---|
| 403 | pb_log(0,"Generating fake ChangeLog for test version\n");
|
---|
| 404 | open(CL,"> $dest/$ENV{'PBCMSLOGFILE'}") || die "Unable to create $dest/$ENV{'PBCMSLOGFILE'}";
|
---|
| 405 | close(CL);
|
---|
| 406 | }
|
---|
| 407 | }
|
---|
| 408 |
|
---|
[890] | 409 | if (! -f "$dest/ChangeLog") {
|
---|
| 410 | if ($scheme =~ /^svn/) {
|
---|
[448] | 411 | # In case we have no network, just create an empty one before to allow correct build
|
---|
| 412 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 413 | close(CL);
|
---|
[1127] | 414 | my $command = pb_check_req("svn2cl",1);
|
---|
[1421] | 415 | if ((defined $command) && (-x $command)) {
|
---|
[1127] | 416 | pb_system("$command --group-by-day --authors=$authors -i -o $dest/ChangeLog $pkgdir","Generating ChangeLog from SVN with svn2cl");
|
---|
[395] | 417 | } else {
|
---|
[405] | 418 | # To be written from pbcl
|
---|
[661] | 419 | pb_system("$vcscmd log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVN");
|
---|
[395] | 420 | }
|
---|
[890] | 421 | } elsif ($scheme =~ /^svk/) {
|
---|
[780] | 422 | pb_system("$vcscmd log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVK");
|
---|
[890] | 423 | } elsif ($scheme =~ /^hg/) {
|
---|
[612] | 424 | # In case we have no network, just create an empty one before to allow correct build
|
---|
| 425 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 426 | close(CL);
|
---|
[896] | 427 | pb_system("$vcscmd log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from Mercurial");
|
---|
[890] | 428 | } elsif ($scheme =~ /^git/) {
|
---|
[661] | 429 | # In case we have no network, just create an empty one before to allow correct build
|
---|
| 430 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 431 | close(CL);
|
---|
| 432 | pb_system("$vcscmd log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from GIT");
|
---|
[1174] | 433 | } elsif (($scheme =~ /^file/) || ($scheme eq "dir") || ($scheme eq "http") || ($scheme eq "ftp")) {
|
---|
[405] | 434 | pb_system("echo ChangeLog for $pkgdir > $dest/ChangeLog","Empty ChangeLog file created");
|
---|
[890] | 435 | } elsif ($scheme =~ /^cvs/) {
|
---|
| 436 | my $tmp=basename($pkgdir);
|
---|
| 437 | # CVS needs a relative path !
|
---|
[448] | 438 | # In case we have no network, just create an empty one before to allow correct build
|
---|
| 439 | open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
|
---|
| 440 | close(CL);
|
---|
[1127] | 441 | my $command = pb_check_req("cvs2cl",1);
|
---|
| 442 | if (-x $command) {
|
---|
| 443 | pb_system("$command --group-by-day -U $authors -f $dest/ChangeLog $pkgdir","Generating ChangeLog from CVS with cvs2cl");
|
---|
[395] | 444 | } else {
|
---|
[405] | 445 | # To be written from pbcl
|
---|
[661] | 446 | pb_system("$vcscmd log $tmp > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from CVS");
|
---|
[395] | 447 | }
|
---|
[890] | 448 | } else {
|
---|
| 449 | die "cms $scheme unknown";
|
---|
[395] | 450 | }
|
---|
| 451 | }
|
---|
[896] | 452 | if (! -f "$dest/ChangeLog") {
|
---|
| 453 | copy("$dest/$ENV{'PBCMSLOGFILE'}","$dest/ChangeLog");
|
---|
[395] | 454 | }
|
---|
[896] | 455 | }
|
---|
[405] | 456 |
|
---|
[409] | 457 | =back
|
---|
| 458 |
|
---|
| 459 | =head1 WEB SITES
|
---|
| 460 |
|
---|
| 461 | 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/>.
|
---|
| 462 |
|
---|
| 463 | =head1 USER MAILING LIST
|
---|
| 464 |
|
---|
| 465 | None exists for the moment.
|
---|
| 466 |
|
---|
| 467 | =head1 AUTHORS
|
---|
| 468 |
|
---|
| 469 | The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
|
---|
| 470 |
|
---|
| 471 | =head1 COPYRIGHT
|
---|
| 472 |
|
---|
| 473 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
| 474 | described in the file C<COPYING> included with the distribution.
|
---|
| 475 |
|
---|
| 476 | =cut
|
---|
| 477 |
|
---|
[395] | 478 | 1;
|
---|