From 407f5566ea831c07d070c98cf83af207288d28c0 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 10 Dec 2018 23:43:32 +0100 Subject: Fix incorrect example for get_updateable_packages() Signed-off-by: Florian Pritz --- lib/App/ArchLinux/PackagerTools.pm | 8 ++++---- lib/App/ArchLinux/PackagerTools/CPAN.pm | 17 ++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/App/ArchLinux/PackagerTools.pm b/lib/App/ArchLinux/PackagerTools.pm index cfc2f01..409cbf7 100644 --- a/lib/App/ArchLinux/PackagerTools.pm +++ b/lib/App/ArchLinux/PackagerTools.pm @@ -66,10 +66,10 @@ method get_distributions_in_repo() { my $distribution_names = ['App::ArchLinux::PackagerTools', 'DBI']; my $packages = $app->get_updateable_packages($distribution_names); - print $packages[0]->{dist_name}; - print $packages[0]->{pkgname}; - print $packages[0]->{repo_version}; - print $packages[0]->{cpan_version}; + print $packages->[0]->{dist_name}; + print $packages->[0]->{pkgname}; + print $packages->[0]->{repo_version}; + print $packages->[0]->{cpan_version}; Accepts a list of package names and returns a list of packages that can be updated. The returned packages contain the name of the distribution, the name diff --git a/lib/App/ArchLinux/PackagerTools/CPAN.pm b/lib/App/ArchLinux/PackagerTools/CPAN.pm index 4faf0d6..50306c9 100644 --- a/lib/App/ArchLinux/PackagerTools/CPAN.pm +++ b/lib/App/ArchLinux/PackagerTools/CPAN.pm @@ -3,9 +3,9 @@ use strictures; use autodie; use CPAN::DistnameInfo; -use CPANPLUS::Backend; use Carp; use Function::Parameters; +use IPC::Run qw(run); use Log::Any qw($log); use Syntax::Keyword::Try; use version; @@ -37,7 +37,6 @@ Returns a new instance. =cut method new($class: $deps = {}) { - $deps->{cpanplus_backend} //= CPANPLUS::Backend->new(); return $class->new_no_defaults($deps); } @@ -133,16 +132,16 @@ Set up the internal index of CPAN distributions =cut method _build_dist_index() { - $log->debug("Updating CPANPLUS index. This may take a while"); - $self->{deps}->{cpanplus_backend}->reload_indices(); # TODO download pacakges list ourselves instead of using cpanplus for it? We may need cpanplus for other features later so keeping it is probably also fine. - - $log->debug("Building index..."); - my $packages_file = "$ENV{HOME}/.cpanplus/02packages.details.txt.gz"; - open my $fh, '-|', 'zcat', $packages_file; + $log->debug("Fetching CPAN modules index"); + my $out; + run [qw(curl -s ), "https://cpan.metacpan.org/modules/02packages.details.txt.gz"], '|', ['zcat'], \$out or die $log->error("Failed to fetch and uncompress CPAN module index: $?")."\n"; + #my $packages_file = "$ENV{HOME}/.cpanplus/02packages.details.txt.gz"; + #open my $out, '-|', 'zcat', $packages_file; my %seen; my $line_number = 0; - while (<$fh>) { + $log->debug("Building index..."); + for (split /\n/, $out) { # skip meta info (first 9 lines) next if $line_number++ < 9; -- cgit v1.2.3-24-g4f1b