diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-11-18 23:33:14 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-11-18 23:33:14 +0100 |
commit | e93e80dede905b653e35b8bb4e8f31f0c58719bd (patch) | |
tree | 75bf928f77b16b20722c35cf0418286c2c23269e /lib/App/ArchLinux/PackagerTools.pm | |
parent | fd9ce6c0c8b3d7b8816e80bffee436c50eb7cbb9 (diff) | |
download | App-ArchLinux-PackagerTools-e93e80dede905b653e35b8bb4e8f31f0c58719bd.tar.gz App-ArchLinux-PackagerTools-e93e80dede905b653e35b8bb4e8f31f0c58719bd.tar.xz |
Implement basic check for upgradable packages
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/App/ArchLinux/PackagerTools.pm')
-rw-r--r-- | lib/App/ArchLinux/PackagerTools.pm | 65 |
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__ |