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

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

Still in dev. phase - lots of changes - near the end for cms2build

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