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

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

Changelog reviewed once more

  • Property svn:executable set to *
File size: 1.8 KB
RevLine 
[636]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
[646]33die "TOOLHOME doesn't exist" if (not (defined $TOOLHOME));
34
[636]35if (-f "$TOOLHOME/../$pkg/ChangeLog") {
36 $chglog = "$TOOLHOME/../$pkg/ChangeLog";
37 }
38else {
39 $pkg2 = $pkg;
40 $pkg2 =~ s/-..*//;
41 if (-f "$TOOLHOME/../$pkg2/ChangeLog") {
42 $chglog = "$TOOLHOME/../$pkg2/ChangeLog";
43 }
44 else {
45 die "Unable to find a ChangeLog file for $pkg\n";
46 }
47}
48print "Using $chglog as input ChangeLog file for $pkg\n";
49
50open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
51open(OUTPUT,"> $outfile") || die "Unable to open $outfile (write)";
52# Skip first 4 lines
53$tmp = <INPUT>;
54$tmp = <INPUT>;
55$tmp = <INPUT>;
56$tmp = <INPUT>;
57
58# Handle each block separated by newline
59while (<INPUT>) {
60 ($ver, $date) = split(/ /);
61 chomp($date);
62 $date =~ s/\(([0-9-]+)\)/$1/;
[642]63 #print "**$date**\n";
[636]64 $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
[642]65 #print "**$ndate**\n";
[636]66 if ($dtype eq "rpm") {
[644]67 print OUTPUT "* $ndate Bruno Cornec <bruno\@mondorescue.org> $ver\n";
68 print OUTPUT "- Updated to $ver\n";
[636]69
70 $tmp = <INPUT>;
71 while ($tmp !~ /^$/) {
[644]72 print OUTPUT $tmp;
[646]73 last if (eof(INPUT));
74 $tmp = <INPUT>;
[636]75 }
[644]76 print OUTPUT "\n";
[646]77 last if (eof(INPUT));
[636]78 }
79}
80close(OUTPUT);
81close(INPUT);
Note: See TracBrowser for help on using the repository browser.