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