Просмотр исходного кода

dpkg-shlibdeps: initialize dependencies differently

* scripts/Dpkg/Shlibs/SymbolFile.pm (get_smallest_version): New
function to retrieve the smallest "minver" of all symbols of a
given library.
* scripts/dpkg-shlibdeps.pl: Do not initialize dependencies of
libraries with symbols files as unversioned, instead use the
smallest minimal version returned by the function above. This
is required because the library might not have always been
available in the package and the unversioned dependency thus
doesn't ensure his presence.

* scripts/t/800_Dpkg_IPC.t: Remove temporary files used by the
tests.
Raphael Hertzog лет назад: 18
Родитель
Сommit
c87dde454c
5 измененных файлов с 44 добавлено и 3 удалено
  1. 15 0
      ChangeLog
  2. 5 0
      debian/changelog
  3. 14 0
      scripts/Dpkg/Shlibs/SymbolFile.pm
  4. 6 2
      scripts/dpkg-shlibdeps.pl
  5. 4 1
      scripts/t/800_Dpkg_IPC.t

+ 15 - 0
ChangeLog

@@ -1,3 +1,18 @@
+2008-04-04  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/Dpkg/Shlibs/SymbolFile.pm (get_smallest_version): New
+	function to retrieve the smallest "minver" of all symbols of a
+	given library.
+	* scripts/dpkg-shlibdeps.pl: Do not initialize dependencies of
+	libraries with symbols files as unversioned, instead use the
+	smallest minimal version returned by the function above. This
+	is required because the library might not have always been
+	available in the package and the unversioned dependency thus
+	doesn't ensure his presence.
+
+	* scripts/t/800_Dpkg_IPC.t: Remove temporary files used by the
+	tests.
+
 2008-04-02  Sven Joachim  <svenjoac@gmx.de>
 
 	* lib/triglib.c (trk_unknown_interest_change): Fix typo.

+ 5 - 0
debian/changelog

@@ -19,6 +19,11 @@ dpkg (1.14.18) UNRELEASED; urgency=low
   * Ensure the Files field is last in *.dsc and *.changes. This is a
     work-around for some braindead dsc parsers (dupload and sbuild for
     instance, see #473518 and #470440).
+  * Initialize dependencies for libraries having symbols files with the
+    smallest minimal version listed in the symbols file instead of using
+    an unversioned dependency. It's the only way to ensure the library
+    presence if it wasn't available in all versions of the package that ever
+    existed. Closes: #474079
 
   [ Updated dselect translations ]
   * German. (Sven Joachim).

+ 14 - 0
scripts/Dpkg/Shlibs/SymbolFile.pm

@@ -304,6 +304,20 @@ sub get_dependency {
     return $self->{objects}{$soname}{deps}[$dep_id];
 }
 
+sub get_smallest_version {
+    my ($self, $soname, $dep_id) = @_;
+    $dep_id = 0 unless defined($dep_id);
+    my $minver;
+    foreach my $sym (values %{$self->{objects}{$soname}{syms}}) {
+        next if $dep_id != $sym->{dep_id};
+        $minver ||= $sym->{minver};
+        if (vercmp($minver, $sym->{minver}) > 0) {
+            $minver = $sym->{minver};
+        }
+    }
+    return $minver;
+}
+
 sub get_dependencies {
     my ($self, $soname) = @_;
     return @{$self->{objects}{$soname}{deps}};

+ 6 - 2
scripts/dpkg-shlibdeps.pl

@@ -201,11 +201,15 @@ foreach my $file (keys %exec) {
 		}
 	    }
 	    if (defined($dpkg_symfile) && $symfile->has_object($soname)) {
-		# Initialize dependencies as an unversioned dependency
+		# Initialize dependencies with the smallest minimal version
+                # of all symbols (unversioned dependency is not ok as the
+                # library might not have always been available in the
+                # package and we really need it)
 		my $dep = $symfile->get_dependency($soname);
+		my $minver = $symfile->get_smallest_version($soname) || '';
 		foreach my $subdep (split /\s*,\s*/, $dep) {
 		    if (not exists $dependencies{$cur_field}{$subdep}) {
-			$dependencies{$cur_field}{$subdep} = '';
+			$dependencies{$cur_field}{$subdep} = $minver;
 		    }
 		}
 	    } else {

+ 4 - 1
scripts/t/800_Dpkg_IPC.t

@@ -17,7 +17,7 @@ my $string = "foo\nbar\n";
 my $string2;
 
 open TMP, '>', $tmp_name;
-print TMP $string;;
+print TMP $string;
 close TMP;
 
 my $pid = fork_and_exec(exec => "cat",
@@ -54,3 +54,6 @@ $string2 = <TMP>;
 close TMP;
 
 is($string2, $string, "{from,to}_file");
+
+unlink($tmp_name);
+unlink($tmp2_name);