Browse Source

Dpkg::File: Disable the NFS-unsafe warning on Linux

On Linux systems the flock() locks get converted to file-range locks on
NFS mounts, which makes it safe.

The correct solution here will be to completely get rid of the need to
do any locking, which should also make parallel builds faster.

Addresses: #677865 (on Linux)
Guillem Jover 7 years ago
parent
commit
afa428a417
2 changed files with 7 additions and 1 deletions
  1. 2 0
      debian/changelog
  2. 5 1
      scripts/Dpkg/File.pm

+ 2 - 0
debian/changelog

@@ -13,6 +13,8 @@ dpkg (1.18.20) UNRELEASED; urgency=medium
       from dpkg-shlibdeps.
     - Encode the ELF ABI as a big-endian byte stream, so that decoding for
       output gives meaningful results.
+    - Disable the NFS-unsafe warning on Linux, as using flock() on NFS has
+      been safe for some time now. Addresses: #677865 (on Linux)
 
   [ Updated scripts translations ]
   * German (Helge Kreutzmann).

+ 5 - 1
scripts/Dpkg/File.pm

@@ -43,7 +43,11 @@ sub file_lock($$) {
         use File::FcntlLock;
     };
     if ($@) {
-        warning(g_('File::FcntlLock not available; using flock which is not NFS-safe'));
+        # On Linux systems the flock() locks get converted to file-range
+        # locks on NFS mounts.
+        if ($^O ne 'linux') {
+            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 {