summaryrefslogtreecommitdiffstats
path: root/lib/App/ArchLinux/PackagerTools.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App/ArchLinux/PackagerTools.pm')
-rw-r--r--lib/App/ArchLinux/PackagerTools.pm65
1 files changed, 59 insertions, 6 deletions
diff --git a/lib/App/ArchLinux/PackagerTools.pm b/lib/App/ArchLinux/PackagerTools.pm
index 0e83434..d8cb89d 100644
--- a/lib/App/ArchLinux/PackagerTools.pm
+++ b/lib/App/ArchLinux/PackagerTools.pm
@@ -1,14 +1,15 @@
package App::ArchLinux::PackagerTools;
-use 5.008001;
-use strict;
-use warnings;
+use v5.24;
+use strictures;
our $VERSION = "0.01";
+use autodie;
+use Function::Parameters;
+use Log::Any qw($log);
-
-1;
-__END__
+use App::ArchLinux::PackagerTools::Pacman;
+use App::ArchLinux::PackagerTools::CPAN;
=encoding utf-8
@@ -24,6 +25,55 @@ App::ArchLinux::PackagerTools - It's new $module
App::ArchLinux::PackagerTools is ...
+=head1 METHODS
+
+=head2 Constructors
+
+=head3 new
+
+ App::ArchLinux::PackagerTools->new();
+
+Returns a new instance.
+
+=cut
+method new($class: $deps = {}) {
+ $deps->{cpan} //= App::ArchLinux::PackagerTools::CPAN->new();
+ $deps->{pacman} //= App::ArchLinux::PackagerTools::Pacman->new({$deps->%{cpan}});
+ return $class->new_no_defaults($deps);
+}
+
+method new_no_defaults($class: $deps = {}) {
+ my $self = {};
+ bless $self, $class;
+ $self->{deps} = $deps;
+ return $self;
+}
+
+method get_distributions_in_repo() {
+ return $self->{deps}->{pacman}->get_perl_distributions();
+}
+
+method get_updateable_packages($distribution_names) {
+ my @packages;
+ for my $dist_name ($distribution_names->@*) {
+ my $repo_version = $self->{deps}->{pacman}->get_perl_distribution_version($dist_name);
+ my $dist = $self->{deps}->{cpan}->get_dist($dist_name);
+ if ($self->{deps}->{cpan}->is_newer_version_available($dist_name, $repo_version)) {
+ $log->infof('New version available for dist \'%s\': %s', $dist_name, $dist->{version});
+ push @packages, {
+ dist_name => $dist_name,
+ repo_version => $repo_version,
+ cpan_version => $dist->{version},
+ pkgname => $self->{deps}->{pacman}->get_perl_pkgname($dist_name),
+ };
+ } else {
+ $log->debugf('Dist \'%s\' is already up to date with version %s', $dist_name, $dist->{version});
+ }
+
+ }
+ return \@packages;
+}
+
=head1 LICENSE
Copyright (C) 2018 Florian Pritz E<lt>bluewind@xinu.atE<gt>
@@ -48,3 +98,6 @@ Florian Pritz E<lt>bluewind@xinu.atE<gt>
=cut
+1;
+
+__END__