source: MondoRescue/branches/2.2.1/tools/mkchangelog.pl@ 1017

Last change on this file since 1017 was 930, checked in by Bruno Cornec, 17 years ago

Fix type in mkchangelog.pl + some more comments for qemu build support (fedora)

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