try to fix bugs like #355619 & update copyright years in ebuild #1

Merged
merged 9 commits into from Dec 25, 2013
View
12 bin/g-cpan 100644 → 100755
@@ -522,6 +522,7 @@ sub generatePackageInfo
my $s_perl = new DirHandle($pkgdbdir);
my $eb = $ebuild_wanted;
$eb =~ s{::}{/}gxs;
+ $eb = '/' . $eb;
while (defined(my $read = $s_perl->read))
{
if ((-d $pkgdbdir . "/" . $read) and ($read =~ m{^perl}x))
@@ -532,8 +533,8 @@ sub generatePackageInfo
foreach (@data)
{
my $thisfile = (split(/ /, $_))[1];
- $thisfile =~ s{\.([A-Za-z]{1,3})$}{};
- if (($thisfile =~ m{$eb}x) && !defined($passed_to_install{$eb}))
+ $thisfile =~ s{\.([A-Za-z]{1,3})$}{};
+ if ( ($thisfile =~ m{\Q$eb\E$}x) && !defined($passed_to_install{$eb}) )
{
spinner_stop();
print_info("$ebuild_wanted is part of the core perl install");
@@ -710,23 +711,24 @@ sub generatePackageInfo
# Detect the file extension, upstream usually uses .tar.gz, but not always
my $module_a_ext = '';
- foreach my $ext qw(tgz tbz2 tar.bz2 tar.xz tar.Z zip)
- {
+ foreach my $ext (qw( tgz tbz2 tar.bz2 tar.xz tar.Z zip )) {
if ( $gcpan_run->{'cpan'}{lc($original_ebuild)}{'src_uri'} =~ m/\.\Q$ext\E$/ ) {
$module_a_ext = sprintf 'MODULE_A_EXT="%s"', $ext;
}
}
+ my $module_version = $gcpan_run->{cpan}{lc($original_ebuild)}{version};
my $description = $gcpan_run->{'cpan'}{lc($original_ebuild)}{'description'};
print $EBUILD <<"HERE";
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# This ebuild generated by $prog $VERSION
EAPI="2"
MODULE_AUTHOR="$module_author"
+MODULE_VERSION="$module_version"
$module_a_ext
$module_section
inherit perl-module
View
@@ -6,12 +6,11 @@ use warnings;
use File::Spec;
use CPAN;
use File::Path;
-use YAML;
+use YAML ();
use YAML::Node;
use Memoize;
use Cwd qw(getcwd abs_path cwd);
use File::Basename;
-use Shell qw(perl);
memoize('transformCPAN');
memoize('FindDeps');
@@ -196,13 +195,13 @@ sub unpackModule {
chdir($tmp_dir) or die "Unable to enter dir $tmp_dir:$!\n";
# If we have a Makefile.PL, run it to generate Makefile
- if ( -f "Makefile.PL" ) {
- perl("Makefile.PL",'</dev/null');
+ if ( -f 'Makefile.PL' ) {
+ system('perl Makefile.PL </dev/null');
}
# If we have a Build.PL, run it to generate the Build script
- if ( -f "Build.PL" ) {
- perl("Build.PL",'</dev/null');
+ if ( -f 'Build.PL' ) {
+ system('perl Build.PL </dev/null');
}
# Return whence we came
@@ -313,16 +312,9 @@ sub FindDeps {
if ( -f $object ) {
my $abs_path = abs_path($object);
if ( $object eq "META\.yml" ) {
-
# Do YAML parsing if you can
- my $b_n = dirname($abs_path);
- $b_n = basename($b_n);
- open(YAML,"$abs_path");
- my @yaml = <YAML>;
- close(YAML);
- if ( check_yaml(@yaml) ) {
- my $arr = YAML::Load(@yaml);
- foreach my $type qw(configure_requires requires build_requires recommends) {
+ if ( my $arr = yaml_load($abs_path) ) {
+ foreach my $type (qw( configure_requires requires build_requires recommends )) {
if ( my $ar_type = $arr->{$type} ) {
foreach my $module ( keys %{$ar_type} ) {
next if ( $module eq "" );
@@ -384,7 +376,7 @@ sub FindDeps {
my (%p) = ();
my $fh;
- foreach my $type qw(requires configure_requires build_requires) {
+ foreach my $type (qw( requires configure_requires build_requires )) {
if ( $fh = FileHandle->new("<$makefile\0") ) {
local ($/) = "";
while (<$fh>) {
@@ -397,7 +389,7 @@ sub FindDeps {
my @list = split( ',', $p );
foreach my $pa (@list) {
$pa =~ s/\n|\s+|\'//mg;
- if ($pa =~ /=~/) {
+ if ( $pa =~ /=~|\?\(/ ) {
my ($module, $version ) = eval $pa;
next if ((!defined($module)) or
( $module eq "" ) or
@@ -438,10 +430,11 @@ sub FindDeps {
}
-sub check_yaml {
- my @yaml = @_;
- return 1 if YAML::Load(@yaml);
- return 0;
+sub yaml_load {
+ my $filepath = shift;
+ my $yaml = eval { YAML::LoadFile($filepath); };
+ return if $@;
+ return $yaml;
}
sub transformCPAN {
my $self = shift;
View
@@ -47,7 +47,7 @@ sub getEnv {
return($var =~ /^$envvar$/ );
};
-foreach my $file ( "$ENV{HOME}/.gcpanrc", "/etc/make.conf", "/etc/make.globals" ) {
+foreach my $file ( "$ENV{HOME}/.gcpanrc", '/etc/portage/make.conf', '/etc/make.conf', '/etc/make.globals' ) {
if ( -f $file) {
my $importer = Shell::EnvImporter->new(
file => $file,