[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;
|
---|
[651] | 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 = "";
|
---|
[659] | 22 | my $n2date = "";
|
---|
[636] | 23 | my $tmp = "";
|
---|
| 24 | my $ver = "";
|
---|
[774] | 25 | my $ver2 = "";
|
---|
[636] | 26 | my $date = "";
|
---|
[924] | 27 | my $tag = "";
|
---|
[636] | 28 |
|
---|
| 29 | # For date handling
|
---|
| 30 | $ENV{LANG}="C";
|
---|
| 31 |
|
---|
| 32 | die "Syntax : mkchangelog dtype package-name output-file"
|
---|
| 33 | if ((not (defined $dtype)) || ($dtype eq "") ||
|
---|
| 34 | (not (defined $pkg)) || ($pkg eq "") ||
|
---|
| 35 | (not (defined $outfile)) || ($outfile eq ""));
|
---|
| 36 |
|
---|
[651] | 37 | my $TOOLHOME;
|
---|
| 38 | $tmp = dirname($PROGRAM_NAME);
|
---|
| 39 | if ($tmp =~ /^\//) {
|
---|
| 40 | $TOOLHOME = $tmp;
|
---|
| 41 | }
|
---|
| 42 | else {
|
---|
| 43 | $TOOLHOME = "$ENV{PWD}/$tmp";
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | die "TOOLHOME doesn't exist" if (not (defined $TOOLHOME));
|
---|
| 47 |
|
---|
[636] | 48 | if (-f "$TOOLHOME/../$pkg/ChangeLog") {
|
---|
| 49 | $chglog = "$TOOLHOME/../$pkg/ChangeLog";
|
---|
| 50 | }
|
---|
| 51 | else {
|
---|
| 52 | $pkg2 = $pkg;
|
---|
| 53 | $pkg2 =~ s/-..*//;
|
---|
| 54 | if (-f "$TOOLHOME/../$pkg2/ChangeLog") {
|
---|
| 55 | $chglog = "$TOOLHOME/../$pkg2/ChangeLog";
|
---|
| 56 | }
|
---|
| 57 | else {
|
---|
| 58 | die "Unable to find a ChangeLog file for $pkg\n";
|
---|
| 59 | }
|
---|
| 60 | }
|
---|
[930] | 61 | $tmp="$TOOLHOME/../$pkg/TAG";
|
---|
[924] | 62 | if (-f "$tmp") {
|
---|
| 63 | open(TAG,"$tmp") || die "Unable to open $tmp";
|
---|
| 64 | $tag = <TAG>;
|
---|
| 65 | chomp($tag);
|
---|
| 66 | } else {
|
---|
| 67 | die "Unable to find a TAG file for $pkg\n";
|
---|
| 68 | }
|
---|
[781] | 69 | #print "Using $chglog as input ChangeLog file for $pkg\n";
|
---|
[636] | 70 |
|
---|
| 71 | open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
|
---|
| 72 | open(OUTPUT,"> $outfile") || die "Unable to open $outfile (write)";
|
---|
[774] | 73 |
|
---|
[636] | 74 | # Skip first 4 lines
|
---|
| 75 | $tmp = <INPUT>;
|
---|
| 76 | $tmp = <INPUT>;
|
---|
| 77 | $tmp = <INPUT>;
|
---|
[651] | 78 | if ($dtype eq "announce") {
|
---|
| 79 | print OUTPUT $tmp;
|
---|
| 80 | }
|
---|
[636] | 81 | $tmp = <INPUT>;
|
---|
[651] | 82 | if ($dtype eq "announce") {
|
---|
| 83 | print OUTPUT $tmp;
|
---|
| 84 | }
|
---|
[636] | 85 |
|
---|
[781] | 86 | my $first=1;
|
---|
| 87 |
|
---|
[636] | 88 | # Handle each block separated by newline
|
---|
| 89 | while (<INPUT>) {
|
---|
| 90 | ($ver, $date) = split(/ /);
|
---|
[774] | 91 | $ver =~ s/^v//;
|
---|
[636] | 92 | chomp($date);
|
---|
| 93 | $date =~ s/\(([0-9-]+)\)/$1/;
|
---|
[651] | 94 | #print "**$date**\n";
|
---|
[636] | 95 | $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
|
---|
[659] | 96 | $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
|
---|
[651] | 97 | #print "**$ndate**\n";
|
---|
[1271] | 98 | if (($dtype eq "rpm") || ($dtype eq "fc")) {
|
---|
[774] | 99 | if ($ver !~ /-/) {
|
---|
[781] | 100 | if ($first eq 1) {
|
---|
[924] | 101 | $ver2 = "$ver-$tag"."$ENV{suf}";
|
---|
[781] | 102 | $first=0;
|
---|
| 103 | } else {
|
---|
| 104 | $ver2 = "$ver-1"."$ENV{suf}";
|
---|
| 105 | }
|
---|
[774] | 106 | } else {
|
---|
[781] | 107 | $ver2 = "$ver"."$ENV{suf}";
|
---|
[774] | 108 | }
|
---|
| 109 | print OUTPUT "* $ndate Bruno Cornec <bruno\@mondorescue.org> $ver2\n";
|
---|
[651] | 110 | print OUTPUT "- Updated to $ver\n";
|
---|
| 111 | }
|
---|
[659] | 112 | if ($dtype eq "deb") {
|
---|
| 113 | print OUTPUT "$pkg ($ver) unstable; urgency=low\n";
|
---|
| 114 | print OUTPUT "\n";
|
---|
| 115 | }
|
---|
[636] | 116 |
|
---|
[651] | 117 | $tmp = <INPUT>;
|
---|
| 118 | while ($tmp !~ /^$/) {
|
---|
[659] | 119 | if ($dtype eq "deb") {
|
---|
| 120 | print OUTPUT " * $tmp";
|
---|
[1332] | 121 | } elsif ($dtype eq "rpm") {
|
---|
[659] | 122 | print OUTPUT "$tmp";
|
---|
[1332] | 123 | } else {
|
---|
| 124 | print OUTPUT "$tmp";
|
---|
[659] | 125 | }
|
---|
[651] | 126 | last if (eof(INPUT));
|
---|
| 127 | $tmp = <INPUT>;
|
---|
[636] | 128 | }
|
---|
[651] | 129 | print OUTPUT "\n";
|
---|
[659] | 130 |
|
---|
| 131 | if ($dtype eq "deb") {
|
---|
| 132 | print OUTPUT " -- Bruno Cornec <bruno\@mondorescue.org> $n2date\n\n";
|
---|
| 133 | print OUTPUT "\n";
|
---|
| 134 | }
|
---|
| 135 |
|
---|
[651] | 136 | last if (eof(INPUT));
|
---|
| 137 | last if ($dtype eq "announce");
|
---|
[636] | 138 | }
|
---|
| 139 | close(OUTPUT);
|
---|
| 140 | close(INPUT);
|
---|