From 2cafdf6269c73d980f5a6491fccc321e101283d6 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Sun, 8 Nov 2015 23:59:29 +0100 Subject: Extract get_mandatory_arch helper --- emi | 8 +++----- lib/Iurt/Config.pm | 7 +++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/emi b/emi index 0b127e6..ffc4c47 100755 --- a/emi +++ b/emi @@ -29,7 +29,7 @@ use strict; use File::Path qw(make_path); -use Iurt::Config qw(config_usage config_init get_author_email); +use Iurt::Config qw(config_usage config_init get_author_email get_mandatory_arch); use Iurt::Process qw(check_pid); use Iurt::Mail qw(sendmail); use Iurt::File qw(check_upload_tree); @@ -192,8 +192,7 @@ foreach my $prefix (sort keys %pkg_tree) { my $ok = 1; foreach my $section (keys %{$pkg_tree{$prefix}{section}}) { - my $mandatory_arch = find { ref($_) eq 'ARRAY' } $config->{mandatory_arch}, - (ref($config->{mandatory_arch}) eq 'HASH' ? ($config->{mandatory_arch}{$target}, $config->{mandatory_arch}{default}) : ()), []; + my $mandatory_arch = get_mandatory_arch($config, $target); my @wanted_archs = defined($pkg_tree{$prefix}{section}{$section}{arch}{noarch}) ? 'noarch' : @$mandatory_arch; my $path = $pkg_tree{$prefix}{section}{$section}{path}; my %missing; @@ -299,8 +298,7 @@ sub upload_prefix_in_section { my $arch_list = find { ref($_) eq 'ARRAY' } $config->{arch}, (ref($config->{arch}) eq 'HASH' ? ($config->{arch}{$target}, $config->{arch}{default}) : ()); my @arch_list = $arch_list ? @$arch_list : keys %{$config->{bot}}; # If we are here, mandatory arches are done, no need to check them - my $mandatory_arch = find { ref($_) eq 'ARRAY' } $config->{mandatory_arch}, - (ref($config->{mandatory_arch}) eq 'HASH' ? ($config->{mandatory_arch}{$target}, $config->{mandatory_arch}{default}) : ()), []; + my $mandatory_arch = get_mandatory_arch($config, $target); foreach my $arch (difference2(@arch_list, $mandatory_arch)) { next if $pkg_tree{$prefix}{section}{$section}{arch}{$arch}; $all_done = 0; diff --git a/lib/Iurt/Config.pm b/lib/Iurt/Config.pm index a1a1e84..7b07d7a 100644 --- a/lib/Iurt/Config.pm +++ b/lib/Iurt/Config.pm @@ -20,6 +20,7 @@ our @EXPORT = qw( check_arch check_noarch get_package_prefix + get_mandatory_arch %arch_comp ); @@ -180,4 +181,10 @@ sub check_arch { return 1; } +sub get_mandatory_arch { + my ($config, $target) = @_; + find { ref($_) eq 'ARRAY' } $config->{mandatory_arch}, + (ref($config->{mandatory_arch}) eq 'HASH' ? ($config->{mandatory_arch}{$target}, $config->{mandatory_arch}{default}) : ()), []; +} + 1; -- cgit v1.2.1