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