This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=21a6dc6193f69a912567f1d48edc30a6b2993e4a

commit 21a6dc6193f69a912567f1d48edc30a6b2993e4a
Author: Guillem Jover <[email protected]>
AuthorDate: Tue Aug 26 00:40:54 2025 +0200

    Dpkg::Lock: Fallback to use File::FcntlLock::Pure if File::FcntlLock fails
    
    This will allow to use an NFS-safe module even during a perl-api
    transition, as we can fallback to use the pure perl version, which
    is not tied to the perl-api.
    
    While at it reword and simplify the entire comment describing this
    code, to make it way less convoluted.
---
 scripts/Dpkg/Lock.pm | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/scripts/Dpkg/Lock.pm b/scripts/Dpkg/Lock.pm
index ba8ff3646..dfa9bbdf6 100644
--- a/scripts/Dpkg/Lock.pm
+++ b/scripts/Dpkg/Lock.pm
@@ -45,18 +45,24 @@ 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 q{
-        require File::FcntlLock;
-    };
-    if (not $@) {
-        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);
-        return;
+    # We cannot have a strict dependency on libfile-fcntllock-perl because
+    # it contains an XS module, and dpkg-dev indirectly making use of it,
+    # which makes building new perl package that bump the perl ABI
+    # impossible as these packages cannot then be installed alongside.
+    #
+    # But if the XS module fails to load, because we are in the middle of an
+    # upgrade with an ABI breaking perl transition, fall back to try to use
+    # the pure Perl module, if available.
+    foreach my $module (qw(File::FcntlLock File::FcntlLock::Pure)) {
+        eval qq{
+            require $module;
+        };
+        if (not $@) {
+            my $fs = $module->new(l_type => F_WRLCK);
+            $fs->lock($fh, F_SETLKW)
+                or syserr(g_('failed to get a write lock on %s'), $filename);
+            return;
+        }
     }
 
     # On Linux systems the flock() locks get converted to file-range

-- 
Dpkg.Org's dpkg

Reply via email to