source: ProjectBuilder/devel/pb/lib/changelog.pm@ 21

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

Add syntax, control of traces, debug level ...
Much Nicer output now

File size: 2.2 KB
Line 
1#!/usr/bin/perl -w
2#
3# Creates changelog for packages from Changelog files in the apps
4#
5# $Id$
6#
7
8use strict;
9use Date::Manip;
10use File::Basename;
11use English;
12
13sub changelog {
14
15my $dtype = shift;
16my $pkg = shift;
17my $pbtag = shift;
18my $dsuf = shift;
19my $path = shift;
20my $OUTPUT = shift;
21
22my $log = "";
23
24# For date handling
25$ENV{LANG}="C";
26
27return("\n") if ((not (defined $dtype)) || ($dtype eq "") ||
28 (not (defined $pkg)) || ($pkg eq "") ||
29 (not (defined $pbtag)) || ($pbtag eq "") ||
30 (not (defined $dsuf)) || ($dsuf eq "") ||
31 (not (defined $path)) || ($path eq "") ||
32 (not (defined $OUTPUT)) || ($OUTPUT eq ""));
33
34my $chglog = "$ENV{'PBROOT'}/$path/ChangeLog";
35if (! -f $chglog) {
36 print "Unable to find the ChangeLog file ($chglog) for $pkg\n" if ($debug >= 0);
37 return("\n");
38}
39
40open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
41
42# Skip first 4 lines
43my $tmp = <INPUT>;
44$tmp = <INPUT>;
45$tmp = <INPUT>;
46if ($dtype eq "announce") {
47 print $OUTPUT $tmp;
48}
49$tmp = <INPUT>;
50if ($dtype eq "announce") {
51 print $OUTPUT $tmp;
52}
53
54my $first=1;
55
56# Handle each block separated by newline
57while (<INPUT>) {
58 my ($ver, $date) = split(/ /);
59 my $ver2;
60 $ver =~ s/^v//;
61 chomp($date);
62 $date =~ s/\(([0-9-]+)\)/$1/;
63 #print "**$date**\n";
64 my $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
65 my $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
66 #print "**$ndate**\n";
67 if (($dtype eq "rpm") || ($dtype eq "fc")) {
68 if ($ver !~ /-/) {
69 if ($first eq 1) {
70 $ver2 = "$ver-$pbtag$dsuf";
71 $first=0;
72 } else {
73 $ver2 = "$ver-1$dsuf";
74 }
75 } else {
76 $ver2 = "$ver$dsuf";
77 }
78 print $OUTPUT "* $ndate $confparam{'packager'} $ver2\n";
79 print $OUTPUT "- Updated to $ver\n";
80 }
81 if ($dtype eq "deb") {
82 print $OUTPUT "$pkg ($ver) unstable; urgency=low\n";
83 print $OUTPUT "\n";
84 }
85
86 $tmp = <INPUT>;
87 while ($tmp !~ /^$/) {
88 if ($dtype eq "deb") {
89 print $OUTPUT " * $tmp";
90 } elsif ($dtype eq "rpm") {
91 print $OUTPUT "$tmp";
92 } else {
93 print $OUTPUT "$tmp";
94 }
95 last if (eof(INPUT));
96 $tmp = <INPUT>;
97 }
98 print $OUTPUT "\n";
99
100 if ($dtype eq "deb") {
101 print $OUTPUT " -- $confparam{'packager'} $n2date\n\n";
102 print $OUTPUT "\n";
103 }
104
105 last if (eof(INPUT));
106 last if ($dtype eq "announce");
107}
108close(INPUT);
109}
1101;
Note: See TracBrowser for help on using the repository browser.