Update category/package when creating the initial ChangeLog, thanks to Serkan Kaba...
authoridl0r <idl0r@gentoo.org>
Sat, 9 May 2009 18:25:52 +0000 (18:25 -0000)
committeridl0r <idl0r@gentoo.org>
Sat, 9 May 2009 18:25:52 +0000 (18:25 -0000)
svn path=/trunk/gentoolkit-dev/; revision=636

src/echangelog/echangelog

index 9b71f8b166511dcf018f1fc923303f2697da3b75..4315acf4d11b46e7e96642440c29a571c8b7e98c 100755 (executable)
@@ -11,6 +11,7 @@
 use strict;
 use POSIX qw(strftime getcwd setlocale);
 use File::Find;
+use File::Basename;
 use Getopt::Long;
 
 # Fix bug 21022 by restricting to C locale
@@ -153,6 +154,18 @@ sub changelog_info(%) {
        close(INFO);
 }
 
+sub update_cat_pn {
+       my $t = shift;
+       my $cwd = getcwd();
+
+       my $category = basename(dirname($cwd));
+       my $package_name = basename($cwd);
+
+       $t =~ s/^(# ChangeLog for).*/$1 $category\/$package_name/;
+
+       return $t;
+}
+
 GetOptions(
        'help' => \$opt_help,
        'strict' => \$opt_strict,
@@ -193,22 +206,27 @@ if ( -d "CVS" ) {
 
 # Read the current ChangeLog
 if (-f 'ChangeLog') {
-       open I, '<ChangeLog' or die "Can't open ChangeLog for input: $!\n";
+       open(I, '<', 'ChangeLog') or die "Can't open ChangeLog for input: $!\n";
        { local $/ = undef; $text = <I>; }
-       close I;
+       close(I);
 } else {
        # No ChangeLog here, maybe we should make one...
        if (<*.ebuild>) {
-               open C, "portageq envvar PORTDIR |" or die "Can't find PORTDIR";
-               my ($new) = <C>;
-               close C;
+               open(C, '-|', "portageq portdir") or die "portageq returned with an error: $!\n";
+               my $portdir = <C>;
+               $portdir =~ s/\s+$//;
+               close(C);
 
-               $new =~ s/\s+$//;
-               open I, "< $new/skel.ChangeLog"
-                       or die "Can't open $new/skel.ChangeLog for input: $!\n";
+               die "Can't find PORTDIR\n" if (length $portdir == 0);
+
+               open(I, '<', "$portdir/skel.ChangeLog")
+                       or die "Can't open $portdir/skel.ChangeLog for input: $!\n";
                { local $/ = undef; $text = <I>; }
-               close I;
-               $text =~ s/^\*.*//ms;   # don't need the fake entry
+               close(I);
+
+               $text =~ s/^\*.*//ms; # don't need the fake entry
+
+               $text = update_cat_pn($text);
        } else {
                die "This should be run in a directory with ebuilds...\n";
        }
@@ -424,7 +442,6 @@ sub mypush(\@@) {
 
 # Forget ebuilds that only have changed copyrights, unless that's all
 # the changed files we have
-
 @ebuilds = grep /\.ebuild$/, @files;
 @files = grep !/\.ebuild$/, @files;
 
@@ -641,18 +658,6 @@ if (@new_versions) {
                        or die "Failed to insert new entry (3)\n";
 }
 
-sub update_cat_pn {
-       my ($t) = @_;
-       my ($cwd) = getcwd();
-
-       $cwd =~ m|.*/(\w+-\w+\|virtual)/([^/]+)|
-               or die "Can't figure out category/package.. sorry!\n";
-       my ($category, $package_name) = ($1, $2);
-       $t =~ s/^(# ChangeLog for).*/$1 $category\/$package_name/;
-
-       return $t;
-}
-
 # New packages and/or ones that have moved around often have stale data here.
 # But only do that in places where ebuilds are around (as echangelog can be
 # used in profiles/ and such places).