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

Dpkg::Shlibs: Fix add_library_dir to initialize the library paths if needed

We need to initialize the paths, otherwise a subsequent initialization
will discard any paths added with this function.

Regression introduced in commit 96e0d5d129fd963b3ef254580985c54bb717b5af.
Guillem Jover лет назад: 11
Родитель
Сommit
7b52b5fa9d
2 измененных файлов с 16 добавлено и 2 удалено
  1. 3 0
      scripts/Dpkg/Shlibs.pm
  2. 13 2
      scripts/t/Dpkg_Shlibs.t

+ 3 - 0
scripts/Dpkg/Shlibs.pm

@@ -130,6 +130,9 @@ sub setup_library_paths {
 
 sub add_library_dir {
     my $dir = shift;
+
+    setup_library_paths() if not $librarypaths_init;
+
     unshift @librarypaths, $dir;
 }
 

+ 13 - 2
scripts/t/Dpkg_Shlibs.t

@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 122;
+use Test::More tests => 124;
 
 use Cwd;
 use IO::String;
@@ -32,6 +32,17 @@ my %tmp;
 my $srcdir = $ENV{srcdir} || '.';
 my $datadir = $srcdir . '/t/Dpkg_Shlibs';
 
+my @librarypaths;
+
+Dpkg::Shlibs::add_library_dir('/test-b');
+@librarypaths = Dpkg::Shlibs::get_library_paths();
+is($librarypaths[0], '/test-b', 'add_library_dir() does not get lost');
+
+Dpkg::Shlibs::add_library_dir('/test-a');
+@librarypaths = Dpkg::Shlibs::get_library_paths();
+is_deeply([ @librarypaths[0, 1] ] , [ '/test-a', '/test-b' ],
+          'add_library_dir() prepends');
+
 Dpkg::Shlibs::blank_library_paths();
 
 # We want relative paths inside the ld.so.conf fragments to work, and $srcdir
@@ -42,7 +53,7 @@ chdir($srcdir);
 Dpkg::Shlibs::parse_ldso_conf('t/Dpkg_Shlibs/ld.so.conf');
 chdir($cwd);
 
-my @librarypaths = Dpkg::Shlibs::get_library_paths();
+@librarypaths = Dpkg::Shlibs::get_library_paths();
 is_deeply(\@librarypaths,
           [ qw(/nonexistant32 /nonexistant/lib64
                /usr/local/lib /nonexistant/lib128) ], 'parsed library paths');