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

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

pb_env_init now creates a pbconf template dir if asked for (newproj option)

File size: 3.3 KB
RevLine 
[17]1#!/usr/bin/perl -w
2#
[273]3# Creates all changelog for packages from a single Changelog files in pbconf
[17]4#
5# $Id$
6#
7
8use strict;
9use Date::Manip;
10use File::Basename;
11use English;
[89]12use ProjectBuilder::Base qw (pb_conf_get);
[17]13
[74]14sub pb_changelog {
[17]15
16my $dtype = shift;
17my $pkg = shift;
[254]18my $pbver = shift;
[17]19my $pbtag = shift;
20my $dsuf = shift;
[18]21my $path = shift;
[17]22my $OUTPUT = shift;
[254]23my $doit = shift;
[17]24
25my $log = "";
26
27# For date handling
28$ENV{LANG}="C";
29
30return("\n") if ((not (defined $dtype)) || ($dtype eq "") ||
31 (not (defined $pkg)) || ($pkg eq "") ||
[254]32 (not (defined $pbver)) || ($pbver eq "") ||
[18]33 (not (defined $pbtag)) || ($pbtag eq "") ||
34 (not (defined $dsuf)) || ($dsuf eq "") ||
35 (not (defined $path)) || ($path eq "") ||
[255]36 (not (defined $OUTPUT)) || ($OUTPUT eq "") ||
[254]37 (not (defined $doit)) || ($doit eq ""));
[17]38
[18]39my $chglog = "$ENV{'PBROOT'}/$path/ChangeLog";
[254]40if ((! -f $chglog) && ($doit eq "yes")) {
[227]41 #print "No ChangeLog file ($chglog) for $pkg\n";
[17]42 return("\n");
43}
44
[255]45my $date;
46my $ndate;
47my $n2date;
48my $ver;
49my $ver2;
50my ($packager) = pb_conf_get("packager");
51
[254]52# If we don't need to do it, fake something
53if ($doit ne "yes") {
54 my @date=(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
[255]55 $date = strftime("%Y-%m-%d", @date);
56 $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
57 $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
[254]58 if (($dtype eq "rpm") || ($dtype eq "fc")) {
[255]59 $ver2 = "$pbver-$pbtag$dsuf";
[254]60 print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
61 print $OUTPUT "- Updated to $pbver\n";
62 }
63 if ($dtype eq "deb") {
64 print $OUTPUT "$pkg ($pbver) unstable; urgency=low\n";
65 print $OUTPUT "\n";
66 print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
67 }
68 return;
69}
70
[17]71open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
72
73# Skip first 4 lines
74my $tmp = <INPUT>;
75$tmp = <INPUT>;
76$tmp = <INPUT>;
77if ($dtype eq "announce") {
78 print $OUTPUT $tmp;
79}
80$tmp = <INPUT>;
81if ($dtype eq "announce") {
82 print $OUTPUT $tmp;
83}
84
85my $first=1;
86
87# Handle each block separated by newline
88while (<INPUT>) {
[255]89 ($ver, $date) = split(/ /);
[17]90 $ver =~ s/^v//;
91 chomp($date);
92 $date =~ s/\(([0-9-]+)\)/$1/;
93 #print "**$date**\n";
[255]94 $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
95 $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
[17]96 #print "**$ndate**\n";
[88]97
[17]98 if (($dtype eq "rpm") || ($dtype eq "fc")) {
99 if ($ver !~ /-/) {
100 if ($first eq 1) {
101 $ver2 = "$ver-$pbtag$dsuf";
102 $first=0;
103 } else {
104 $ver2 = "$ver-1$dsuf";
105 }
106 } else {
107 $ver2 = "$ver$dsuf";
108 }
[88]109 print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
[17]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") {
[194]120 $tmp =~ s/^- //;
[17]121 print $OUTPUT " * $tmp";
122 } elsif ($dtype eq "rpm") {
123 print $OUTPUT "$tmp";
124 } else {
125 print $OUTPUT "$tmp";
126 }
127 last if (eof(INPUT));
128 $tmp = <INPUT>;
129 }
130 print $OUTPUT "\n";
131
132 if ($dtype eq "deb") {
[194]133 # Cf: http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog
134 print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
[17]135 }
136
137 last if (eof(INPUT));
138 last if ($dtype eq "announce");
139}
140close(INPUT);
141}
1421;
Note: See TracBrowser for help on using the repository browser.