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