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 | my $chglog = shift || undef;
|
---|
25 |
|
---|
26 | my $log = "";
|
---|
27 |
|
---|
28 | # For date handling
|
---|
29 | $ENV{LANG}="C";
|
---|
30 |
|
---|
31 | if ((not (defined $dtype)) || ($dtype eq "") ||
|
---|
32 | (not (defined $pkg)) || ($pkg eq "") ||
|
---|
33 | (not (defined $pbver)) || ($pbver eq "") ||
|
---|
34 | (not (defined $pbtag)) || ($pbtag eq "") ||
|
---|
35 | (not (defined $dsuf)) || ($dsuf eq "") ||
|
---|
36 | (not (defined $path)) || ($path eq "") ||
|
---|
37 | (not (defined $OUTPUT)) || ($OUTPUT eq "") ||
|
---|
38 | (not (defined $doit)) || ($doit eq "")) {
|
---|
39 | print $OUTPUT "\n";
|
---|
40 | return;
|
---|
41 | }
|
---|
42 |
|
---|
43 | if (((not defined $chglog) || (! -f $chglog)) && ($doit eq "yes")) {
|
---|
44 | #print "No ChangeLog file ($chglog) for $pkg\n";
|
---|
45 | print $OUTPUT "\n";
|
---|
46 | return;
|
---|
47 | }
|
---|
48 |
|
---|
49 | my $date;
|
---|
50 | my $ndate;
|
---|
51 | my $n2date;
|
---|
52 | my $ver;
|
---|
53 | my $ver2;
|
---|
54 | my ($packager) = pb_conf_get("packager");
|
---|
55 |
|
---|
56 | # If we don't need to do it, or don't have it fake something
|
---|
57 | if (((not defined $chglog) || (! -f $chglog)) && ($doit ne "yes")) {
|
---|
58 | my @date=(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
|
---|
59 | $date = strftime("%Y-%m-%d", @date);
|
---|
60 | $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
61 | $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
62 | if (($dtype eq "rpm") || ($dtype eq "fc")) {
|
---|
63 | $ver2 = "$pbver-$pbtag$dsuf";
|
---|
64 | print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
|
---|
65 | print $OUTPUT "- Updated to $pbver\n";
|
---|
66 | }
|
---|
67 | if ($dtype eq "deb") {
|
---|
68 | print $OUTPUT "$pkg ($pbver) unstable; urgency=low\n";
|
---|
69 | print $OUTPUT "\n";
|
---|
70 | print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
|
---|
71 | }
|
---|
72 | return;
|
---|
73 | }
|
---|
74 |
|
---|
75 | open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
|
---|
76 |
|
---|
77 | # Skip first 4 lines
|
---|
78 | my $tmp = <INPUT>;
|
---|
79 | $tmp = <INPUT>;
|
---|
80 | $tmp = <INPUT>;
|
---|
81 | if ($dtype eq "announce") {
|
---|
82 | print $OUTPUT $tmp;
|
---|
83 | }
|
---|
84 | $tmp = <INPUT>;
|
---|
85 | if ($dtype eq "announce") {
|
---|
86 | print $OUTPUT $tmp;
|
---|
87 | }
|
---|
88 |
|
---|
89 | my $first=1;
|
---|
90 |
|
---|
91 | # Handle each block separated by newline
|
---|
92 | while (<INPUT>) {
|
---|
93 | ($ver, $date) = split(/ /);
|
---|
94 | $ver =~ s/^v//;
|
---|
95 | chomp($date);
|
---|
96 | $date =~ s/\(([0-9-]+)\)/$1/;
|
---|
97 | #print "**$date**\n";
|
---|
98 | $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
99 | $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
100 | #print "**$ndate**\n";
|
---|
101 |
|
---|
102 | if (($dtype eq "rpm") || ($dtype eq "fc")) {
|
---|
103 | if ($ver !~ /-/) {
|
---|
104 | if ($first eq 1) {
|
---|
105 | $ver2 = "$ver-$pbtag$dsuf";
|
---|
106 | $first=0;
|
---|
107 | } else {
|
---|
108 | $ver2 = "$ver-1$dsuf";
|
---|
109 | }
|
---|
110 | } else {
|
---|
111 | $ver2 = "$ver$dsuf";
|
---|
112 | }
|
---|
113 | print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
|
---|
114 | print $OUTPUT "- Updated to $ver\n";
|
---|
115 | }
|
---|
116 | if ($dtype eq "deb") {
|
---|
117 | print $OUTPUT "$pkg ($ver) unstable; urgency=low\n";
|
---|
118 | print $OUTPUT "\n";
|
---|
119 | }
|
---|
120 |
|
---|
121 | $tmp = <INPUT>;
|
---|
122 | while ($tmp !~ /^$/) {
|
---|
123 | if ($dtype eq "deb") {
|
---|
124 | $tmp =~ s/^- //;
|
---|
125 | print $OUTPUT " * $tmp";
|
---|
126 | } elsif ($dtype eq "rpm") {
|
---|
127 | print $OUTPUT "$tmp";
|
---|
128 | } else {
|
---|
129 | print $OUTPUT "$tmp";
|
---|
130 | }
|
---|
131 | last if (eof(INPUT));
|
---|
132 | $tmp = <INPUT>;
|
---|
133 | }
|
---|
134 | print $OUTPUT "\n";
|
---|
135 |
|
---|
136 | if ($dtype eq "deb") {
|
---|
137 | # Cf: http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog
|
---|
138 | print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
|
---|
139 | }
|
---|
140 |
|
---|
141 | last if (eof(INPUT));
|
---|
142 | last if ($dtype eq "announce");
|
---|
143 | }
|
---|
144 | close(INPUT);
|
---|
145 | }
|
---|
146 | 1;
|
---|