source: ProjectBuilder/devel/pb/lib/ProjectBuilder/Changelog.pm@ 254

Last change on this file since 254 was 254, checked in by Bruno Cornec, 17 years ago

Change pb_changelog interface in order to have a way to not generate logs for projects not ready for it.

File size: 3.3 KB
Line 
1#!/usr/bin/perl -w
2#
3# Creates changelog for packages from Changelog files in the apps
4#
5# $Id$
6#
7
8use strict;
9use Date::Manip;
10use File::Basename;
11use English;
12use ProjectBuilder::Base qw (pb_conf_get);
13
14sub pb_changelog {
15
16my $dtype = shift;
17my $pkg = shift;
18my $pbver = shift;
19my $pbtag = shift;
20my $dsuf = shift;
21my $path = shift;
22my $OUTPUT = shift;
23my $doit = shift;
24
25my $log = "";
26
27# For date handling
28$ENV{LANG}="C";
29
30return("\n") if ((not (defined $dtype)) || ($dtype eq "") ||
31 (not (defined $pkg)) || ($pkg eq "") ||
32 (not (defined $pbver)) || ($pbver eq "") ||
33 (not (defined $pbtag)) || ($pbtag eq "") ||
34 (not (defined $dsuf)) || ($dsuf eq "") ||
35 (not (defined $path)) || ($path eq "") ||
36 (not (defined $OUTPUT)) || ($OUTPUT eq ""));
37 (not (defined $doit)) || ($doit eq ""));
38
39my $chglog = "$ENV{'PBROOT'}/$path/ChangeLog";
40if ((! -f $chglog) && ($doit eq "yes")) {
41 #print "No ChangeLog file ($chglog) for $pkg\n";
42 return("\n");
43}
44
45# If we don't need to do it, fake something
46if ($doit ne "yes") {
47 my @date=(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
48 my $date = strftime("%Y-%m-%d", @date);
49 my $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
50 my $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
51 if (($dtype eq "rpm") || ($dtype eq "fc")) {
52 my $ver2 = "$pbver-$pbtag$dsuf";
53 print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
54 print $OUTPUT "- Updated to $pbver\n";
55 }
56 if ($dtype eq "deb") {
57 print $OUTPUT "$pkg ($pbver) unstable; urgency=low\n";
58 print $OUTPUT "\n";
59 print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
60 }
61 return;
62}
63
64open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
65
66# Skip first 4 lines
67my $tmp = <INPUT>;
68$tmp = <INPUT>;
69$tmp = <INPUT>;
70if ($dtype eq "announce") {
71 print $OUTPUT $tmp;
72}
73$tmp = <INPUT>;
74if ($dtype eq "announce") {
75 print $OUTPUT $tmp;
76}
77
78my $first=1;
79
80# Handle each block separated by newline
81while (<INPUT>) {
82 my ($ver, $date) = split(/ /);
83 my $ver2;
84 $ver =~ s/^v//;
85 chomp($date);
86 $date =~ s/\(([0-9-]+)\)/$1/;
87 #print "**$date**\n";
88 my $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
89 my $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
90 #print "**$ndate**\n";
91 my ($packager) = pb_conf_get("packager");
92
93 if (($dtype eq "rpm") || ($dtype eq "fc")) {
94 if ($ver !~ /-/) {
95 if ($first eq 1) {
96 $ver2 = "$ver-$pbtag$dsuf";
97 $first=0;
98 } else {
99 $ver2 = "$ver-1$dsuf";
100 }
101 } else {
102 $ver2 = "$ver$dsuf";
103 }
104 print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
105 print $OUTPUT "- Updated to $ver\n";
106 }
107 if ($dtype eq "deb") {
108 print $OUTPUT "$pkg ($ver) unstable; urgency=low\n";
109 print $OUTPUT "\n";
110 }
111
112 $tmp = <INPUT>;
113 while ($tmp !~ /^$/) {
114 if ($dtype eq "deb") {
115 $tmp =~ s/^- //;
116 print $OUTPUT " * $tmp";
117 } elsif ($dtype eq "rpm") {
118 print $OUTPUT "$tmp";
119 } else {
120 print $OUTPUT "$tmp";
121 }
122 last if (eof(INPUT));
123 $tmp = <INPUT>;
124 }
125 print $OUTPUT "\n";
126
127 if ($dtype eq "deb") {
128 # Cf: http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog
129 print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
130 }
131
132 last if (eof(INPUT));
133 last if ($dtype eq "announce");
134}
135close(INPUT);
136}
1371;
Note: See TracBrowser for help on using the repository browser.