source: MondoRescue/branches/2.0.9/tools/mkchangelog.pl@ 777

Last change on this file since 777 was 777, checked in by Bruno Cornec, 18 years ago

Fix #41 again

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