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