From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6592507174472122368 X-Received: by 2002:aca:ea05:: with SMTP id i5-v6mr34738687oih.103.1534937692821; Wed, 22 Aug 2018 04:34:52 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:aca:a9d0:: with SMTP id s199-v6ls484061oie.5.gmail; Wed, 22 Aug 2018 04:34:52 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzlTf/EpN0lEw5XJzljTIBW06GJPo6mOLfSxFGbijonV/+e6IhK2ksLnsll3KVqPnFqdjHc X-Received: by 2002:aca:4186:: with SMTP id o128-v6mr34592399oia.82.1534937692595; Wed, 22 Aug 2018 04:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534937692; cv=none; d=google.com; s=arc-20160816; b=g+yMcFFv1JwKb1EFeOtUYjeZoM2HvPPGxNj7/JA+02sCRCe9ziehDlgV1ccdE5YyGR J/crPFHrTShnvFwKXBAXtUU7FW3Xe+PKmEcqAP8o9f4qIsj8RZlRMQpCkxdJlEOeWQQW PWmNVSdNW8tWg2L8KixnDMdMsTmBW+QqZf26jC0gvoJe4PuC2GssJbToHNHHvxKpSzJr QIaljWr9r3LmaVRHn2HfLcBWd2qNSHisWzEqhsf/tS6P81wCG5aJfdVWtv0sSHKd4Fot 8nNCBgka5U3DMmltn3r/rVOkPG13M1GdIqsqnZaiofThgNXSy6U0zC6luDQvUIRpTPpU JmDQ== 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:arc-authentication-results; bh=Xu2tN2qYZs6Spr5o681Ji1LB1dADAC8+ySYMCi2rUT4=; b=MV3jm/On2j3W7Zl3sHdquBxHFKk+XTawUmnOW9TMiXuE0vo581E49Az8yIyFpk/3M0 q4bidpTod3qu8xlNQFikbDdWkYJxRfeCv5wKwc0h3TSrp4Pt7zPYZgvIKlw+xMg+ZrO+ Logf5uAbTAn1T0LuR2Z9xf0eu4dgBkG4Bg0iIBK6cKVCNEL4B0fFYVKDaKsWacMhwiIv 5mcAo8eZ0YsoS9RfPG0Cu+6SUFRIGgX9h19x1U3hk9aBHR8G0irx2SHxU/dkmQpy9Uvb TwAJfBCqvAGA7wrY4JuluMWbE7gdmtDMVqU9Oubtxz6C9GXkjU8MLH8YXyay21p0aEGN c+Pw== 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 c21-v6si58929oic.1.2018.08.22.04.34.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 04:34:52 -0700 (PDT) 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 1fsRPX-0000aZ-Td from Cedric_Hombourger@mentor.com for isar-users@googlegroups.com; Wed, 22 Aug 2018 04:34:51 -0700 Received: from FRG-W10-HOMBOUR.world.mentorg.com (137.202.0.87) by svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 22 Aug 2018 12:34:48 +0100 From: Cedric Hombourger To: CC: Cedric Hombourger Subject: [PATCH 1/1] dpkg: acquire lock when calling reprepro Date: Wed, 22 Aug 2018 13:34:36 +0200 Message-ID: <1534937676-7628-2-git-send-email-Cedric_Hombourger@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534937676-7628-1-git-send-email-Cedric_Hombourger@mentor.com> References: <1534937676-7628-1-git-send-email-Cedric_Hombourger@mentor.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [137.202.0.87] 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: hdmIOZBn/Cyd As bitbake performs multi-threaded builds, packages may be built while others get deployed. A lock was already acquired within dpkg_runbuild but accesses to the isar-apt database were not protected from do_deploy_deb. Move the lock from the buildchroot to the isar-apt repository and acquire the (same) lock from dpkg_runbuild, repo_clean and do_deploy_deb. Signed-off-by: Cedric Hombourger --- meta/classes/dpkg-base.bbclass | 8 ++++++-- meta/recipes-devtools/buildchroot/files/build.sh | 2 +- meta/recipes-kernel/linux/files/build-kernel.sh | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass index a41df2c..7137968 100644 --- a/meta/classes/dpkg-base.bbclass +++ b/meta/classes/dpkg-base.bbclass @@ -71,6 +71,8 @@ do_build() { mount -t proc none ${BUILDCHROOT_DIR}/proc fi' + # Create database lock file here so we own it (not root) and perform actual build + touch ${DEPLOY_DIR_APT}/${DISTRO}/db.lock dpkg_runbuild sudo umount ${BUILDROOT} 2>/dev/null || true @@ -82,7 +84,8 @@ CLEANFUNCS += "repo_clean" repo_clean() { PACKAGES=$(cd ${S}/..; ls *.deb | sed 's/\([^_]*\).*/\1/') if [ -n "${PACKAGES}" ]; then - reprepro -b ${DEPLOY_DIR_APT}/${DISTRO} \ + flock ${DEPLOY_DIR_APT}/${DISTRO}/db.lock \ + reprepro -b ${DEPLOY_DIR_APT}/${DISTRO} \ --dbdir ${DEPLOY_DIR_DB}/${DISTRO} \ -C main -A ${DISTRO_ARCH} \ remove ${DEBDISTRONAME} \ @@ -93,7 +96,8 @@ repo_clean() { # Install package to Isar-apt do_deploy_deb() { repo_clean - reprepro -b ${DEPLOY_DIR_APT}/${DISTRO} \ + flock ${DEPLOY_DIR_APT}/${DISTRO}/db.lock \ + reprepro -b ${DEPLOY_DIR_APT}/${DISTRO} \ --dbdir ${DEPLOY_DIR_DB}/${DISTRO} \ -C main \ includedeb ${DEBDISTRONAME} \ diff --git a/meta/recipes-devtools/buildchroot/files/build.sh b/meta/recipes-devtools/buildchroot/files/build.sh index e2dabab..e8a9c17 100644 --- a/meta/recipes-devtools/buildchroot/files/build.sh +++ b/meta/recipes-devtools/buildchroot/files/build.sh @@ -50,7 +50,7 @@ install_cmd="apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y # Install all build deps mk-build-deps $set_arch -t "${install_cmd}" -i -r debian/control -) 42>/dpkg.lock +) 42>/isar-apt/db.lock # If autotools files have been created, update their timestamp to # prevent them from being regenerated diff --git a/meta/recipes-kernel/linux/files/build-kernel.sh b/meta/recipes-kernel/linux/files/build-kernel.sh index 8b58e93..2ff5a1e 100644 --- a/meta/recipes-kernel/linux/files/build-kernel.sh +++ b/meta/recipes-kernel/linux/files/build-kernel.sh @@ -34,7 +34,7 @@ REPACK_LINUX_IMAGE_DIR="${REPACK_DIR}/linux-image" REPACK_LINUX_HEADERS_DIR="${REPACK_DIR}/linux-headers" # Lock-protected because apt and dpkg do not wait in case of contention -flock /dpkg.lock \ +flock /isar-apt/db.lock \ apt-get install -y -o Debug::pkgProblemResolver=yes \ --no-install-recommends ${KBUILD_DEPENDS} -- 2.11.0