From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6665957031077216256 X-Received: by 2002:a2e:9a0e:: with SMTP id o14mr1118605lji.9.1552060165553; Fri, 08 Mar 2019 07:49:25 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:ac2:4352:: with SMTP id o18ls915672lfl.11.gmail; Fri, 08 Mar 2019 07:49:25 -0800 (PST) X-Google-Smtp-Source: APXvYqzi02LxysUc4JAxJU8kK7WstZGm6GP9S2EtmxlzqY8/1Y/bxiiWxTtMmIc+62hOC05m/PuQ X-Received: by 2002:ac2:554f:: with SMTP id l15mr1206116lfk.16.1552060165029; Fri, 08 Mar 2019 07:49:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552060165; cv=none; d=google.com; s=arc-20160816; b=GyTBEFaagCsY453u6rnq4BUmWB3BZE/me7v+RAzlT4TZlTkp42uZQzbun4h6o0Qlzc +dlzrfgtU2vas4tyYvfEszE0p49qdGqOtOO6rlZBpT3JKDKS7Rzyjbleus6soSi+cNvF scc5P+S81FCml7opVxHXlw/3W/Gsv6f84pLLsMzjE2vVrxyT7jZgdr8YI/Tux/4IzdOu fFvn3lDpyBwBXHK+MQhhwBL5VtnbaKRiXfLNiKbc74SlZHnOMazhxVZ9PK0pqBWPYZP+ Ga6YRLDUcgjhDRHtrIvYBfqyTF4nQ4nWySbYn9ExdkUjyG+GlOCR/IV18jQ9+bNEyg3s dKyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=6FhCrJ7gRl5Q11hTuVUtD90CNqMVl2w4phjCSKmQc3A=; b=mzNzMYQrKKOM+E1nU3Ugj0+v0tsJYCu3kps/Cj28Oua/e19K+qoiBa0y9QJ/cNixGI oJDWcrYANNBTpagAfPp4G7wpYX3KH7oihq7D9hEG+oN5L9PQVmJMFW997YBseBmcdftg FbPRIqtXHcLdavTV1pPRuo+JOMXXKjQPO3SFh3fk34rsRagPCEn87bB1OH3FRNiBwZ9Z 0PWDVe9k+2FbMO4JjiQ6MdS6tE7cskrGJ58T11QEFih2pqdZWNSNMKeAyBdRuYLqGp5B cN9KVvYMA20le+bmBWp3RnKzUA3Qn/gcZH7qI51xkkpaEBR5FYqCHi8kGL5oxNTCqYsJ GUtA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of cedric_hombourger@mentor.com designates 192.94.38.131 as permitted sender) smtp.mailfrom=Cedric_Hombourger@mentor.com Return-Path: Received: from relay1.mentorg.com (relay1.mentorg.com. [192.94.38.131]) by gmr-mx.google.com with ESMTPS id h25si517517lja.3.2019.03.08.07.49.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 07:49:24 -0800 (PST) Received-SPF: pass (google.com: domain of cedric_hombourger@mentor.com designates 192.94.38.131 as permitted sender) client-ip=192.94.38.131; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of cedric_hombourger@mentor.com designates 192.94.38.131 as permitted sender) smtp.mailfrom=Cedric_Hombourger@mentor.com Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-02.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1h2HkQ-0000Hl-Sz from Cedric_Hombourger@mentor.com for isar-users@googlegroups.com; Fri, 08 Mar 2019 07:49:22 -0800 Received: from FRG-W10-HOMBOUR.world.mentorg.com (137.202.0.90) by svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Fri, 8 Mar 2019 15:49:18 +0000 From: Cedric Hombourger To: CC: Cedric Hombourger Subject: [PATCH v2] dpkg: acquire a read (shared) locks while building packages Date: Fri, 8 Mar 2019 16:49:05 +0100 Message-ID: <1552060145-1317-1-git-send-email-Cedric_Hombourger@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <97148d8a-edea-f4c3-d35d-f538512b7c38@siemens.com> References: <97148d8a-edea-f4c3-d35d-f538512b7c38@siemens.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) X-TUID: S9XbEryOiPvC As debhelper scripts involved during the actual build process (dpkg-buildpackage) may access the dpkg database, we need to make sure it does not get modified in the background by other build tasks for other packages (such as install_build_deps). An example of a reader is dh_shlibdeps/dpkg-shlibdeps: it needs to find packages providing the shared libraries the package depends on to substitute shlibs variables found in its control file with package dependencies. Acquire the isar-apt lock as a shared lock to block writers. Special care may be needed in other classes/users of the dpkg_runbuild API. Due to some limitations with bitbake (to be discussed with the maintainers), we could not grab the lock from dpkg-base. A statement such as "flock dpkg_run_build" would fail as flock can't exec() dpkg_run_build (since it is a shell function, not an executable). The popular shell construct "( flock -n 9; dpkg_run_build ) 9> " cannot be parsed by bitbake. And finally the lockfiles task attribute (implemented in bitbake) only handles exclusive locks. This commit is only addressing dpkg.bbclass. dpkg-raw.bbclass is left intact as the generated control file does require dh_shlibdeps. linux-custom.inc was also left out as the Debian packaging scripts only use low-level packaging tools and do not use debhelper scripts during packaging (at this time). In agreement with the Isar project maintainers, we will not grab the Isar lock from linux-custom.inc to let kernel builds run in parallel with do_install_deps() and do_deploy_deb() that may be executed by other bitbake threads. Signed-off-by: Cedric Hombourger --- meta/classes/dpkg.bbclass | 1 + 1 file changed, 1 insertion(+) diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass index 24b9fe3..f4e3d7a 100644 --- a/meta/classes/dpkg.bbclass +++ b/meta/classes/dpkg.bbclass @@ -19,5 +19,6 @@ do_install_builddeps[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}" # Build package from sources using build script dpkg_runbuild() { E="${@ bb.utils.export_proxies(d)}" + flock -s "${REPO_ISAR_DIR}/isar.lock" \ sudo -E chroot --userspec=$( id -u ):$( id -g ) ${BUILDCHROOT_DIR} /isar/build.sh ${PP}/${PPS} ${DISTRO_ARCH} } -- 2.11.0