Control: tags -1 + patch

The attached patch implements the change I suggested, dropping fcntl
locking in favor of flock, and documenting that change in the changelog
along with the rationale.

- Josh Triplett
>From 0c6eddc8200e7bea482ad65c5870f7977847d26a Mon Sep 17 00:00:00 2001
From: Josh Triplett <j...@joshtriplett.org>
Date: Sun, 5 Jun 2016 14:27:38 -0700
Subject: [PATCH] Always use flock for file locking; drop Recommends on
 libfile-fcntllock-perl

Per the flock(2) manpage, NFS clients going back to Linux 2.6.12
translate flock into an fcntl lock on the entire file.
---
 debian/changelog     |  6 ++++++
 debian/control       |  2 +-
 scripts/Dpkg/File.pm | 18 ++----------------
 3 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index f963c99..1c5c8d8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,11 @@
 dpkg (1.18.8) UNRELEASED; urgency=medium
 
+  [ Josh Triplett ]
+  * Always use flock for file locking, dropping optional use of fcntl locking
+    via File::FcntlLock; drop Recommends on libfile-fcntllock-perl.  Per the
+    flock(2) manpage, NFS clients going back to Linux 2.6.12 translate flock
+    into an fcntl lock on the entire file.  Closes: #677865, #679777
+
   [ Updated programs translations ]
   * German (Sven Joachim).
 
diff --git a/debian/control b/debian/control
index 80bd9a4..3916790 100644
--- a/debian/control
+++ b/debian/control
@@ -70,7 +70,7 @@ Priority: optional
 Architecture: all
 Multi-Arch: foreign
 Depends: dpkg (>= 1.16.3), perl, ${misc:Depends}
-Recommends: libfile-fcntllock-perl, bzip2, xz-utils
+Recommends: bzip2, xz-utils
 Suggests: debian-keyring, gnupg | gnupg2, gpgv | gpgv2,
  gcc | c-compiler, binutils, patch
 Breaks: dpkg-dev (<< 1.15.6), patch (<< 2.7)
diff --git a/scripts/Dpkg/File.pm b/scripts/Dpkg/File.pm
index c6ae326..f50099e 100644
--- a/scripts/Dpkg/File.pm
+++ b/scripts/Dpkg/File.pm
@@ -34,22 +34,8 @@ use Dpkg::ErrorHandling;
 sub file_lock($$) {
     my ($fh, $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)
-            or syserr(g_('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)
-                or syserr(g_('failed to get a write lock on %s'), $filename);
-        }
-    }
+    flock($fh, LOCK_EX)
+        or syserr(g_('failed to get a write lock on %s'), $filename);
 }
 
 sub file_slurp {
-- 
2.8.1

Reply via email to