source: MondoRescue/branches/stable/tools/mkchangelog.pl@ 636

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

First attempt to automize changelog generation for packages from the std ChangeLogs files from mindi/mondo

  • 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 printf OUTPUT "* $ndate Bruno Cornec <bruno\@mondorescue.org> $ver\n";
66 printf OUTPUT "- Updated to $ver\n";
67
68 $tmp = <INPUT>;
69 while ($tmp !~ /^$/) {
70 printf OUTPUT $tmp;
71 $tmp = <INPUT>;
72 }
73 printf OUTPUT "\n";
74 }
75}
76close(OUTPUT);
77close(INPUT);
Note: See TracBrowser for help on using the repository browser.