summaryrefslogtreecommitdiffstats
path: root/lib/App/ArchLinux/PackagerTools/Pacman.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App/ArchLinux/PackagerTools/Pacman.pm')
-rw-r--r--lib/App/ArchLinux/PackagerTools/Pacman.pm54
1 files changed, 51 insertions, 3 deletions
diff --git a/lib/App/ArchLinux/PackagerTools/Pacman.pm b/lib/App/ArchLinux/PackagerTools/Pacman.pm
index 765746e..8a26407 100644
--- a/lib/App/ArchLinux/PackagerTools/Pacman.pm
+++ b/lib/App/ArchLinux/PackagerTools/Pacman.pm
@@ -18,8 +18,7 @@ App::ArchLinux::PackagerTools::Pacman - Methods to interact with pacman
=head1 DESCRIPTION
This module allows to query pacman for a list of packages in the repository and
-extract a list of perl distributions that are part of the repository.
-
+extract a list of CPAN distributions that are part of the repository.
=head1 METHODS
@@ -27,7 +26,7 @@ extract a list of perl distributions that are part of the repository.
=head3 new
- App::ArchLinux::PackagerTools::Pacman->new();
+ my $pacman = App::ArchLinux::PackagerTools::Pacman->new();
Returns a new instance.
@@ -55,6 +54,8 @@ method new_no_defaults($class: $deps = {}) {
=head3 get_packages
+ my $packages = $pacman->get_packages();
+
Returns an arrayref of package hashes. Each package hash contains at least the
pkgname and pkgver keys.
@@ -72,12 +73,30 @@ method get_packages() {
return \@packages;
}
+=head3 get_perl_packages
+
+ my $packages = $pacman->get_perl_packages();
+
+Similar to get_packages(), but returns a list filtered to perl packages.
+
+=cut
+
method get_perl_packages() {
my @packages = grep {$_->{pkgname} =~ /^perl-/} $self->get_packages->@*;
$log->debugf("Found %d perl packages", scalar(@packages));
return \@packages;
}
+=head3 get_perl_distributions
+
+ my $dists = $pacman->get_perl_distributions();
+
+Returns a list of CPAN distributions that are in the pacman repo. Returns an
+arrayref of hashrefs that contain dist_name and version keys.
+
+=cut
+
+
method get_perl_distributions() {
my @distributions;
@@ -95,6 +114,14 @@ method get_perl_distributions() {
return \@distributions;
}
+=head3 get_package_version
+
+ my $version = $pacman->get_package_version($pkgname);
+
+Return the version of a package in the pacman package repositories.
+
+=cut
+
method get_package_version($pkgname) {
# TODO do not fork expac for each package here! works for now, but it's sloooow
my $version = `expac -S -1 '%v' -- '$pkgname'`;
@@ -102,13 +129,34 @@ method get_package_version($pkgname) {
return $version;
}
+=head3 get_perl_pkgname
+
+ my $pkgname = $pacman->get_perl_pkgname($dist_name);
+
+Return the pacman package name for a CPAN distribution. In most cases, this
+prefixes the distribution with "perl-" and replaces "::" with "-", but it may
+also return other names if they are mapped differently.
+
+=cut
+
method get_perl_pkgname($dist_name) {
+ # TODO implement mapping
my $pkgname = lc($dist_name);
$pkgname =~ s/::/-/g;
$pkgname = "perl-$pkgname";
return $pkgname;
}
+=head3 get_perl_distribution_version
+
+ my $version = $pacman->get_perl_distribution_version($dist_name);
+
+Return the version of a CPAN distribution's pacman package. This removes
+pacman-specific information from the pacman's package version.
+
+=cut
+
+
method get_perl_distribution_version($dist_name) {
my $pkgname = $self->get_perl_pkgname($dist_name);
my $version = $self->get_package_version($pkgname);