[636] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
| 3 | # Creates changelog for packages from Changelog files in the apps
|
---|
| 4 | #
|
---|
| 5 | # $Id$
|
---|
| 6 | #
|
---|
| 7 | # Syntax : mkchangelog dtype package-name output-file
|
---|
| 8 | #
|
---|
| 9 |
|
---|
| 10 | use strict;
|
---|
| 11 | use Date::Manip;
|
---|
[656] | 12 | use File::Basename;
|
---|
| 13 | use English;
|
---|
[636] | 14 |
|
---|
| 15 | my $log = "";
|
---|
| 16 | my $dtype = $ARGV[0];
|
---|
| 17 | my $pkg = $ARGV[1];
|
---|
| 18 | my $pkg2;
|
---|
| 19 | my $outfile = $ARGV[2];
|
---|
| 20 | my $chglog = "";
|
---|
| 21 | my $ndate = "";
|
---|
[656] | 22 | my $n2date = "";
|
---|
[636] | 23 | my $tmp = "";
|
---|
| 24 | my $ver = "";
|
---|
| 25 | my $date = "";
|
---|
| 26 |
|
---|
| 27 | # For date handling
|
---|
| 28 | $ENV{LANG}="C";
|
---|
| 29 |
|
---|
| 30 | die "Syntax : mkchangelog dtype package-name output-file"
|
---|
| 31 | if ((not (defined $dtype)) || ($dtype eq "") ||
|
---|
| 32 | (not (defined $pkg)) || ($pkg eq "") ||
|
---|
| 33 | (not (defined $outfile)) || ($outfile eq ""));
|
---|
| 34 |
|
---|
[656] | 35 | my $TOOLHOME;
|
---|
| 36 | $tmp = dirname($PROGRAM_NAME);
|
---|
| 37 | if ($tmp =~ /^\//) {
|
---|
| 38 | $TOOLHOME = $tmp;
|
---|
| 39 | }
|
---|
| 40 | else {
|
---|
| 41 | $TOOLHOME = "$ENV{PWD}/$tmp";
|
---|
| 42 | }
|
---|
| 43 |
|
---|
[646] | 44 | die "TOOLHOME doesn't exist" if (not (defined $TOOLHOME));
|
---|
| 45 |
|
---|
[636] | 46 | if (-f "$TOOLHOME/../$pkg/ChangeLog") {
|
---|
| 47 | $chglog = "$TOOLHOME/../$pkg/ChangeLog";
|
---|
| 48 | }
|
---|
| 49 | else {
|
---|
| 50 | $pkg2 = $pkg;
|
---|
| 51 | $pkg2 =~ s/-..*//;
|
---|
| 52 | if (-f "$TOOLHOME/../$pkg2/ChangeLog") {
|
---|
| 53 | $chglog = "$TOOLHOME/../$pkg2/ChangeLog";
|
---|
| 54 | }
|
---|
| 55 | else {
|
---|
| 56 | die "Unable to find a ChangeLog file for $pkg\n";
|
---|
| 57 | }
|
---|
| 58 | }
|
---|
| 59 | print "Using $chglog as input ChangeLog file for $pkg\n";
|
---|
| 60 |
|
---|
| 61 | open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
|
---|
| 62 | open(OUTPUT,"> $outfile") || die "Unable to open $outfile (write)";
|
---|
| 63 | # Skip first 4 lines
|
---|
| 64 | $tmp = <INPUT>;
|
---|
| 65 | $tmp = <INPUT>;
|
---|
| 66 | $tmp = <INPUT>;
|
---|
[656] | 67 | if ($dtype eq "announce") {
|
---|
| 68 | print OUTPUT $tmp;
|
---|
| 69 | }
|
---|
[636] | 70 | $tmp = <INPUT>;
|
---|
[656] | 71 | if ($dtype eq "announce") {
|
---|
| 72 | print OUTPUT $tmp;
|
---|
| 73 | }
|
---|
[636] | 74 |
|
---|
| 75 | # Handle each block separated by newline
|
---|
| 76 | while (<INPUT>) {
|
---|
| 77 | ($ver, $date) = split(/ /);
|
---|
| 78 | chomp($date);
|
---|
| 79 | $date =~ s/\(([0-9-]+)\)/$1/;
|
---|
[642] | 80 | #print "**$date**\n";
|
---|
[636] | 81 | $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
[656] | 82 | $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
[642] | 83 | #print "**$ndate**\n";
|
---|
[636] | 84 | if ($dtype eq "rpm") {
|
---|
[644] | 85 | print OUTPUT "* $ndate Bruno Cornec <bruno\@mondorescue.org> $ver\n";
|
---|
| 86 | print OUTPUT "- Updated to $ver\n";
|
---|
[636] | 87 | }
|
---|
[656] | 88 | if ($dtype eq "deb") {
|
---|
| 89 | print OUTPUT "$pkg ($ver) unstable; urgency=low\n";
|
---|
[644] | 90 | print OUTPUT "\n";
|
---|
[656] | 91 | }
|
---|
| 92 |
|
---|
| 93 | $tmp = <INPUT>;
|
---|
| 94 | while ($tmp !~ /^$/) {
|
---|
[661] | 95 | if ($dtype eq "deb") {
|
---|
| 96 | print OUTPUT " * $tmp";
|
---|
| 97 | }
|
---|
| 98 | else {
|
---|
| 99 | print OUTPUT "$tmp";
|
---|
| 100 | }
|
---|
[646] | 101 | last if (eof(INPUT));
|
---|
[656] | 102 | $tmp = <INPUT>;
|
---|
[636] | 103 | }
|
---|
[656] | 104 | print OUTPUT "\n";
|
---|
| 105 |
|
---|
| 106 | if ($dtype eq "deb") {
|
---|
| 107 | print OUTPUT " -- Bruno Cornec <bruno\@mondorescue.org> $n2date\n\n";
|
---|
| 108 | print OUTPUT "\n";
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | last if (eof(INPUT));
|
---|
| 112 | last if ($dtype eq "announce");
|
---|
[636] | 113 | }
|
---|
| 114 | close(OUTPUT);
|
---|
| 115 | close(INPUT);
|
---|