Package: dpkg-dev
Version: 1.16.3

I had a go today at starting a test rebuild of XS perl modules against
perl 5.16 (which is not yet in experiemental, but is being prepared at
[1]).

Unfortunately, since the perl 5.14 transition, dpkg-dev has gained a
dependency on libfile-fcntllock-perl (as of 1.16.2);
libfile-fcntllock-perl is itself a package requiring rebuilding.

This blocks the rebuilds of perl packages.

The attached patch solves this by using flock() which is built into
perl, rather than an external library. My understanding is that this
should be adequate for the purpose, but please let me know if I've missed
something and there is a strong reason to use File::FcntlLock instead
(if so, maybe we could make the relationship to libfile-fcntllock-perl a
recommends, and abort if we detect that a parallel build is being invoked
without File::FcntlLock being installed).

Thanks,
Dominic.

[1] 
<http://anonscm.debian.org/gitweb/?p=perl/perl.git;a=shortlog;h=refs/heads/debian-5.16>

-- 
Dominic Hargreaves | http://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)
>From d0ce09bc030702abeee924b8db9e25f7c0648ccf Mon Sep 17 00:00:00 2001
From: Dominic Hargreaves <[email protected]>
Date: Mon, 4 Jun 2012 12:11:46 +0100
Subject: [PATCH] Avoid use of File::FcntlLock in dpkg-dev

libfile-fcntllock-perl build-depends on dpkg-dev, so avoid this circular
build-dependency by using flock instead.
---
 debian/control              |    2 +-
 scripts/dpkg-distaddfile.pl |    5 ++---
 scripts/dpkg-gencontrol.pl  |    5 ++---
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/debian/control b/debian/control
index 3184473..18ce7ee 100644
--- a/debian/control
+++ b/debian/control
@@ -51,7 +51,7 @@ Section: utils
 Priority: optional
 Architecture: all
 Multi-Arch: foreign
-Depends: libdpkg-perl (= ${source:Version}), libfile-fcntllock-perl, bzip2, xz-utils,
+Depends: libdpkg-perl (= ${source:Version}), bzip2, xz-utils,
  patch, make, binutils, base-files (>= 5.0.0), ${misc:Depends}
 Recommends: gcc | c-compiler, build-essential, fakeroot, gnupg, gpgv, libalgorithm-merge-perl
 Suggests: debian-keyring
diff --git a/scripts/dpkg-distaddfile.pl b/scripts/dpkg-distaddfile.pl
index 5d80d5e..e14175d 100755
--- a/scripts/dpkg-distaddfile.pl
+++ b/scripts/dpkg-distaddfile.pl
@@ -20,7 +20,7 @@
 use strict;
 use warnings;
 
-use File::FcntlLock;
+use Fcntl qw(:flock);
 use POSIX;
 use POSIX qw(:errno_h :signal_h);
 use Dpkg;
@@ -77,11 +77,10 @@ my ($file, $section, $priority) = @ARGV;
 
 # Obtain a lock on debian/control to avoid simultaneous updates
 # of debian/files when parallel building is in use
-my $fs = File::FcntlLock->new(l_type => F_WRLCK);
 my $lockfh;
 sysopen($lockfh, "debian/control", O_WRONLY) ||
     syserr(_g("cannot write %s"), "debian/control");
-$fs->lock($lockfh, F_SETLKW) ||
+flock($lockfh, LOCK_EX) ||
     syserr(_("failed to get a write lock on %s"), "debian/control");
 
 $fileslistfile="./$fileslistfile" if $fileslistfile =~ m/^\s/;
diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl
index 103a276..37d1231 100755
--- a/scripts/dpkg-gencontrol.pl
+++ b/scripts/dpkg-gencontrol.pl
@@ -22,7 +22,7 @@
 use strict;
 use warnings;
 
-use File::FcntlLock;
+use Fcntl qw(:flock);
 use POSIX;
 use POSIX qw(:errno_h);
 use Dpkg;
@@ -336,11 +336,10 @@ for my $f (keys %remove) {
 
 # Obtain a lock on debian/control to avoid simultaneous updates
 # of debian/files when parallel building is in use
-my $fs = File::FcntlLock->new(l_type => F_WRLCK);
 my $lockfh;
 sysopen($lockfh, "debian/control", O_WRONLY) ||
     syserr(_g("cannot write %s"), "debian/control");
-$fs->lock($lockfh, F_SETLKW) ||
+flock($lockfh, LOCK_EX) ||
     syserr(_("failed to get a write lock on %s"), "debian/control");
 
 $fileslistfile="./$fileslistfile" if $fileslistfile =~ m/^\s/;
-- 
1.7.10

Reply via email to