source: MondoRescue/branches/2.0.8/tools/mkchangelog.pl@ 645

Last change on this file since 645 was 645, checked in by bcornec, 18 years ago

still some changelog improvements

  • Property svn:executable set to *
File size: 1.7 KB
Line 
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
10use strict;
11use Date::Manip;
12
13my $log = "";
14my $dtype = $ARGV[0];
15my $pkg = $ARGV[1];
16my $pkg2;
17my $outfile = $ARGV[2];
18my $TOOLHOME = $ENV{TOOLHOME};
19my $chglog = "";
20my $ndate = "";
21my $tmp = "";
22my $ver = "";
23my $date = "";
24
25# For date handling
26$ENV{LANG}="C";
27
28die "Syntax : mkchangelog dtype package-name output-file"
29 if ((not (defined $dtype)) || ($dtype eq "") ||
30 (not (defined $pkg)) || ($pkg eq "") ||
31 (not (defined $outfile)) || ($outfile eq ""));
32
33if (-f "$TOOLHOME/../$pkg/ChangeLog") {
34 $chglog = "$TOOLHOME/../$pkg/ChangeLog";
35 }
36else {
37 $pkg2 = $pkg;
38 $pkg2 =~ s/-..*//;
39 if (-f "$TOOLHOME/../$pkg2/ChangeLog") {
40 $chglog = "$TOOLHOME/../$pkg2/ChangeLog";
41 }
42 else {
43 die "Unable to find a ChangeLog file for $pkg\n";
44 }
45}
46print "Using $chglog as input ChangeLog file for $pkg\n";
47
48open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
49open(OUTPUT,"> $outfile") || die "Unable to open $outfile (write)";
50# Skip first 4 lines
51$tmp = <INPUT>;
52$tmp = <INPUT>;
53$tmp = <INPUT>;
54$tmp = <INPUT>;
55
56# Handle each block separated by newline
57while (<INPUT>) {
58 ($ver, $date) = split(/ /);
59 chomp($date);
60 $date =~ s/\(([0-9-]+)\)/$1/;
61 #print "**$date**\n";
62 $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
63 #print "**$ndate**\n";
64 if ($dtype eq "rpm") {
65 print OUTPUT "* $ndate Bruno Cornec <bruno\@mondorescue.org> $ver\n";
66 print OUTPUT "- Updated to $ver\n";
67
68 $tmp = <INPUT>;
69 while ($tmp !~ /^$/) {
70 print OUTPUT $tmp;
71 if (<INPUT>) {
72 $tmp = $_;
73 }
74 else {
75 last;
76 }
77 }
78 print OUTPUT "\n";
79 }
80}
81close(OUTPUT);
82close(INPUT);
Note: See TracBrowser for help on using the repository browser.