X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FCPANPLUS%2FDist%2FGentoo.pm;h=43260ba904ade5fadbe969ff9bfc2ca8f4e2373d;hb=afb044f01dfbb8113137ed467e8c68c6748f1625;hp=945095428f563c4ea6b50ddc4935ea7180c5af32;hpb=012a8ae10e8fc6e70ff1b0f90c470196417c0bf1;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm index 9450954..43260ba 100644 --- a/lib/CPANPLUS/Dist/Gentoo.pm +++ b/lib/CPANPLUS/Dist/Gentoo.pm @@ -19,11 +19,11 @@ CPANPLUS::Dist::Gentoo - CPANPLUS backend generating Gentoo ebuilds. =head1 VERSION -Version 0.01 +Version 0.02_01 =cut -our $VERSION = '0.01'; +our $VERSION = '0.02_01'; =head1 SYNOPSIS @@ -31,13 +31,18 @@ our $VERSION = '0.01'; --dist-opts overlay=/usr/local/portage \ --dist-opts distdir=/usr/portage/distfiles \ --dist-opts manifest=yes \ + --dist-opts keywords=x86 \ Any::Module You::Like =head1 DESCRPITON This module is a CPANPLUS backend that recursively generates Gentoo ebuilds for a given package in the specified overlay (defaults to C), update the manifest, and even emerge it (together with its dependencies) if the user requires it. You need write permissions on the directory where Gentoo fetches its source files (usually C). -The generated ebuilds are placed into the section C. They favour depending on C or C rather than C. +The generated ebuilds are placed into the section C. They favour depending on C or C rather than C. + +=head1 INSTALLATION + +After installing this module, you should append C to your F file. =head1 METHODS @@ -45,6 +50,8 @@ All the methods are inherited from L. Please refer to its =cut +use constant CATEGORY => 'perl-gcpanp'; + sub format_available { for my $prog (qw/emerge ebuild/) { unless (can_run($prog)) { @@ -55,24 +62,24 @@ sub format_available { return 1; } -my $overlay; - sub init { my ($self) = @_; my $stat = $self->status; $stat->mk_accessors(qw/name version dist desc uri src license deps eb_name eb_version eb_dir eb_file distdir fetched_arch - do_manifest/); + keywords do_manifest/); return 1; } my %gentooism = ( - 'Digest' => 'digest-base', - 'Locale-Maketext' => 'locale-maketext', - 'Net-Ping' => 'net-ping', - 'PathTools' => 'File-Spec', - 'PodParser' => 'Pod-Parser', + 'Digest' => 'digest-base', + 'Locale-Maketext' => 'locale-maketext', + 'Net-Ping' => 'net-ping', + 'PathTools' => 'File-Spec', + 'PodParser' => 'Pod-Parser', + 'Set-Scalar' => 'set-scalar', + 'Tie-EncryptedHash' => 'tie-encryptedhash', ); sub prepare { @@ -84,11 +91,19 @@ sub prepare { my %opts = @_; - my $manifest = delete($opts{'manifest'}); - $manifest = 0 if not defined $manifest or $manifest =~ /^\s*no?\s*$/i; + my $keywords = delete $opts{'keywords'}; + $keywords = 'x86' unless defined $keywords; + $keywords = [ split ' ', $keywords ]; + $stat->keywords($keywords); + + my $manifest = delete $opts{'manifest'}; + $manifest = 1 unless defined $manifest; + $manifest = 0 if $manifest =~ /^\s*no?\s*$/i; $stat->do_manifest($manifest); + my $overlay = catdir(delete($opts{'overlay'}) || '/usr/local/portage', - 'perl-cpanp'); + CATEGORY); + $stat->distdir(delete($opts{'distdir'}) || '/usr/portage/distfiles'); if ($stat->do_manifest && !-w $stat->distdir) { error 'distdir isn\'t writable -- aborting'; @@ -134,6 +149,7 @@ sub prepare { my $prereqs = $mod->status->prereqs; my @depends; for my $prereq (sort keys %$prereqs) { + next if $prereq =~ /^perl(?:-|\z)/; my $obj = $int->module_tree($prereq); unless ($obj) { error 'Wrong module object -- aborting'; @@ -174,7 +190,6 @@ sub create { $self->SUPER::create(@_); my $dir = $stat->eb_dir; - print STDERR "@@@ mkdir $dir\n"; unless (-d $dir) { eval { mkpath $dir }; if ($@) { @@ -190,6 +205,7 @@ sub create { $d .= 'SRC_URI="' . $stat->src . "\"\n"; $d .= "SLOT=\"0\"\n"; $d .= 'LICENSE="|| ( ' . join(' ', sort @{$stat->license}) . " )\"\n"; + $d .= 'KEYWORDS="' . join(' ', sort @{$stat->keywords}) . "\"\n"; $d .= 'DEPEND="' . join "\n", 'dev-lang/perl', map { @@ -200,7 +216,7 @@ sub create { $a .= '-' . $_->[1]; } '|| ( ' . join(' ', map "$x$_/$a", - qw/perl-core dev-perl perl-cpanp/) # perl-gcpan ? + qw/perl-core dev-perl perl-gcpan/, CATEGORY) . ' )'; } @{$stat->deps}; $d .= "\"\n"; @@ -221,8 +237,10 @@ sub create { } msg 'Adding Manifest entry for ' . $stat->dist; - unless (scalar run command => [ 'ebuild', $file, 'manifest' ], verbose => 0) { - error 'ebuild manifest failed -- aborting'; + my ($success, $errmsg) = run command => [ 'ebuild', $file, 'manifest' ], + verbose => 0; + unless ($success) { + error "$errmsg -- aborting"; 1 while unlink $file; return 0; } @@ -237,11 +255,13 @@ sub install { my $conf = $self->parent->parent->configure_object; my $sudo = $conf->get_program('sudo'); - my @cmd = 'emerge', '=' . $stat->eb_name . '-' . $stat->eb_version; + my @cmd = ('emerge', '=' . $stat->eb_name . '-' . $stat->eb_version); unshift @cmd, $sudo if $sudo; - unless (run command => \@cmd, verbose => 1) { - error 'emerge failed -- aborting'; + my ($success, $errmsg) = run command => \@cmd, + verbose => 1; + unless ($success) { + error "$errmsg -- aborting"; return 0; } @@ -254,11 +274,13 @@ sub uninstall { my $conf = $self->parent->parent->configure_object; my $sudo = $conf->get_program('sudo'); - my @cmd = 'emerge', '=' . $stat->eb_name . '-' . $stat->eb_version; + my @cmd = ('emerge', '-C', '=' . $stat->eb_name . '-' . $stat->eb_version); unshift @cmd, $sudo if $sudo; - unless (run command => \@cmd, verbose => 1) { - error 'emerge -C failed -- aborting'; + my ($success, $errmsg) = run command => \@cmd, + verbose => 1; + unless ($success) { + error "$errmsg -- aborting"; return 0; } @@ -283,6 +305,8 @@ L, L, L. Vincent Pit, C<< >>, L. +You can contact me by mail or on C (vincent). + =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.