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

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

changelog are now generated from mindi's and mondo's main ChangeLog files
new tool to create automatically announces for new version-tag
news.shtml and latest-news.html are now generated from a DB of announce (SQLite)
announce DB added (SQLite v3)
Build process improved for Debian

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