diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-12-10 23:43:32 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-12-10 23:43:32 +0100 |
commit | 407f5566ea831c07d070c98cf83af207288d28c0 (patch) | |
tree | 5461935a91fc319e81116915a1d56dfeadc51d2b | |
parent | d02cec97b983985f4f48e607e807b46ab2ae93a6 (diff) | |
download | App-ArchLinux-PackagerTools-407f5566ea831c07d070c98cf83af207288d28c0.tar.gz App-ArchLinux-PackagerTools-407f5566ea831c07d070c98cf83af207288d28c0.tar.xz |
Fix incorrect example for get_updateable_packages()
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | cpanfile | 2 | ||||
-rw-r--r-- | lib/App/ArchLinux/PackagerTools.pm | 8 | ||||
-rw-r--r-- | lib/App/ArchLinux/PackagerTools/CPAN.pm | 17 |
3 files changed, 13 insertions, 14 deletions
@@ -1,6 +1,6 @@ requires 'CPAN::DistnameInfo'; -requires 'CPANPLUS::Backend'; requires 'Function::Parameters'; +requires 'IPC::Run'; requires 'Log::Any'; requires 'Log::Any::Adapter'; requires 'Log::Log4perl'; 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; |