source: MondoRescue/trunk/tools/mkchangelog.pl@ 652

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

merge -r641:651 $SVN_M/branches/stable

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