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