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 $ver2 = "";
|
---|
26 | my $date = "";
|
---|
27 |
|
---|
28 | # For date handling
|
---|
29 | $ENV{LANG}="C";
|
---|
30 |
|
---|
31 | die "Syntax : mkchangelog dtype package-name output-file"
|
---|
32 | if ((not (defined $dtype)) || ($dtype eq "") ||
|
---|
33 | (not (defined $pkg)) || ($pkg eq "") ||
|
---|
34 | (not (defined $outfile)) || ($outfile eq ""));
|
---|
35 |
|
---|
36 | my $TOOLHOME;
|
---|
37 | $tmp = dirname($PROGRAM_NAME);
|
---|
38 | if ($tmp =~ /^\//) {
|
---|
39 | $TOOLHOME = $tmp;
|
---|
40 | }
|
---|
41 | else {
|
---|
42 | $TOOLHOME = "$ENV{PWD}/$tmp";
|
---|
43 | }
|
---|
44 |
|
---|
45 | die "TOOLHOME doesn't exist" if (not (defined $TOOLHOME));
|
---|
46 |
|
---|
47 | if (-f "$TOOLHOME/../$pkg/ChangeLog") {
|
---|
48 | $chglog = "$TOOLHOME/../$pkg/ChangeLog";
|
---|
49 | }
|
---|
50 | else {
|
---|
51 | $pkg2 = $pkg;
|
---|
52 | $pkg2 =~ s/-..*//;
|
---|
53 | if (-f "$TOOLHOME/../$pkg2/ChangeLog") {
|
---|
54 | $chglog = "$TOOLHOME/../$pkg2/ChangeLog";
|
---|
55 | }
|
---|
56 | else {
|
---|
57 | die "Unable to find a ChangeLog file for $pkg\n";
|
---|
58 | }
|
---|
59 | }
|
---|
60 | print "Using $chglog as input ChangeLog file for $pkg\n";
|
---|
61 |
|
---|
62 | open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
|
---|
63 | open(OUTPUT,"> $outfile") || die "Unable to open $outfile (write)";
|
---|
64 | open(TAG, "$ENV{TOPDIR}/LAST") || die "Unable to open $ENV{TOPDIR}/LAST";
|
---|
65 |
|
---|
66 | $tmp = <TAG>;
|
---|
67 | chomp($tmp);
|
---|
68 | my ($tmp2, $tag) = split(/-/, $tmp);
|
---|
69 | # Skip first 4 lines
|
---|
70 | $tmp = <INPUT>;
|
---|
71 | $tmp = <INPUT>;
|
---|
72 | $tmp = <INPUT>;
|
---|
73 | if ($dtype eq "announce") {
|
---|
74 | print OUTPUT $tmp;
|
---|
75 | }
|
---|
76 | $tmp = <INPUT>;
|
---|
77 | if ($dtype eq "announce") {
|
---|
78 | print OUTPUT $tmp;
|
---|
79 | }
|
---|
80 |
|
---|
81 | # Handle each block separated by newline
|
---|
82 | while (<INPUT>) {
|
---|
83 | ($ver, $date) = split(/ /);
|
---|
84 | $ver =~ s/^v//;
|
---|
85 | chomp($date);
|
---|
86 | $date =~ s/\(([0-9-]+)\)/$1/;
|
---|
87 | #print "**$date**\n";
|
---|
88 | $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
89 | $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
90 | #print "**$ndate**\n";
|
---|
91 | if ($dtype eq "rpm") {
|
---|
92 | if ($ver !~ /-/) {
|
---|
93 | $ver2 = "$ver-$tag"."$ENV{suf}";
|
---|
94 | } else {
|
---|
95 | $ver2 = "$ver"."$ENV{suf}";
|
---|
96 | }
|
---|
97 | print OUTPUT "* $ndate Bruno Cornec <bruno\@mondorescue.org> $ver2\n";
|
---|
98 | print OUTPUT "- Updated to $ver\n";
|
---|
99 | }
|
---|
100 | if ($dtype eq "deb") {
|
---|
101 | print OUTPUT "$pkg ($ver) unstable; urgency=low\n";
|
---|
102 | print OUTPUT "\n";
|
---|
103 | }
|
---|
104 |
|
---|
105 | $tmp = <INPUT>;
|
---|
106 | while ($tmp !~ /^$/) {
|
---|
107 | if ($dtype eq "deb") {
|
---|
108 | print OUTPUT " * $tmp";
|
---|
109 | }
|
---|
110 | else {
|
---|
111 | print OUTPUT "$tmp";
|
---|
112 | }
|
---|
113 | last if (eof(INPUT));
|
---|
114 | $tmp = <INPUT>;
|
---|
115 | }
|
---|
116 | print OUTPUT "\n";
|
---|
117 |
|
---|
118 | if ($dtype eq "deb") {
|
---|
119 | print OUTPUT " -- Bruno Cornec <bruno\@mondorescue.org> $n2date\n\n";
|
---|
120 | print OUTPUT "\n";
|
---|
121 | }
|
---|
122 |
|
---|
123 | last if (eof(INPUT));
|
---|
124 | last if ($dtype eq "announce");
|
---|
125 | }
|
---|
126 | close(OUTPUT);
|
---|
127 | close(INPUT);
|
---|