1  #!/usr/bin/perl w


2  #


3  # Creates changelog for packages from Changelog files in the apps


4  #


5  # $Id$


6  #


7 


8  use strict;


9  use Date::Manip;


10  use File::Basename;


11  use English;


12  use ProjectBuilder::Base qw (pb_conf_read);


13 


14  sub pb_changelog {


15 


16  my $dtype = shift;


17  my $pkg = shift;


18  my $pbtag = shift;


19  my $dsuf = shift;


20  my $path = shift;


21  my $OUTPUT = shift;


22 


23  my $log = "";


24 


25  # For date handling


26  $ENV{LANG}="C";


27 


28  return("\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 


35  my $chglog = "$ENV{'PBROOT'}/$path/ChangeLog";


36  if (! f $chglog) {


37  print "Unable to find the ChangeLog file ($chglog) for $pkg\n" if ($debug >= 0);


38  return("\n");


39  }


40 


41  open(INPUT,"$chglog")  die "Unable to open $chglog (read)";


42 


43  # Skip first 4 lines


44  my $tmp = <INPUT>;


45  $tmp = <INPUT>;


46  $tmp = <INPUT>;


47  if ($dtype eq "announce") {


48  print $OUTPUT $tmp;


49  }


50  $tmp = <INPUT>;


51  if ($dtype eq "announce") {


52  print $OUTPUT $tmp;


53  }


54 


55  my $first=1;


56 


57  # Handle each block separated by newline


58  while (<INPUT>) {


59  my ($ver, $date) = split(/ /);


60  my $ver2;


61  $ver =~ s/^v//;


62  chomp($date);


63  $date =~ s/\(([09]+)\)/$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 = "$ver1$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  }


111  close(INPUT);


112  }


113  1;

