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
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;
[285]24my $chglog = shift || undef;
[17]25
26my $log = "";
27
28# For date handling
29$ENV{LANG}="C";
30
[285]31if ((not (defined $dtype)) || ($dtype eq "") ||
[17]32 (not (defined $pkg)) || ($pkg eq "") ||
[254]33 (not (defined $pbver)) || ($pbver eq "") ||
[18]34 (not (defined $pbtag)) || ($pbtag eq "") ||
35 (not (defined $dsuf)) || ($dsuf eq "") ||
36 (not (defined $path)) || ($path eq "") ||
[255]37 (not (defined $OUTPUT)) || ($OUTPUT eq "") ||
[285]38 (not (defined $doit)) || ($doit eq "")) {
39 print $OUTPUT "\n";
40 return;
41}
[17]42
[285]43if (((not defined $chglog) || (! -f $chglog)) && ($doit eq "yes")) {
[315]44 #pb_log(2,"No ChangeLog file ($chglog) for $pkg\n";
[285]45 print $OUTPUT "\n";
46 return;
[17]47}
48
[255]49my $date;
50my $ndate;
51my $n2date;
52my $ver;
53my $ver2;
[320]54my ($packager) = pb_conf_get("pbpackager");
[255]55
[285]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")) {
[254]58 my @date=(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
[255]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");
[254]62 if (($dtype eq "rpm") || ($dtype eq "fc")) {
[255]63 $ver2 = "$pbver-$pbtag$dsuf";
[254]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
[17]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>) {
[255]93 ($ver, $date) = split(/ /);
[17]94 $ver =~ s/^v//;
95 chomp($date);
96 $date =~ s/\(([0-9-]+)\)/$1/;
[315]97 #pb_log(2,"**$date**\n";
[255]98 $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
99 $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
[315]100 #pb_log(2,"**$ndate**\n";
[88]101
[17]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 }
[88]113 print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
[17]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") {
[194]124 $tmp =~ s/^- //;
[17]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") {
[194]137 # Cf: http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog
138 print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}} $n2date\n\n\n";
[17]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.