public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Cedric Hombourger <Cedric_Hombourger@mentor.com>
To: <isar-users@googlegroups.com>
Cc: Cedric Hombourger <Cedric_Hombourger@mentor.com>
Subject: [PATCH v3 3/3] dpkg+linux: use Isar's lock via do_prepare[lockfiles] instead of flock
Date: Sun, 26 Aug 2018 08:21:28 +0200	[thread overview]
Message-ID: <1535264488-128-3-git-send-email-Cedric_Hombourger@mentor.com> (raw)
In-Reply-To: <1535264488-128-1-git-send-email-Cedric_Hombourger@mentor.com>

reprepro and apt operations may not run in parallel since this could result
in the apt database being updated (by reprepro) while it is being read (by
apt-get update). reprepro calls were already serialized with Isar's lock (via
do_deploy_deb[lockfiles]). Use the same lock for do_prepare in the dpkg and
linux-custom packaging code. This allows us to drop the /dpkg.lock flock and
use bitbake's locking scheme instead.

Signed-off-by: Cedric Hombourger <Cedric_Hombourger@mentor.com>
---
 meta/classes/dpkg.bbclass                       |  3 +++
 meta/recipes-devtools/buildchroot/files/deps.sh | 29 ++++++++++---------------
 meta/recipes-kernel/linux/linux-custom.inc      |  6 +++--
 3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
index e8bd6ba..2e53c1b 100644
--- a/meta/classes/dpkg.bbclass
+++ b/meta/classes/dpkg.bbclass
@@ -9,6 +9,9 @@ dpkg_prepare() {
     sudo -E chroot ${BUILDCHROOT_DIR} /isar/deps.sh ${PP}/${PPS} ${DISTRO_ARCH}
 }
 
+# apt and reprepro may not run in parallel, acquire the Isar lock
+do_prepare[lockfiles] += "${DEPLOY_DIR_APT}/isar.lock"
+
 # Build package from sources using build script
 dpkg_runbuild() {
     E="${@ bb.utils.export_proxies(d)}"
diff --git a/meta/recipes-devtools/buildchroot/files/deps.sh b/meta/recipes-devtools/buildchroot/files/deps.sh
index 854a4d5..4bd604f 100644
--- a/meta/recipes-devtools/buildchroot/files/deps.sh
+++ b/meta/recipes-devtools/buildchroot/files/deps.sh
@@ -12,21 +12,16 @@ source /isar/common.sh
 #   2) we add -y to go non-interactive
 install_cmd="apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y"
 
-(
-    # Lock-protected because apt and dpkg do not wait in case of contention
-    flock 42 || exit 1
+# Make sure that we have latest isar-apt content.
+# Options meaning:
+#   Dir::Etc::sourcelist - specifies which source to be used
+#   Dir::Etc::sourceparts - disables looking for the other sources
+#   APT::Get::List-Cleanup - do not erase obsolete packages list for
+#                            upstream in '/var/lib/apt/lists'
+apt-get update \
+    -o Dir::Etc::sourcelist="sources.list.d/isar-apt.list" \
+    -o Dir::Etc::sourceparts="-" \
+    -o APT::Get::List-Cleanup="0"
 
-    # Make sure that we have latest isar-apt content.
-    # Options meaning:
-    #   Dir::Etc::sourcelist - specifies which source to be used
-    #   Dir::Etc::sourceparts - disables looking for the other sources
-    #   APT::Get::List-Cleanup - do not erase obsolete packages list for
-    #                            upstream in '/var/lib/apt/lists'
-    apt-get update \
-        -o Dir::Etc::sourcelist="sources.list.d/isar-apt.list" \
-        -o Dir::Etc::sourceparts="-" \
-        -o APT::Get::List-Cleanup="0"
-
-    # Install all build deps
-    mk-build-deps $set_arch -t "${install_cmd}" -i -r debian/control
-) 42>/dpkg.lock
+# Install all build deps
+mk-build-deps $set_arch -t "${install_cmd}" -i -r debian/control
diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index 26c6ad8..8438143 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -29,13 +29,15 @@ KERNEL_DEBIAN_DEPENDS ?= "initramfs-tools | linux-initramfs-tool, kmod, linux-ba
 KERNEL_HEADERS_DEBIAN_DEPENDS ?= "libc6, libssl1.1"
 
 dpkg_prepare() {
-	# Lock-protected because apt and dpkg do not wait in case of contention
 	sudo -E chroot ${BUILDCHROOT_DIR} \
-		flock /dpkg.lock apt-get install \
+		apt-get install \
 			-y -o Debug::pkgProblemResolver=yes \
 			--no-install-recommends ${KBUILD_DEPENDS}
 }
 
+# apt and reprepro may not run in parallel, acquire the Isar lock
+do_prepare[lockfiles] += "${DEPLOY_DIR_APT}/isar.lock"
+
 dpkg_runbuild() {
 	# Install package builder script
 	sudo install -m 755 ${WORKDIR}/build-kernel.sh ${BUILDCHROOT_DIR}
-- 
2.11.0


  parent reply	other threads:[~2018-08-26  6:21 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-22 11:34 [PATCH 0/1] acquire database lock when calling reprepro Cedric Hombourger
2018-08-22 11:34 ` [PATCH 1/1] dpkg: acquire " Cedric Hombourger
2018-08-22 12:20   ` Jan Kiszka
2018-08-22 12:48     ` Hombourger, Cedric
2018-08-22 13:41       ` Henning Schild
2018-08-22 13:47         ` Hombourger, Cedric
2018-08-22 13:48         ` Jan Kiszka
2018-08-26  6:21         ` [PATCH v3 1/3] dpkg: move installation of dependencies into dpkg_prepare Cedric Hombourger
2018-08-26  6:21           ` [PATCH v3 2/3] linux: leverage dpkg_prepare to install build dependencies Cedric Hombourger
2018-08-26  6:21           ` Cedric Hombourger [this message]
2018-08-28 12:12           ` [PATCH v3 1/3] dpkg: move installation of dependencies into dpkg_prepare Maxim Yu. Osipov
2018-08-31  8:10           ` Jan Kiszka
2018-08-31  8:15             ` chombourger
2018-08-31  8:21               ` Jan Kiszka
2018-08-31  8:28           ` Jan Kiszka
2018-08-31  8:33             ` chombourger
2018-08-31  8:41               ` Jan Kiszka
2018-08-31  9:05                 ` Jan Kiszka
2018-09-01  6:58                   ` Jan Kiszka
2018-09-01  8:44                     ` Cedric Hombourger
2018-09-01  9:31                       ` Jan Kiszka
2018-08-22 11:58 ` [PATCH 0/1] acquire database lock when calling reprepro Alexander Smirnov
2018-08-22 12:07   ` Hombourger, Cedric
2018-08-22 12:47 ` [PATCH v2] dpkg: acquire " Cedric Hombourger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1535264488-128-3-git-send-email-Cedric_Hombourger@mentor.com \
    --to=cedric_hombourger@mentor.com \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox