Ver código fonte

Dpkg::Deps::KnownFacts: Add support for versioned Provides

This got missed in commit 5bb02fe80e9f40dcad9703a72f67cf615ff217b5.
Guillem Jover 12 anos atrás
pai
commit
5cc36d8e80
3 arquivos alterados com 47 adições e 6 exclusões
  1. 2 0
      debian/changelog
  2. 11 5
      scripts/Dpkg/Deps.pm
  3. 34 1
      scripts/t/Dpkg_Deps.t

+ 2 - 0
debian/changelog

@@ -28,6 +28,8 @@ dpkg (1.17.14) UNRELEASED; urgency=low
     dselect-curses.h, to not just default on the builtin and override keys
     dselect-curses.h, to not just default on the builtin and override keys
     for dselect key bindings support. Regression introduced in dpkg 1.15.1.
     for dselect key bindings support. Regression introduced in dpkg 1.15.1.
   * Emit a warning when using the obsolete Dpkg::Deps check_package() function.
   * Emit a warning when using the obsolete Dpkg::Deps check_package() function.
+  * Add support for versioned Provides to Dpkg::Deps::KnownFacts, missed in
+    dpkg 1.17.11.
 
 
   [ Raphaël Hertzog ]
   [ Raphaël Hertzog ]
   * Explain better in deb-triggers(5) why interest/activate-noawait should be
   * Explain better in deb-triggers(5) why interest/activate-noawait should be

+ 11 - 5
scripts/Dpkg/Deps.pm

@@ -1360,7 +1360,7 @@ sub add_installed_package {
 
 
 Records that the "$by" package provides the $virtual package. $relation
 Records that the "$by" package provides the $virtual package. $relation
 and $version correspond to the associated relation given in the Provides
 and $version correspond to the associated relation given in the Provides
-field. This might be used in the future for versioned provides.
+field (if present).
 
 
 =cut
 =cut
 
 
@@ -1453,10 +1453,16 @@ sub _evaluate_simple_dep {
 	}
 	}
     }
     }
     foreach my $virtpkg ($self->_find_virtual_packages($pkg)) {
     foreach my $virtpkg ($self->_find_virtual_packages($pkg)) {
-	# XXX: Adapt when versioned provides are allowed
-	next if defined $virtpkg->[1];
-	next if defined $dep->{relation}; # Provides don't satisfy versioned deps
-	return 1;
+	next if defined $virtpkg->[1] and $virtpkg->[1] ne REL_EQ;
+
+	if (defined $dep->{relation}) {
+	    next if not defined $virtpkg->[2];
+	    return 1 if version_compare_relation($virtpkg->[2],
+	                                         $dep->{relation},
+	                                         $dep->{version});
+	} else {
+	    return 1;
+	}
     }
     }
     return if $lackinfos;
     return if $lackinfos;
     return 0;
     return 0;

+ 34 - 1
scripts/t/Dpkg_Deps.t

@@ -16,8 +16,9 @@
 use strict;
 use strict;
 use warnings;
 use warnings;
 
 
-use Test::More tests => 36;
+use Test::More tests => 41;
 use Dpkg::Arch qw(get_host_arch);
 use Dpkg::Arch qw(get_host_arch);
+use Dpkg::Version;
 
 
 use_ok('Dpkg::Deps');
 use_ok('Dpkg::Deps');
 
 
@@ -117,6 +118,8 @@ $facts->add_installed_package('pkg-ma-allowed', '1.3.4-1', 'somearch', 'allowed'
 $facts->add_installed_package('pkg-ma-allowed2', '1.3.4-1', 'somearch', 'allowed');
 $facts->add_installed_package('pkg-ma-allowed2', '1.3.4-1', 'somearch', 'allowed');
 $facts->add_installed_package('pkg-ma-allowed3', '1.3.4-1', get_host_arch(), 'allowed');
 $facts->add_installed_package('pkg-ma-allowed3', '1.3.4-1', get_host_arch(), 'allowed');
 $facts->add_provided_package('myvirtual', undef, undef, 'mypackage');
 $facts->add_provided_package('myvirtual', undef, undef, 'mypackage');
+$facts->add_provided_package('myvirtual2', REL_EQ, '1.0-1', 'mypackage');
+$facts->add_provided_package('myvirtual3', REL_GE, '2.0-1', 'mypackage');
 
 
 my $field_duplicate = 'libc6 (>= 2.3), libc6 (>= 2.6-1), mypackage (>=
 my $field_duplicate = 'libc6 (>= 2.3), libc6 (>= 2.6-1), mypackage (>=
 1.3), myvirtual | something, python (>= 2.5), mypackage2, pkg-ma-foreign,
 1.3), myvirtual | something, python (>= 2.5), mypackage2, pkg-ma-foreign,
@@ -125,6 +128,36 @@ my $dep_dup = deps_parse($field_duplicate);
 $dep_dup->simplify_deps($facts, $dep_opposite);
 $dep_dup->simplify_deps($facts, $dep_opposite);
 is($dep_dup->output(), 'libc6 (>= 2.6-1), mypackage2, pkg-ma-allowed2', 'Simplify deps');
 is($dep_dup->output(), 'libc6 (>= 2.6-1), mypackage2, pkg-ma-allowed2', 'Simplify deps');
 
 
+my $field_virtual = 'myvirtual | other';
+my $dep_virtual = deps_parse($field_virtual);
+$dep_virtual->simplify_deps($facts);
+is($dep_virtual->output(), '',
+   'Simplify unversioned depends with unversioned virtual (satisfied)');
+
+$field_virtual = 'myvirtual (>= 1.0) | other';
+$dep_virtual = deps_parse($field_virtual);
+$dep_virtual->simplify_deps($facts);
+is($dep_virtual->output(), 'myvirtual (>= 1.0) | other',
+   'Simplify versioned depends on unversioned virtual (unsatisfied)');
+
+$field_virtual = 'myvirtual2 (>= 0.0) | other';
+$dep_virtual = deps_parse($field_virtual);
+$dep_virtual->simplify_deps($facts);
+is($dep_virtual->output(), '',
+   'Simplify versioned depends on versioned virtual (satisfied)');
+
+$field_virtual = 'myvirtual2 (>= 2.0) | other';
+$dep_virtual = deps_parse($field_virtual);
+$dep_virtual->simplify_deps($facts);
+is($dep_virtual->output(), 'myvirtual2 (>= 2.0) | other',
+   'Simplify versioned depends on versioned virtual (unsatisfied)');
+
+$field_virtual = 'myvirtual3 (= 2.0-1)';
+$dep_virtual = deps_parse($field_virtual);
+$dep_virtual->simplify_deps($facts);
+is($dep_virtual->output(), 'myvirtual3 (= 2.0-1)',
+   'Simplify versioned depends on GT versioned virtual (unsatisfied/ignored)');
+
 my $field_dup_union = 'libc6 (>> 2.3), libc6 (>= 2.6-1), fake (<< 2.0),
 my $field_dup_union = 'libc6 (>> 2.3), libc6 (>= 2.6-1), fake (<< 2.0),
 fake(>> 3.0), fake (= 2.5), python (<< 2.5), python (= 2.4)';
 fake(>> 3.0), fake (= 2.5), python (<< 2.5), python (= 2.4)';
 my $dep_dup_union = deps_parse($field_dup_union, union => 1);
 my $dep_dup_union = deps_parse($field_dup_union, union => 1);