From 8babb87408f6b5f063e3e40dbf32774d56965c09 Mon Sep 17 00:00:00 2001 From: idl0r Date: Sat, 9 May 2009 18:25:52 +0000 Subject: [PATCH] Update category/package when creating the initial ChangeLog, thanks to Serkan Kaba . Cleanup. svn path=/trunk/gentoolkit-dev/; revision=636 --- src/echangelog/echangelog | 51 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/echangelog/echangelog b/src/echangelog/echangelog index 9b71f8b..4315acf 100755 --- a/src/echangelog/echangelog +++ b/src/echangelog/echangelog @@ -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, '; } - 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) = ; - close C; + open(C, '-|', "portageq portdir") or die "portageq returned with an error: $!\n"; + my $portdir = ; + $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 = ; } - 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). -- 2.26.2