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 |
|
---|
40 | This modules provides generic functions suitable for changelog management for project-builder.org
|
---|
41 |
|
---|
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 |
|
---|
61 | =cut
|
---|
62 |
|
---|
63 | sub pb_changelog {
|
---|
64 |
|
---|
65 | my $dtype = shift;
|
---|
66 | my $pkg = shift;
|
---|
67 | my $pbver = shift;
|
---|
68 | my $pbtag = shift;
|
---|
69 | my $dsuf = shift;
|
---|
70 | my $path = shift;
|
---|
71 | my $OUTPUT = shift;
|
---|
72 | my $doit = shift;
|
---|
73 | my $chglog = shift || undef;
|
---|
74 |
|
---|
75 | my $log = "";
|
---|
76 |
|
---|
77 | # For date handling
|
---|
78 | $ENV{LANG}="C";
|
---|
79 |
|
---|
80 | if ((not (defined $dtype)) || ($dtype eq "") ||
|
---|
81 | (not (defined $pkg)) || ($pkg eq "") ||
|
---|
82 | (not (defined $pbver)) || ($pbver eq "") ||
|
---|
83 | (not (defined $pbtag)) || ($pbtag eq "") ||
|
---|
84 | (not (defined $dsuf)) || ($dsuf eq "") ||
|
---|
85 | (not (defined $path)) || ($path eq "") ||
|
---|
86 | (not (defined $OUTPUT)) || ($OUTPUT eq "") ||
|
---|
87 | (not (defined $doit)) || ($doit eq "")) {
|
---|
88 | print $OUTPUT "\n";
|
---|
89 | return;
|
---|
90 | }
|
---|
91 |
|
---|
92 | if (((not defined $chglog) || (! -f $chglog)) && ($doit eq "yes")) {
|
---|
93 | #pb_log(2,"No ChangeLog file ($chglog) for $pkg\n";
|
---|
94 | print $OUTPUT "\n";
|
---|
95 | return;
|
---|
96 | }
|
---|
97 |
|
---|
98 | my $date;
|
---|
99 | my $ndate;
|
---|
100 | my $n2date;
|
---|
101 | my $ver;
|
---|
102 | my $ver2;
|
---|
103 | my ($pbpackager) = pb_conf_get("pbpackager");
|
---|
104 |
|
---|
105 | if (not defined $pbpackager->{$ENV{'PBPROJ'}}) {
|
---|
106 | $pbpackager->{$ENV{'PBPROJ'}} = "undefined\@noproject.noorg";
|
---|
107 | }
|
---|
108 |
|
---|
109 | # If we don't need to do it, or don't have it fake something
|
---|
110 | if (((not defined $chglog) || (! -f $chglog)) && ($doit ne "yes")) {
|
---|
111 | my @date = pb_get_date();
|
---|
112 | $date = strftime("%Y-%m-%d", @date);
|
---|
113 | $ndate = &UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
114 | $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
115 | if (($dtype eq "rpm") || ($dtype eq "fc")) {
|
---|
116 | $ver2 = "$pbver-$pbtag$dsuf";
|
---|
117 | print $OUTPUT "* $ndate $pbpackager->{$ENV{'PBPROJ'}} $ver2\n";
|
---|
118 | print $OUTPUT "- Updated to $pbver\n";
|
---|
119 | }
|
---|
120 | if ($dtype eq "deb") {
|
---|
121 | print $OUTPUT "$pkg ($pbver) unstable; urgency=low\n";
|
---|
122 | print $OUTPUT "\n";
|
---|
123 | print $OUTPUT " -- $pbpackager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
|
---|
124 | }
|
---|
125 | return;
|
---|
126 | }
|
---|
127 |
|
---|
128 | open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
|
---|
129 |
|
---|
130 | # Skip first 4 lines
|
---|
131 | my $tmp = <INPUT>;
|
---|
132 | $tmp = <INPUT>;
|
---|
133 | $tmp = <INPUT>;
|
---|
134 | if ($dtype eq "announce") {
|
---|
135 | print $OUTPUT $tmp;
|
---|
136 | }
|
---|
137 | $tmp = <INPUT>;
|
---|
138 | if ($dtype eq "announce") {
|
---|
139 | print $OUTPUT $tmp;
|
---|
140 | }
|
---|
141 |
|
---|
142 | my $first=1;
|
---|
143 |
|
---|
144 | # Handle each block separated by newline
|
---|
145 | while (<INPUT>) {
|
---|
146 | ($ver, $date) = split(/ /);
|
---|
147 | $ver =~ s/^v//;
|
---|
148 | chomp($date);
|
---|
149 | $date =~ s/\(([0-9-]+)\)/$1/;
|
---|
150 | #pb_log(2,"**$date**\n";
|
---|
151 | $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
152 | $n2date = UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
153 | #pb_log(2,"**$ndate**\n";
|
---|
154 |
|
---|
155 | if (($dtype eq "rpm") || ($dtype eq "fc")) {
|
---|
156 | if ($ver !~ /-/) {
|
---|
157 | if ($first eq 1) {
|
---|
158 | $ver2 = "$ver-$pbtag$dsuf";
|
---|
159 | $first=0;
|
---|
160 | } else {
|
---|
161 | $ver2 = "$ver-1$dsuf";
|
---|
162 | }
|
---|
163 | } else {
|
---|
164 | $ver2 = "$ver$dsuf";
|
---|
165 | }
|
---|
166 | print $OUTPUT "* $ndate $pbpackager->{$ENV{'PBPROJ'}} $ver2\n";
|
---|
167 | print $OUTPUT "- Updated to $ver\n";
|
---|
168 | }
|
---|
169 | if ($dtype eq "deb") {
|
---|
170 | print $OUTPUT "$pkg ($ver) unstable; urgency=low\n";
|
---|
171 | print $OUTPUT "\n";
|
---|
172 | }
|
---|
173 |
|
---|
174 | $tmp = <INPUT>;
|
---|
175 | while ($tmp !~ /^$/) {
|
---|
176 | if ($dtype eq "deb") {
|
---|
177 | $tmp =~ s/^- //;
|
---|
178 | print $OUTPUT " * $tmp";
|
---|
179 | } elsif ($dtype eq "rpm") {
|
---|
180 | print $OUTPUT "$tmp";
|
---|
181 | } else {
|
---|
182 | print $OUTPUT "$tmp";
|
---|
183 | }
|
---|
184 | last if (eof(INPUT));
|
---|
185 | $tmp = <INPUT>;
|
---|
186 | }
|
---|
187 | print $OUTPUT "\n";
|
---|
188 |
|
---|
189 | if ($dtype eq "deb") {
|
---|
190 | # Cf: http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog
|
---|
191 | print $OUTPUT " -- $pbpackager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
|
---|
192 | }
|
---|
193 |
|
---|
194 | last if (eof(INPUT));
|
---|
195 | last if ($dtype eq "announce");
|
---|
196 | }
|
---|
197 | close(INPUT);
|
---|
198 | }
|
---|
199 |
|
---|
200 |
|
---|
201 | =back
|
---|
202 |
|
---|
203 | =head1 WEB SITES
|
---|
204 |
|
---|
205 | 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/>.
|
---|
206 |
|
---|
207 | =head1 USER MAILING LIST
|
---|
208 |
|
---|
209 | None exists for the moment.
|
---|
210 |
|
---|
211 | =head1 AUTHORS
|
---|
212 |
|
---|
213 | The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>.
|
---|
214 |
|
---|
215 | =head1 COPYRIGHT
|
---|
216 |
|
---|
217 | Project-Builder.org is distributed under the GPL v2.0 license
|
---|
218 | described in the file C<COPYING> included with the distribution.
|
---|
219 |
|
---|
220 | =cut
|
---|
221 |
|
---|
222 | 1;
|
---|