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

Last change on this file since 320 was 320, checked in by Bruno Cornec, 16 years ago
  • Param packager => pbpackager for consistency, and PBPACKAGER is an env var usable
  • Base is now a perl package
  • Multiple fixes all around the place with a correct collectl build from http URL
  • Add build2ve/cms2ve/newve/script2ve and mock support
  • build2vm/launchvm => build2v/launchv and has now a parameter
  • send2ssh => send2target, will be able to evolve later + lots of parameter changes to support VE
  • Add file support
  • Add -f option to force rebuilding the chroot
  • Env var PBVM => PBV
  • Update the concepts doc
File size: 3.4 KB
Line 
1#!/usr/bin/perl -w
2#
3# Creates all changelog for packages from a single Changelog files in pbconf
4#
5# $Id$
6#
7
8use strict;
9use Date::Manip;
10use File::Basename;
11use English;
12use ProjectBuilder::Base qw (pb_conf_get);
13
14sub pb_changelog {
15
16my $dtype = shift;
17my $pkg = shift;
18my $pbver = shift;
19my $pbtag = shift;
20my $dsuf = shift;
21my $path = shift;
22my $OUTPUT = shift;
23my $doit = shift;
24my $chglog = shift || undef;
25
26my $log = "";
27
28# For date handling
29$ENV{LANG}="C";
30
31if ((not (defined $dtype)) || ($dtype eq "") ||
32 (not (defined $pkg)) || ($pkg eq "") ||
33 (not (defined $pbver)) || ($pbver eq "") ||
34 (not (defined $pbtag)) || ($pbtag eq "") ||
35 (not (defined $dsuf)) || ($dsuf eq "") ||
36 (not (defined $path)) || ($path eq "") ||
37 (not (defined $OUTPUT)) || ($OUTPUT eq "") ||
38 (not (defined $doit)) || ($doit eq "")) {
39 print $OUTPUT "\n";
40 return;
41}
42
43if (((not defined $chglog) || (! -f $chglog)) && ($doit eq "yes")) {
44 #pb_log(2,"No ChangeLog file ($chglog) for $pkg\n";
45 print $OUTPUT "\n";
46 return;
47}
48
49my $date;
50my $ndate;
51my $n2date;
52my $ver;
53my $ver2;
54my ($packager) = pb_conf_get("pbpackager");
55
56# If we don't need to do it, or don't have it fake something
57if (((not defined $chglog) || (! -f $chglog)) && ($doit ne "yes")) {
58 my @date=(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
59 $date = strftime("%Y-%m-%d", @date);
60 $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
61 $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
62 if (($dtype eq "rpm") || ($dtype eq "fc")) {
63 $ver2 = "$pbver-$pbtag$dsuf";
64 print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
65 print $OUTPUT "- Updated to $pbver\n";
66 }
67 if ($dtype eq "deb") {
68 print $OUTPUT "$pkg ($pbver) unstable; urgency=low\n";
69 print $OUTPUT "\n";
70 print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
71 }
72 return;
73}
74
75open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
76
77# Skip first 4 lines
78my $tmp = <INPUT>;
79$tmp = <INPUT>;
80$tmp = <INPUT>;
81if ($dtype eq "announce") {
82 print $OUTPUT $tmp;
83}
84$tmp = <INPUT>;
85if ($dtype eq "announce") {
86 print $OUTPUT $tmp;
87}
88
89my $first=1;
90
91# Handle each block separated by newline
92while (<INPUT>) {
93 ($ver, $date) = split(/ /);
94 $ver =~ s/^v//;
95 chomp($date);
96 $date =~ s/\(([0-9-]+)\)/$1/;
97 #pb_log(2,"**$date**\n";
98 $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
99 $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
100 #pb_log(2,"**$ndate**\n";
101
102 if (($dtype eq "rpm") || ($dtype eq "fc")) {
103 if ($ver !~ /-/) {
104 if ($first eq 1) {
105 $ver2 = "$ver-$pbtag$dsuf";
106 $first=0;
107 } else {
108 $ver2 = "$ver-1$dsuf";
109 }
110 } else {
111 $ver2 = "$ver$dsuf";
112 }
113 print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
114 print $OUTPUT "- Updated to $ver\n";
115 }
116 if ($dtype eq "deb") {
117 print $OUTPUT "$pkg ($ver) unstable; urgency=low\n";
118 print $OUTPUT "\n";
119 }
120
121 $tmp = <INPUT>;
122 while ($tmp !~ /^$/) {
123 if ($dtype eq "deb") {
124 $tmp =~ s/^- //;
125 print $OUTPUT " * $tmp";
126 } elsif ($dtype eq "rpm") {
127 print $OUTPUT "$tmp";
128 } else {
129 print $OUTPUT "$tmp";
130 }
131 last if (eof(INPUT));
132 $tmp = <INPUT>;
133 }
134 print $OUTPUT "\n";
135
136 if ($dtype eq "deb") {
137 # Cf: http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog
138 print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
139 }
140
141 last if (eof(INPUT));
142 last if ($dtype eq "announce");
143}
144close(INPUT);
145}
1461;
Note: See TracBrowser for help on using the repository browser.