瀏覽代碼

Dpkg::Arch: Add new debarch_is_concerned()

Factor out from Dpkg::Deps::Simple::arch_is_concerned().
Guillem Jover 11 年之前
父節點
當前提交
e5b233d01a
共有 2 個文件被更改,包括 31 次插入23 次删除
  1. 29 0
      scripts/Dpkg/Arch.pm
  2. 2 23
      scripts/Dpkg/Deps.pm

+ 29 - 0
scripts/Dpkg/Arch.pm

@@ -24,6 +24,7 @@ use Exporter qw(import);
 our @EXPORT_OK = qw(get_raw_build_arch get_raw_host_arch
                     get_build_arch get_host_arch get_gcc_host_gnu_type
                     get_valid_arches debarch_eq debarch_is debarch_is_wildcard
+                    debarch_is_concerned
                     debarch_to_cpuattrs
                     debarch_to_gnutriplet gnutriplet_to_debarch
                     debtriplet_to_gnutriplet gnutriplet_to_debtriplet
@@ -439,4 +440,32 @@ sub debarch_is_wildcard($)
     return 0;
 }
 
+sub debarch_is_concerned
+{
+    my ($host_arch, @arches) = @_;
+
+    my $seen_arch = 0;
+    foreach my $arch (@arches) {
+        $arch = lc $arch;
+
+        if ($arch =~ /^!/) {
+            my $not_arch = $arch;
+            $not_arch =~ s/^!//;
+
+            if (debarch_is($host_arch, $not_arch)) {
+                $seen_arch = 0;
+                last;
+            } else {
+                # !arch includes by default all other arches
+                # unless they also appear in a !otherarch
+                $seen_arch = 1;
+            }
+        } elsif (debarch_is($host_arch, $arch)) {
+            $seen_arch = 1;
+            last;
+        }
+    }
+    return $seen_arch;
+}
+
 1;

+ 2 - 23
scripts/Dpkg/Deps.pm

@@ -541,7 +541,7 @@ use warnings;
 
 use Carp;
 
-use Dpkg::Arch qw(debarch_is);
+use Dpkg::Arch qw(debarch_is_concerned);
 use Dpkg::BuildProfiles qw(parse_build_profiles evaluate_restriction_formula);
 use Dpkg::Version;
 use Dpkg::ErrorHandling;
@@ -813,28 +813,7 @@ sub arch_is_concerned {
     return 0 if not defined $self->{package}; # Empty dep
     return 1 if not defined $self->{arches};  # Dep without arch spec
 
-    my $seen_arch = 0;
-    foreach my $arch (@{$self->{arches}}) {
-	$arch=lc($arch);
-
-	if ($arch =~ /^!/) {
-	    my $not_arch = $arch;
-	    $not_arch =~ s/^!//;
-
-	    if (debarch_is($host_arch, $not_arch)) {
-		$seen_arch = 0;
-		last;
-	    } else {
-		# !arch includes by default all other arches
-		# unless they also appear in a !otherarch
-		$seen_arch = 1;
-	    }
-	} elsif (debarch_is($host_arch, $arch)) {
-	    $seen_arch = 1;
-	    last;
-	}
-    }
-    return $seen_arch;
+    return debarch_is_concerned($host_arch, @{$self->{arches}});
 }
 
 sub reduce_arch {