source: ProjectBuilder/devel/pb/lib/ProjectBuilder/Changelog.pm@ 74

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

Big renaming to be more perlish
Single module Base contains all routines except when detaching makes sense

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