[405] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
| 3 | # ProjectBuilder Changelog module
|
---|
| 4 | # Changelog management subroutines brought by the the Project-Builder project
|
---|
| 5 | #
|
---|
| 6 | # $Id$
|
---|
| 7 | #
|
---|
| 8 | # Copyright B. Cornec 2007
|
---|
| 9 | # Provided under the GPL v2
|
---|
| 10 |
|
---|
| 11 | package ProjectBuilder::Changelog;
|
---|
| 12 |
|
---|
| 13 | use strict 'vars';
|
---|
| 14 | use Data::Dumper;
|
---|
| 15 | use English;
|
---|
| 16 | use Date::Manip;
|
---|
| 17 | use POSIX qw(strftime);
|
---|
| 18 | use lib qw (lib);
|
---|
| 19 | use ProjectBuilder::Base;
|
---|
| 20 | use ProjectBuilder::Conf;
|
---|
| 21 |
|
---|
| 22 | # Inherit from the "Exporter" module which handles exporting functions.
|
---|
| 23 |
|
---|
| 24 | use Exporter;
|
---|
| 25 |
|
---|
| 26 | # Export, by default, all the functions into the namespace of
|
---|
| 27 | # any code which uses this module.
|
---|
| 28 |
|
---|
| 29 | our @ISA = qw(Exporter);
|
---|
| 30 | our @EXPORT = qw(pb_changelog);
|
---|
| 31 |
|
---|
| 32 | =pod
|
---|
| 33 |
|
---|
| 34 | =head1 NAME
|
---|
| 35 |
|
---|
| 36 | ProjectBuilder::Changelog, part of the project-builder.org - module dealing with changelog management
|
---|
| 37 |
|
---|
| 38 | =head1 DESCRIPTION
|
---|
| 39 |
|
---|
[409] | 40 | This modules provides generic functions suitable for changelog management for project-builder.org
|
---|
[405] | 41 |
|
---|
[409] | 42 | =head1 USAGE
|
---|
| 43 |
|
---|
| 44 | =over 4
|
---|
| 45 |
|
---|
| 46 | =item B<pb_changelog>
|
---|
| 47 |
|
---|
| 48 | Function that generates the changelog used in build files, or for announcements (web, mailing-list, ...)
|
---|
| 49 |
|
---|
| 50 | It takes up to 9 parameters:
|
---|
| 51 | The first parameter is the type of the distribution.
|
---|
| 52 | The second parameter is the package name generated.
|
---|
| 53 | The third parameter is the version of the package.
|
---|
| 54 | The fourth parameter is the tag of the package.
|
---|
| 55 | The fifth parameter is the suffix of the package.
|
---|
| 56 | The sixth parameter is now unused.
|
---|
| 57 | The seventh parameter is the file descriptor on which to write the changelog content.
|
---|
| 58 | The eighth parameter is a flag in the configuration file indicating whether we want changelog expansion or not.
|
---|
| 59 | The nineth parameter is the potential changelog file pbcl.
|
---|
| 60 |
|
---|
[405] | 61 | =cut
|
---|
| 62 |
|
---|
| 63 | sub pb_changelog {
|
---|
| 64 |
|
---|
[543] | 65 | my $pb = shift;
|
---|
| 66 | my $dtype = $pb->{'dtype'};
|
---|
| 67 | my $pbrealpkg = $pb->{'realpkg'};
|
---|
| 68 | my $pbver = $pb->{'ver'};
|
---|
| 69 | my $pbtag = $pb->{'tag'};
|
---|
| 70 | my $dsuf = $pb->{'suf'};
|
---|
[405] | 71 | my $path = shift;
|
---|
| 72 | my $OUTPUT = shift;
|
---|
| 73 | my $doit = shift;
|
---|
[543] | 74 | my $chglog = $pb->{'chglog'} || undef;
|
---|
[405] | 75 |
|
---|
| 76 | my $log = "";
|
---|
| 77 |
|
---|
| 78 | # For date handling
|
---|
| 79 | $ENV{LANG}="C";
|
---|
| 80 |
|
---|
| 81 | if ((not (defined $dtype)) || ($dtype eq "") ||
|
---|
[543] | 82 | (not (defined $pbrealpkg)) || ($pbrealpkg eq "") ||
|
---|
[405] | 83 | (not (defined $pbver)) || ($pbver eq "") ||
|
---|
| 84 | (not (defined $pbtag)) || ($pbtag eq "") ||
|
---|
| 85 | (not (defined $dsuf)) || ($dsuf eq "") ||
|
---|
| 86 | (not (defined $path)) || ($path eq "") ||
|
---|
| 87 | (not (defined $OUTPUT)) || ($OUTPUT eq "") ||
|
---|
| 88 | (not (defined $doit)) || ($doit eq "")) {
|
---|
| 89 | print $OUTPUT "\n";
|
---|
| 90 | return;
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | if (((not defined $chglog) || (! -f $chglog)) && ($doit eq "yes")) {
|
---|
[543] | 94 | #pb_log(2,"No ChangeLog file ($chglog) for $pbrealpkg\n";
|
---|
[405] | 95 | print $OUTPUT "\n";
|
---|
| 96 | return;
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | my $date;
|
---|
| 100 | my $ndate;
|
---|
| 101 | my $n2date;
|
---|
| 102 | my $ver;
|
---|
| 103 | my $ver2;
|
---|
| 104 | my ($pbpackager) = pb_conf_get("pbpackager");
|
---|
| 105 |
|
---|
| 106 | if (not defined $pbpackager->{$ENV{'PBPROJ'}}) {
|
---|
| 107 | $pbpackager->{$ENV{'PBPROJ'}} = "undefined\@noproject.noorg";
|
---|
| 108 | }
|
---|
| 109 |
|
---|
[544] | 110 | my @date = pb_get_date();
|
---|
[405] | 111 | # If we don't need to do it, or don't have it fake something
|
---|
| 112 | if (((not defined $chglog) || (! -f $chglog)) && ($doit ne "yes")) {
|
---|
| 113 | $date = strftime("%Y-%m-%d", @date);
|
---|
| 114 | $ndate = &UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
| 115 | $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
| 116 | if (($dtype eq "rpm") || ($dtype eq "fc")) {
|
---|
| 117 | $ver2 = "$pbver-$pbtag$dsuf";
|
---|
| 118 | print $OUTPUT "* $ndate $pbpackager->{$ENV{'PBPROJ'}} $ver2\n";
|
---|
| 119 | print $OUTPUT "- Updated to $pbver\n";
|
---|
| 120 | }
|
---|
| 121 | if ($dtype eq "deb") {
|
---|
[544] | 122 | if ($pbver !~ /^[0-9]/) {
|
---|
| 123 | # dpkg-deb doesn't accept non digit versions. Prepending date
|
---|
| 124 | my $ldate = strftime("%Y%m%d", @date);
|
---|
| 125 | $pbver =~ s/^/$ldate/;
|
---|
| 126 | }
|
---|
[543] | 127 | print $OUTPUT "$pbrealpkg ($pbver) unstable; urgency=low\n";
|
---|
[405] | 128 | print $OUTPUT "\n";
|
---|
| 129 | print $OUTPUT " -- $pbpackager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
|
---|
| 130 | }
|
---|
| 131 | return;
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
|
---|
| 135 |
|
---|
| 136 | # Skip first 4 lines
|
---|
| 137 | my $tmp = <INPUT>;
|
---|
| 138 | $tmp = <INPUT>;
|
---|
| 139 | $tmp = <INPUT>;
|
---|
| 140 | if ($dtype eq "announce") {
|
---|
[473] | 141 | chomp($tmp);
|
---|
| 142 | print $OUTPUT "$tmp<br>\n";
|
---|
[405] | 143 | }
|
---|
| 144 | $tmp = <INPUT>;
|
---|
| 145 | if ($dtype eq "announce") {
|
---|
[473] | 146 | chomp($tmp);
|
---|
| 147 | print $OUTPUT "$tmp<br>\n";
|
---|
[405] | 148 | }
|
---|
| 149 |
|
---|
| 150 | my $first=1;
|
---|
| 151 |
|
---|
| 152 | # Handle each block separated by newline
|
---|
| 153 | while (<INPUT>) {
|
---|
| 154 | ($ver, $date) = split(/ /);
|
---|
| 155 | $ver =~ s/^v//;
|
---|
| 156 | chomp($date);
|
---|
| 157 | $date =~ s/\(([0-9-]+)\)/$1/;
|
---|
| 158 | #pb_log(2,"**$date**\n";
|
---|
| 159 | $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
| 160 | $n2date = UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
| 161 | #pb_log(2,"**$ndate**\n";
|
---|
| 162 |
|
---|
| 163 | if (($dtype eq "rpm") || ($dtype eq "fc")) {
|
---|
| 164 | if ($ver !~ /-/) {
|
---|
| 165 | if ($first eq 1) {
|
---|
| 166 | $ver2 = "$ver-$pbtag$dsuf";
|
---|
| 167 | $first=0;
|
---|
| 168 | } else {
|
---|
| 169 | $ver2 = "$ver-1$dsuf";
|
---|
| 170 | }
|
---|
| 171 | } else {
|
---|
| 172 | $ver2 = "$ver$dsuf";
|
---|
| 173 | }
|
---|
| 174 | print $OUTPUT "* $ndate $pbpackager->{$ENV{'PBPROJ'}} $ver2\n";
|
---|
| 175 | print $OUTPUT "- Updated to $ver\n";
|
---|
| 176 | }
|
---|
| 177 | if ($dtype eq "deb") {
|
---|
[544] | 178 | if ($ver !~ /^[0-9]/) {
|
---|
| 179 | # dpkg-deb doesn't accept non digit versions. Prepending date
|
---|
| 180 | my $ldate = strftime("%Y%m%d", @date);
|
---|
| 181 | $ver =~ s/^/$ldate/;
|
---|
| 182 | }
|
---|
[543] | 183 | print $OUTPUT "$pbrealpkg ($ver) unstable; urgency=low\n";
|
---|
[405] | 184 | print $OUTPUT "\n";
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | $tmp = <INPUT>;
|
---|
| 188 | while ($tmp !~ /^$/) {
|
---|
| 189 | if ($dtype eq "deb") {
|
---|
| 190 | $tmp =~ s/^- //;
|
---|
| 191 | print $OUTPUT " * $tmp";
|
---|
| 192 | } elsif ($dtype eq "rpm") {
|
---|
| 193 | print $OUTPUT "$tmp";
|
---|
| 194 | } else {
|
---|
[473] | 195 | chomp($tmp);
|
---|
| 196 | print $OUTPUT "$tmp<br>\n";
|
---|
[405] | 197 | }
|
---|
| 198 | last if (eof(INPUT));
|
---|
| 199 | $tmp = <INPUT>;
|
---|
| 200 | }
|
---|
| 201 | print $OUTPUT "\n";
|
---|
| 202 |
|
---|
| 203 | if ($dtype eq "deb") {
|
---|
| 204 | # Cf: http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog
|
---|
| 205 | print $OUTPUT " -- $pbpackager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | last if (eof(INPUT));
|
---|
| 209 | last if ($dtype eq "announce");
|
---|
| 210 | }
|
---|
| 211 | close(INPUT);
|
---|
| 212 | }
|
---|
| 213 |
|
---|
[409] | 214 |
|
---|
| 215 | =back
|
---|
| 216 |
|
---|
| 217 | =head1 WEB SITES
|
---|
| 218 |
|
---|
| 219 | 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/>.
|
---|
| 220 |
|
---|
| 221 | =head1 USER MAILING LIST
|
---|
| 222 |
|
---|
| 223 | None exists for the moment.
|
---|
| 224 |
|
---|
| 225 | =head1 AUTHORS
|
---|
| 226 |
|
---|
| 227 | The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
|
---|
| 228 |
|
---|
| 229 | =head1 COPYRIGHT
|
---|
| 230 |
|
---|
| 231 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
| 232 | described in the file C<COPYING> included with the distribution.
|
---|
| 233 |
|
---|
| 234 | =cut
|
---|
| 235 |
|
---|
[405] | 236 | 1;
|
---|