summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Dpkg/Arch.pm28
-rwxr-xr-xscripts/dpkg-genchanges.pl4
-rwxr-xr-xscripts/dpkg-gencontrol.pl2
-rw-r--r--scripts/t/Dpkg_Arch.t9
4 files changed, 33 insertions, 10 deletions
diff --git a/scripts/Dpkg/Arch.pm b/scripts/Dpkg/Arch.pm
index c3e891526..14709d6cc 100644
--- a/scripts/Dpkg/Arch.pm
+++ b/scripts/Dpkg/Arch.pm
@@ -36,7 +36,7 @@ use strict;
use warnings;
use feature qw(state);
-our $VERSION = '1.02';
+our $VERSION = '1.03';
our @EXPORT_OK = qw(
get_raw_build_arch
get_raw_host_arch
@@ -599,17 +599,25 @@ sub debarch_is_wildcard($)
return 0;
}
-=item $bool = debarch_is_illegal($arch)
+=item $bool = debarch_is_illegal($arch, %options)
Validate an architecture name.
+If the "positive" option is set to a true value, only positive architectures
+will be accepted, otherwise negated architectures are allowed.
+
=cut
sub debarch_is_illegal
{
- my ($arch) = @_;
+ my ($arch, %opts) = @_;
+ my $arch_re = qr/[a-zA-Z0-9][a-zA-Z0-9-]*/;
- return $arch !~ m/^!?[a-zA-Z0-9][a-zA-Z0-9-]*$/;
+ if ($opts{positive}) {
+ return $arch !~ m/^$arch_re$/;
+ } else {
+ return $arch !~ m/^!?$arch_re$/;
+ }
}
=item $bool = debarch_is_concerned($arch, @arches)
@@ -651,15 +659,18 @@ sub debarch_is_concerned
Parse an architecture list.
+If the "positive" option is set to a true value, only positive architectures
+will be accepted, otherwise negated architectures are allowed.
+
=cut
sub debarch_list_parse
{
- my $arch_list = shift;
+ my ($arch_list, %opts) = @_;
my @arch_list = split ' ', $arch_list;
foreach my $arch (@arch_list) {
- if (debarch_is_illegal($arch)) {
+ if (debarch_is_illegal($arch, %opts)) {
error(g_("'%s' is not a legal architecture in list '%s'"),
$arch, $arch_list);
}
@@ -676,6 +687,11 @@ __END__
=head1 CHANGES
+=head2 Version 1.03 (dpkg 1.19.1)
+
+New argument: Accept a "positive" option in debarch_is_illegal() and
+debarch_list_parse().
+
=head2 Version 1.02 (dpkg 1.18.19)
New import tags: ":all", ":getters", ":parsers", ":mappers", ":operators".
diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl
index 84bdc4ba6..4f4b33608 100755
--- a/scripts/dpkg-genchanges.pl
+++ b/scripts/dpkg-genchanges.pl
@@ -369,7 +369,7 @@ foreach my $pkg ($control->get_packages()) {
# No files for this package... warn if it's unexpected
if (((build_has_any(BUILD_ARCH_INDEP) and debarch_eq('all', $a)) or
(build_has_any(BUILD_ARCH_DEP) and
- (any { debarch_is($host_arch, $_) } debarch_list_parse($a)))) and
+ (any { debarch_is($host_arch, $_) } debarch_list_parse($a, positive => 1)))) and
(@restrictions == 0 or
evaluate_restriction_formula(\@restrictions, \@profiles)))
{
@@ -388,7 +388,7 @@ foreach my $pkg ($control->get_packages()) {
$f2pricf{$_} = $v foreach (@f);
} elsif (m/^Architecture$/) {
if (build_has_any(BUILD_ARCH_DEP) and
- (any { debarch_is($host_arch, $_) } debarch_list_parse($v))) {
+ (any { debarch_is($host_arch, $_) } debarch_list_parse($v, positive => 1))) {
$v = $host_arch;
} elsif (!debarch_eq('all', $v)) {
$v = '';
diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl
index 2e656a246..1c92e66dd 100755
--- a/scripts/dpkg-gencontrol.pl
+++ b/scripts/dpkg-gencontrol.pl
@@ -217,7 +217,7 @@ foreach (keys %{$pkg}) {
if (debarch_eq('all', $v)) {
$fields->{$_} = $v;
} else {
- my @archlist = debarch_list_parse($v);
+ my @archlist = debarch_list_parse($v, positive => 1);
if (none { debarch_is($host_arch, $_) } @archlist) {
error(g_("current host architecture '%s' does not " .
diff --git a/scripts/t/Dpkg_Arch.t b/scripts/t/Dpkg_Arch.t
index 525817085..0ef9d1899 100644
--- a/scripts/t/Dpkg_Arch.t
+++ b/scripts/t/Dpkg_Arch.t
@@ -16,7 +16,7 @@
use strict;
use warnings;
-use Test::More tests => 16367;
+use Test::More tests => 16369;
use_ok('Dpkg::Arch', qw(debarch_to_debtuple debarch_to_multiarch
debarch_eq debarch_is debarch_is_wildcard
@@ -148,9 +148,16 @@ my @arch_ref;
@arch_new = debarch_list_parse('amd64 !arm64 linux-i386 !kfreebsd-any');
is_deeply(\@arch_new, \@arch_ref, 'parse valid arch list');
+@arch_ref = qw(amd64 arm64 linux-i386 kfreebsd-any);
+@arch_new = debarch_list_parse('amd64 arm64 linux-i386 kfreebsd-any', positive => 1);
+is_deeply(\@arch_new, \@arch_ref, 'parse valid positive arch list');
+
eval { @arch_new = debarch_list_parse('!amd64!arm64') };
ok($@, 'parse concatenated arches failed');
+eval { @arch_new = debarch_list_parse('amd64 !arm64 !mips', positive => 1) };
+ok($@, 'parse disallowed negated arches failed');
+
is(debarch_to_abiattrs(undef), undef, 'undef ABI attrs');
is_deeply([ debarch_to_abiattrs('amd64') ], [ qw(64 little) ], 'amd64 ABI attrs');