1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # Creates changelog for packages from Changelog files in the apps
|
---|
4 | #
|
---|
5 | # $Id$
|
---|
6 | #
|
---|
7 |
|
---|
8 | use strict;
|
---|
9 | use Date::Manip;
|
---|
10 | use File::Basename;
|
---|
11 | use English;
|
---|
12 |
|
---|
13 | sub changelog {
|
---|
14 |
|
---|
15 | my $dtype = shift;
|
---|
16 | my $pkg = shift;
|
---|
17 | my $pbtag = shift;
|
---|
18 | my $dsuf = shift;
|
---|
19 | my $path = shift;
|
---|
20 | my $OUTPUT = shift;
|
---|
21 |
|
---|
22 | my $log = "";
|
---|
23 |
|
---|
24 | # For date handling
|
---|
25 | $ENV{LANG}="C";
|
---|
26 |
|
---|
27 | return("\n") if ((not (defined $dtype)) || ($dtype eq "") ||
|
---|
28 | (not (defined $pkg)) || ($pkg eq "") ||
|
---|
29 | (not (defined $pbtag)) || ($pbtag eq "") ||
|
---|
30 | (not (defined $dsuf)) || ($dsuf eq "") ||
|
---|
31 | (not (defined $path)) || ($path eq "") ||
|
---|
32 | (not (defined $OUTPUT)) || ($OUTPUT eq ""));
|
---|
33 |
|
---|
34 | my $chglog = "$ENV{'PBROOT'}/$path/ChangeLog";
|
---|
35 | if (! -f $chglog) {
|
---|
36 | print "Unable to find the ChangeLog file ($chglog) for $pkg\n" if ($debug >= 0);
|
---|
37 | return("\n");
|
---|
38 | }
|
---|
39 |
|
---|
40 | open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
|
---|
41 |
|
---|
42 | # Skip first 4 lines
|
---|
43 | my $tmp = <INPUT>;
|
---|
44 | $tmp = <INPUT>;
|
---|
45 | $tmp = <INPUT>;
|
---|
46 | if ($dtype eq "announce") {
|
---|
47 | print $OUTPUT $tmp;
|
---|
48 | }
|
---|
49 | $tmp = <INPUT>;
|
---|
50 | if ($dtype eq "announce") {
|
---|
51 | print $OUTPUT $tmp;
|
---|
52 | }
|
---|
53 |
|
---|
54 | my $first=1;
|
---|
55 |
|
---|
56 | # Handle each block separated by newline
|
---|
57 | while (<INPUT>) {
|
---|
58 | my ($ver, $date) = split(/ /);
|
---|
59 | my $ver2;
|
---|
60 | $ver =~ s/^v//;
|
---|
61 | chomp($date);
|
---|
62 | $date =~ s/\(([0-9-]+)\)/$1/;
|
---|
63 | #print "**$date**\n";
|
---|
64 | my $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
65 | my $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
66 | #print "**$ndate**\n";
|
---|
67 | if (($dtype eq "rpm") || ($dtype eq "fc")) {
|
---|
68 | if ($ver !~ /-/) {
|
---|
69 | if ($first eq 1) {
|
---|
70 | $ver2 = "$ver-$pbtag$dsuf";
|
---|
71 | $first=0;
|
---|
72 | } else {
|
---|
73 | $ver2 = "$ver-1$dsuf";
|
---|
74 | }
|
---|
75 | } else {
|
---|
76 | $ver2 = "$ver$dsuf";
|
---|
77 | }
|
---|
78 | print $OUTPUT "* $ndate $confparam{'packager'} $ver2\n";
|
---|
79 | print $OUTPUT "- Updated to $ver\n";
|
---|
80 | }
|
---|
81 | if ($dtype eq "deb") {
|
---|
82 | print $OUTPUT "$pkg ($ver) unstable; urgency=low\n";
|
---|
83 | print $OUTPUT "\n";
|
---|
84 | }
|
---|
85 |
|
---|
86 | $tmp = <INPUT>;
|
---|
87 | while ($tmp !~ /^$/) {
|
---|
88 | if ($dtype eq "deb") {
|
---|
89 | print $OUTPUT " * $tmp";
|
---|
90 | } elsif ($dtype eq "rpm") {
|
---|
91 | print $OUTPUT "$tmp";
|
---|
92 | } else {
|
---|
93 | print $OUTPUT "$tmp";
|
---|
94 | }
|
---|
95 | last if (eof(INPUT));
|
---|
96 | $tmp = <INPUT>;
|
---|
97 | }
|
---|
98 | print $OUTPUT "\n";
|
---|
99 |
|
---|
100 | if ($dtype eq "deb") {
|
---|
101 | print $OUTPUT " -- $confparam{'packager'} $n2date\n\n";
|
---|
102 | print $OUTPUT "\n";
|
---|
103 | }
|
---|
104 |
|
---|
105 | last if (eof(INPUT));
|
---|
106 | last if ($dtype eq "announce");
|
---|
107 | }
|
---|
108 | close(INPUT);
|
---|
109 | }
|
---|
110 | 1;
|
---|