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

Dpkg::File: Demote libfile-fcntllock-perl Depends to a Recommends

Fallback to use flock based locking, because libfile-fcntllock-perl
being an XS module makes building a new perl package bumping the perl
ABI impossible, as both packages become uninstallable.

Closes: #675947

Based-on-patch-by: Dominic Hargreaves <dom@earth.li>
Guillem Jover лет назад: 14
Родитель
Сommit
bbdc3ccea0
3 измененных файлов с 24 добавлено и 6 удалено
  1. 5 0
      debian/changelog
  2. 2 2
      debian/control
  3. 17 4
      scripts/Dpkg/File.pm

+ 5 - 0
debian/changelog

@@ -49,6 +49,11 @@ dpkg (1.16.4) UNRELEASED; urgency=low
     Thanks to Carsten Hey <carsten@debian.org>. Closes: #675918
   * Refactor the file locking logic into a new Dpkg::File module, and move
     the libfile-fcntllock-perl dependency from dpkg-dev to libdpkg-perl.
+  * Demote the libfile-fcntllock-perl Depends to a Recommends by falling back
+    to use flock based locking, because it being an XS module makes building
+    a new perl package bumping the perl ABI impossible, as both packages
+    become uninstallable. Thanks to Dominic Hargreaves <dom@earth.li>.
+    Closes: #675947
 
   [ Updated man page translations ]
   * German (Helge Kreutzmann).

+ 2 - 2
debian/control

@@ -68,8 +68,8 @@ Section: perl
 Priority: optional
 Architecture: all
 Multi-Arch: foreign
-Depends: dpkg (>= 1.15.8), perl, libtimedate-perl, libfile-fcntllock-perl, ${misc:Depends}
-Recommends: bzip2, xz-utils
+Depends: dpkg (>= 1.15.8), perl, libtimedate-perl, ${misc:Depends}
+Recommends: libfile-fcntllock-perl, bzip2, xz-utils
 Suggests: debian-keyring, gnupg, gpgv, gcc | c-compiler, binutils, patch
 Breaks: dpkg-dev (<< 1.15.6)
 Replaces: dpkg (<< 1.15.8), dpkg-dev (<< 1.15.6)

+ 17 - 4
scripts/Dpkg/File.pm

@@ -21,7 +21,7 @@ use warnings;
 
 our $VERSION = "0.01";
 
-use File::FcntlLock;
+use Fcntl qw(:flock);
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 
@@ -31,9 +31,22 @@ our @EXPORT = qw(file_lock);
 sub file_lock($$) {
     my ($fh, $filename) = @_;
 
-    my $fs = File::FcntlLock->new(l_type => F_WRLCK);
-    $fs->lock($fh, F_SETLKW) ||
-        syserr(_("failed to get a write lock on %s"), $filename);
+    # A strict dependency on libfile-fcntllock-perl being it an XS module,
+    # and dpkg-dev indirectly making use of it, makes building new perl
+    # package which bump the perl ABI impossible as these packages cannot
+    # be installed alongside.
+    eval 'use File::FcntlLock';
+    if ($@) {
+        warning(_g("File::FcntlLock not available; using flock which is not NFS-safe"));
+        flock($fh, LOCK_EX) ||
+            syserr(_("failed to get a write lock on %s"), $filename);
+    } else {
+        eval q{
+            my $fs = File::FcntlLock->new(l_type => F_WRLCK);
+            $fs->lock($fh, F_SETLKW) ||
+                syserr(_("failed to get a write lock on %s"), $filename);
+        }
+    }
 }
 
 1;