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