소스 검색

Dpkg::Deps: Implement support for pkg:arch syntax

Currently, disallow any values for 'arch' besides the special value
'any'. This should only be relaxed once we have a policy for cross-arch
dependencies.

Signed-off-by: Raphaël Hertzog <hertzog@debian.org>
Signed-off-by: Guillem Jover <guillem@debian.org>
Steve Langasek 17 년 전
부모
커밋
33cd7a8304
1개의 변경된 파일22개의 추가작업 그리고 5개의 파일을 삭제
  1. 22 5
      scripts/Dpkg/Deps.pm

+ 22 - 5
scripts/Dpkg/Deps.pm

@@ -473,6 +473,11 @@ undefined when there's no restriction, otherwise it's an
 array ref. It can contain an exclusion list, in that case each
 array ref. It can contain an exclusion list, in that case each
 architecture is prefixed with an exclamation mark.
 architecture is prefixed with an exclamation mark.
 
 
+=item archqual
+
+The arch qualifier of the dependency (can be undef if there's none).
+In the dependency "python:any (>= 2.6)", the arch qualifier is "any".
+
 =back
 =back
 
 
 =head3 Methods
 =head3 Methods
@@ -519,6 +524,7 @@ sub reset {
     $self->{'relation'} = undef;
     $self->{'relation'} = undef;
     $self->{'version'} = undef;
     $self->{'version'} = undef;
     $self->{'arches'} = undef;
     $self->{'arches'} = undef;
+    $self->{'archqual'} = undef;
 }
 }
 
 
 sub parse {
 sub parse {
@@ -533,6 +539,10 @@ sub parse_string {
     return if not $dep =~
     return if not $dep =~
             /^\s*                           # skip leading whitespace
             /^\s*                           # skip leading whitespace
               ([a-zA-Z0-9][a-zA-Z0-9+.-]*)  # package name
               ([a-zA-Z0-9][a-zA-Z0-9+.-]*)  # package name
+              (?:                           # start of optional part
+                :                           # colon for architecture
+                (any)                       # architecture name
+              )?                            # end of optional part
               (?:                           # start of optional part
               (?:                           # start of optional part
                 \s* \(                      # open parenthesis for version part
                 \s* \(                      # open parenthesis for version part
                 \s* (<<|<=|=|>=|>>|<|>)     # relation part
                 \s* (<<|<=|=|>=|>>|<|>)     # relation part
@@ -547,18 +557,22 @@ sub parse_string {
 	      \s*$			    # trailing spaces at end
 	      \s*$			    # trailing spaces at end
             /x;
             /x;
     $self->{package} = $1;
     $self->{package} = $1;
-    $self->{relation} = version_normalize_relation($2) if defined($2);
-    if (defined($3)) {
-        $self->{version} = Dpkg::Version->new($3);
-    }
+    $self->{archqual} = $2 if defined($2);
+    $self->{relation} = version_normalize_relation($3) if defined($3);
     if (defined($4)) {
     if (defined($4)) {
-	$self->{arches} = [ split(/\s+/, $4) ];
+	$self->{version} = Dpkg::Version->new($4);
+    }
+    if (defined($5)) {
+	$self->{arches} = [ split(/\s+/, $5) ];
     }
     }
 }
 }
 
 
 sub output {
 sub output {
     my ($self, $fh) = @_;
     my ($self, $fh) = @_;
     my $res = $self->{package};
     my $res = $self->{package};
+    if (defined($self->{archqual})) {
+	$res .= ":" . $self->{archqual};
+    }
     if (defined($self->{relation})) {
     if (defined($self->{relation})) {
 	$res .= " (" . $self->{relation} . " " . $self->{version} .  ")";
 	$res .= " (" . $self->{relation} . " " . $self->{version} .  ")";
     }
     }
@@ -1212,6 +1226,9 @@ sub check_package {
 
 
 =item * Add new $dep->reset() method that all dependency objects support.
 =item * Add new $dep->reset() method that all dependency objects support.
 
 
+=item * Dpkg::Deps::Simple now recognizes the arch qualifier "any" and
+stores it in the "archqual" property when present.
+
 =back
 =back
 
 
 =cut
 =cut