aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@canonical.com>2011-10-26 15:07:28 +0100
committerJohn Rigby <john.rigby@linaro.org>2011-11-16 14:51:26 -0700
commit13c3c4e3df4683ee37f5cd98c1ac2ca7d149d745 (patch)
treeabcacc96beacbca771238b41227eaedab569826d
parent0623f95160acc2fa3c05063cae155734fc2bed1f (diff)
UBUNTU: debian: add locking to protect debian/files from parallel update
When building with high parallelism we may overlap calls to dh_gencontrol and/or the .ddeb removal code from the debian/files list. If these happen in parallel files may be lost or updates fail leading to build failures or incomplete packing lists. Add primative locking to each of these scenarios using the flock command, utilising a lock file in the debian directory. Signed-off-by: Andy Whitcroft <apw@canonical.com>
-rw-r--r--debian.master/control.stub.in2
-rw-r--r--debian/rules.d/0-common-vars.mk5
-rw-r--r--debian/rules.d/2-binary-arch.mk29
-rw-r--r--debian/rules.d/3-binary-indep.mk4
-rw-r--r--debian/rules.d/5-udebs.mk2
5 files changed, 25 insertions, 17 deletions
diff --git a/debian.master/control.stub.in b/debian.master/control.stub.in
index ad433e22493..84dd89b05f9 100644
--- a/debian.master/control.stub.in
+++ b/debian.master/control.stub.in
@@ -3,7 +3,7 @@ Section: devel
Priority: optional
Maintainer: Ubuntu Kernel Team <kernel-team@lists.ubuntu.com>
Standards-Version: 3.8.4.0
-Build-Depends: debhelper (>= 5), cpio, module-init-tools, kernel-wedge (>= 2.24ubuntu1), makedumpfile [amd64 i386], device-tree-compiler [powerpc], libelf-dev, binutils-dev, rsync, libdw-dev, dpkg (>= 1.16.0~ubuntu4)
+Build-Depends: debhelper (>= 5), cpio, module-init-tools, kernel-wedge (>= 2.24ubuntu1), makedumpfile [amd64 i386], device-tree-compiler [powerpc], libelf-dev, binutils-dev, rsync, libdw-dev, dpkg (>= 1.16.0~ubuntu4), util-linux
Build-Depends-Indep: xmlto, docbook-utils, ghostscript, transfig, bzip2, sharutils, asciidoc
Build-Conflicts: findutils (= 4.4.1-1ubuntu1)
Vcs-Git: http://kernel.ubuntu.com/git-repos/ubuntu/ubuntu-precise.git
diff --git a/debian/rules.d/0-common-vars.mk b/debian/rules.d/0-common-vars.mk
index 8915c40826e..9022d53fad2 100644
--- a/debian/rules.d/0-common-vars.mk
+++ b/debian/rules.d/0-common-vars.mk
@@ -220,3 +220,8 @@ ifneq ($(LOCAL_ENV_CC),)
kmake += CC=$(LOCAL_ENV_CC) DISTCC_HOSTS=$(LOCAL_ENV_DISTCC_HOSTS)
endif
+# Locking is required in parallel builds to prevent loss of contents
+# of the debian/files.
+lockme_file = $(CURDIR)/debian/.LOCK
+lockme_cmd = flock -w 60
+lockme = $(lockme_cmd) $(lockme_file)
diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index 7a42734e6c7..dec5adcf84f 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -268,7 +268,7 @@ endif
dh_compress -plinux-libc-dev
dh_fixperms -plinux-libc-dev
dh_installdeb -plinux-libc-dev
- dh_gencontrol -plinux-libc-dev -- $(libc_dev_version)
+ $(lockme) dh_gencontrol -plinux-libc-dev -- $(libc_dev_version)
dh_md5sums -plinux-libc-dev
dh_builddeb -plinux-libc-dev
endif
@@ -289,7 +289,7 @@ binary-%: install-%
dh_fixperms -p$(pkgimg) -X/boot/
dh_installdeb -p$(pkgimg)
dh_shlibdeps -p$(pkgimg)
- dh_gencontrol -p$(pkgimg)
+ $(lockme) dh_gencontrol -p$(pkgimg)
dh_md5sums -p$(pkgimg)
dh_builddeb -p$(pkgimg) -- -Zbzip2 -z9
@@ -300,7 +300,7 @@ binary-%: install-%
dh_fixperms -p$(pkgimg_ex) -X/boot/; \
dh_installdeb -p$(pkgimg_ex); \
dh_shlibdeps -p$(pkgimg_ex); \
- dh_gencontrol -p$(pkgimg_ex); \
+ $(lockme) dh_gencontrol -p$(pkgimg_ex); \
dh_md5sums -p$(pkgimg_ex); \
dh_builddeb -p$(pkgimg_ex) -- -Zbzip2 -z9; \
fi
@@ -311,7 +311,7 @@ binary-%: install-%
dh_fixperms -p$(pkghdr)
dh_shlibdeps -p$(pkghdr)
dh_installdeb -p$(pkghdr)
- dh_gencontrol -p$(pkghdr)
+ $(lockme) dh_gencontrol -p$(pkghdr)
dh_md5sums -p$(pkghdr)
dh_builddeb -p$(pkghdr)
@@ -324,7 +324,7 @@ ifneq ($(skipsub),true)
dh_fixperms -p$$pkg -X/boot/; \
dh_shlibdeps -p$$pkg; \
dh_installdeb -p$$pkg; \
- dh_gencontrol -p$$pkg; \
+ $(lockme) dh_gencontrol -p$$pkg; \
dh_md5sums -p$$pkg; \
dh_builddeb -p$$pkg; \
done
@@ -336,7 +336,7 @@ ifneq ($(skipdbg),true)
dh_compress -p$(dbgpkg)
dh_fixperms -p$(dbgpkg)
dh_installdeb -p$(dbgpkg)
- dh_gencontrol -p$(dbgpkg)
+ $(lockme) dh_gencontrol -p$(dbgpkg)
dh_md5sums -p$(dbgpkg)
dh_builddeb -p$(dbgpkg)
@@ -349,12 +349,15 @@ ifneq ($(skipdbg),true)
mv ../$(dbgpkg)_$(release)-$(revision)_$(arch).deb \
../$(dbgpkg)_$(release)-$(revision)_$(arch).ddeb
set -e; \
- if grep -qs '^Build-Debug-Symbols: yes$$' /CurrentlyBuilding; then \
- sed -i '/^$(dbgpkg)_/s/\.deb /.ddeb /' debian/files; \
- else \
- grep -v '^$(dbgpkg)_.*$$' debian/files > debian/files.new; \
- mv debian/files.new debian/files; \
- fi
+ ( \
+ $(lockme_cmd) 9 || exit 1; \
+ if grep -qs '^Build-Debug-Symbols: yes$$' /CurrentlyBuilding; then \
+ sed -i '/^$(dbgpkg)_/s/\.deb /.ddeb /' debian/files; \
+ else \
+ grep -v '^$(dbgpkg)_.*$$' debian/files > debian/files.new; \
+ mv debian/files.new debian/files; \
+ fi; \
+ ) 9>$(lockme_file)
# Now, the package wont get into the archive, but it will get put
# into the debug system.
endif
@@ -415,7 +418,7 @@ ifeq ($(do_tools),true)
dh_fixperms -p$(toolspkg)
dh_shlibdeps -p$(toolspkg)
dh_installdeb -p$(toolspkg)
- dh_gencontrol -p$(toolspkg)
+ $(lockme) dh_gencontrol -p$(toolspkg)
dh_md5sums -p$(toolspkg)
dh_builddeb -p$(toolspkg)
endif
diff --git a/debian/rules.d/3-binary-indep.mk b/debian/rules.d/3-binary-indep.mk
index 55c7904b543..462d7219cd2 100644
--- a/debian/rules.d/3-binary-indep.mk
+++ b/debian/rules.d/3-binary-indep.mk
@@ -125,7 +125,7 @@ binary-headers: install-headers
dh_compress -p$(indep_hdrpkg)
dh_fixperms -p$(indep_hdrpkg)
dh_installdeb -p$(indep_hdrpkg)
- dh_gencontrol -p$(indep_hdrpkg)
+ $(lockme) dh_gencontrol -p$(indep_hdrpkg)
dh_md5sums -p$(indep_hdrpkg)
dh_builddeb -p$(indep_hdrpkg)
@@ -138,6 +138,6 @@ binary-indep: install-indep
dh_compress -i
dh_fixperms -i
dh_installdeb -i
- dh_gencontrol -i
+ $(lockme) dh_gencontrol -i
dh_md5sums -i
dh_builddeb -i
diff --git a/debian/rules.d/5-udebs.mk b/debian/rules.d/5-udebs.mk
index 63583deb5b0..2cb81fdd6ef 100644
--- a/debian/rules.d/5-udebs.mk
+++ b/debian/rules.d/5-udebs.mk
@@ -33,6 +33,6 @@ do-binary-udebs: debian/control
[ -z "$dilist" ] || \
for i in $$dilist; do \
dh_fixperms -p$$i; \
- dh_gencontrol -p$$i; \
+ $(lockme) dh_gencontrol -p$$i; \
dh_builddeb -p$$i; \
done