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 $tmp = "";
|
---|
23 | my $ver = "";
|
---|
24 | my $date = "";
|
---|
25 |
|
---|
26 | # For date handling
|
---|
27 | $ENV{LANG}="C";
|
---|
28 |
|
---|
29 | die "Syntax : mkchangelog dtype package-name output-file"
|
---|
30 | if ((not (defined $dtype)) || ($dtype eq "") ||
|
---|
31 | (not (defined $pkg)) || ($pkg eq "") ||
|
---|
32 | (not (defined $outfile)) || ($outfile eq ""));
|
---|
33 |
|
---|
34 | my $TOOLHOME;
|
---|
35 | $tmp = dirname($PROGRAM_NAME);
|
---|
36 | if ($tmp =~ /^\//) {
|
---|
37 | $TOOLHOME = $tmp;
|
---|
38 | }
|
---|
39 | else {
|
---|
40 | $TOOLHOME = "$ENV{PWD}/$tmp";
|
---|
41 | }
|
---|
42 |
|
---|
43 | die "TOOLHOME doesn't exist" if (not (defined $TOOLHOME));
|
---|
44 |
|
---|
45 | if (-f "$TOOLHOME/../$pkg/ChangeLog") {
|
---|
46 | $chglog = "$TOOLHOME/../$pkg/ChangeLog";
|
---|
47 | }
|
---|
48 | else {
|
---|
49 | $pkg2 = $pkg;
|
---|
50 | $pkg2 =~ s/-..*//;
|
---|
51 | if (-f "$TOOLHOME/../$pkg2/ChangeLog") {
|
---|
52 | $chglog = "$TOOLHOME/../$pkg2/ChangeLog";
|
---|
53 | }
|
---|
54 | else {
|
---|
55 | die "Unable to find a ChangeLog file for $pkg\n";
|
---|
56 | }
|
---|
57 | }
|
---|
58 | print "Using $chglog as input ChangeLog file for $pkg\n";
|
---|
59 |
|
---|
60 | open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
|
---|
61 | open(OUTPUT,"> $outfile") || die "Unable to open $outfile (write)";
|
---|
62 | # Skip first 4 lines
|
---|
63 | $tmp = <INPUT>;
|
---|
64 | $tmp = <INPUT>;
|
---|
65 | $tmp = <INPUT>;
|
---|
66 | if ($dtype eq "announce") {
|
---|
67 | print OUTPUT $tmp;
|
---|
68 | }
|
---|
69 | $tmp = <INPUT>;
|
---|
70 | if ($dtype eq "announce") {
|
---|
71 | print OUTPUT $tmp;
|
---|
72 | }
|
---|
73 |
|
---|
74 | # Handle each block separated by newline
|
---|
75 | while (<INPUT>) {
|
---|
76 | ($ver, $date) = split(/ /);
|
---|
77 | chomp($date);
|
---|
78 | $date =~ s/\(([0-9-]+)\)/$1/;
|
---|
79 | #print "**$date**\n";
|
---|
80 | $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
81 | #print "**$ndate**\n";
|
---|
82 | if ($dtype eq "rpm") {
|
---|
83 | print OUTPUT "* $ndate Bruno Cornec <bruno\@mondorescue.org> $ver\n";
|
---|
84 | print OUTPUT "- Updated to $ver\n";
|
---|
85 | }
|
---|
86 |
|
---|
87 | $tmp = <INPUT>;
|
---|
88 | while ($tmp !~ /^$/) {
|
---|
89 | print OUTPUT $tmp;
|
---|
90 | last if (eof(INPUT));
|
---|
91 | $tmp = <INPUT>;
|
---|
92 | }
|
---|
93 | print OUTPUT "\n";
|
---|
94 | last if (eof(INPUT));
|
---|
95 | last if ($dtype eq "announce");
|
---|
96 | }
|
---|
97 | close(OUTPUT);
|
---|
98 | close(INPUT);
|
---|