From 58860d34d6d90e4baafde5253b5c8696024b3da4 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 18 Dec 2018 00:48:32 +0100 Subject: WIP Add maintainer filtering Signed-off-by: Florian Pritz --- README.md | 6 ++++++ cpanfile | 3 ++- lib/App/ArchLinux/PackagerTools.pm | 14 ++++++++++++++ script/perlpkg.pl | 3 +++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03523a9..570ff7a 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,12 @@ Accepts a package name and returns the maintainers of the package. Accepts a list of packages (hashes with the pkgname key) and returns a list with the maintainer key added to each package. +### filter\_by\_maintainer + + my $filtered_packages = $app->filter_by_maintainer($packages); + +Filter a list of packages to the maintainers whitelisted in the config file. + # LICENSE Copyright (C) 2018 Florian Pritz diff --git a/cpanfile b/cpanfile index 2896443..0070edb 100644 --- a/cpanfile +++ b/cpanfile @@ -3,16 +3,17 @@ requires 'CPAN::DistnameInfo'; requires 'Function::Parameters'; requires 'Hash::Merge'; requires 'IPC::Run'; +requires 'List::Util'; requires 'Log::Any'; requires 'Log::Any::Adapter'; requires 'Log::Log4perl'; requires 'Path::Tiny'; requires 'Syntax::Keyword::Try'; requires 'TOML'; +requires 'WWW::JSON'; requires 'autodie'; requires 'perl', 'v5.24.0'; requires 'strictures'; -requires 'WWW::JSON'; requires 'version'; on configure => sub { diff --git a/lib/App/ArchLinux/PackagerTools.pm b/lib/App/ArchLinux/PackagerTools.pm index 720f056..fa246e6 100644 --- a/lib/App/ArchLinux/PackagerTools.pm +++ b/lib/App/ArchLinux/PackagerTools.pm @@ -7,6 +7,7 @@ our $VERSION = "0.01"; use autodie; use Function::Parameters; use Log::Any qw($log); +use List::Util 1.33 qw(any); use App::ArchLinux::PackagerTools::Pacman; use App::ArchLinux::PackagerTools::CPAN; @@ -144,6 +145,19 @@ method add_maintainers($packages) { return \@packages_with_maintainer; } +=head3 filter_by_maintainer + + my $filtered_packages = $app->filter_by_maintainer($packages); + +Filter a list of packages to the maintainers whitelisted in the config file. + +=cut + +method filter_by_maintainer($packages) { + # TODO make configurable + return [grep { any {$_->{name} eq 'bluewind'} $_->{maintainers}->@*} $packages->@*]; +} + =head1 LICENSE Copyright (C) 2018 Florian Pritz Ebluewind@xinu.atE diff --git a/script/perlpkg.pl b/script/perlpkg.pl index e6cac27..03bdb92 100755 --- a/script/perlpkg.pl +++ b/script/perlpkg.pl @@ -55,6 +55,9 @@ my $dists = $app->get_distributions_in_repo(); my $dist_names = [map {$_->{dist_name}} $dists->@*]; my $updateable = $app->get_updateable_packages($dist_names); my $pkgs = $app->add_maintainers($updateable); +my $filtered_pkgs = $app->filter_by_maintainer($pkgs); + +print Dumper($filtered_pkgs); # TODO generate new pacakge pkgbuild # TODO build -- cgit v1.2.3-24-g4f1b