From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6521574339082452992 X-Received: by 10.25.170.82 with SMTP id t79mr208766lfe.36.1518552330014; Tue, 13 Feb 2018 12:05:30 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 10.25.72.82 with SMTP id v79ls1667548lfa.7.gmail; Tue, 13 Feb 2018 12:05:29 -0800 (PST) X-Google-Smtp-Source: AH8x2264cd/NMLeyoxHCsAXmTU1CwZf8EeRaHwUBt9hyyYCF4XlAgae35f+KcvONUOj/ZctBURU/ X-Received: by 10.25.203.215 with SMTP id b206mr211368lfg.6.1518552329381; Tue, 13 Feb 2018 12:05:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518552329; cv=none; d=google.com; s=arc-20160816; b=YswevXQFqohxQtTrhK++1hI/I0ol/Qq0Edo+tcIgcS/8z3BtWXWuZlFWheWjJDe38i nJoDZ7BUaIs8TL21oRC0bDyz3s0SM3JuAuyAw/A+C7oyOE/oAYMJvBlGE5qM9X9onKrZ XTaYh0eFod51ULkpBH8tnyMiyHd08EDGu7DZvOAM1I3tBWO1il8O9QCgvoctrAvNj39J frHNyppfl/iQ0LIOnV7aXn5zjwZ8KyYsNLnLAdyR/QpxIIB7PL4MyVCxVJEUmeJIzFx6 8jGgxHWV9p0tZSclOd2MAiG0uCGt5RzpwJsO+AgE1HFznOXGwAxz1nNiH5FFckHrMAnj zN6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:references:in-reply-to:message-id:date :subject:to:from:arc-authentication-results; bh=1UHLIPq/3dSTuwPn6LTBe5kb/lm2U02oYOsl4EtnT14=; b=O9QYEKjto2fuWaN19qnAx1GmNFFoiHbkxvKhMnSiKZWa1MRocwxOPt8fLCFEjNH/ke tHYaY6QC+OhyqvXhb9Q4vNJJqwVsJ8ASBJkYbiH2a0GoTrC2AXghGrl1UCVEb/ADYhjs n+CrGk/qAbHneKFiq7FOA8BAlbBtPgdNYlG7+a9TbmIfhpd02WCvTim49CiAdlFns8LO qFNi4mKPmpPhr4bnoBTBbwH4RLcS/gPaZLO6Q5qBTj1dnLyPpZzZI3MJY8wOIDP7BoSr X/l9elBuZR2FAc9g6exB7k2bNQXGmehj77YVUymH+Q8vu3FJiS2N3letY2Eenc3y7B9/ xmKQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Return-Path: Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id b10si537422lfe.4.2018.02.13.12.05.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 12:05:29 -0800 (PST) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Received: from mail2.siemens.de (mail2.siemens.de [139.25.208.11]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id w1DK5Se1018534 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 13 Feb 2018 21:05:28 +0100 Received: from md1f2u6c.ad001.siemens.net (md1q0hnc.ad001.siemens.net [139.25.68.37] (may be forged)) by mail2.siemens.de (8.15.2/8.15.2) with ESMTP id w1DK5Sui001776 for ; Tue, 13 Feb 2018 21:05:28 +0100 From: Jan Kiszka To: isar-users Subject: [PATCH v2 5/9] Move buildchroot mounts into dpkg-base class Date: Tue, 13 Feb 2018 21:05:23 +0100 Message-Id: <697b09bb60a515430f655989e859263922148264.1518552327.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: X-TUID: fx85XNv6Jvyv From: Jan Kiszka This avoids the unfortunate setup_mounts task which is either not executed on rebuilds or causes excessive package rebuilds. We just need ensure prior to switching into the buildchroot that all mount points are populated. Signed-off-by: Jan Kiszka --- meta/classes/dpkg-base.bbclass | 13 +++++++++- meta/recipes-devtools/buildchroot/buildchroot.bb | 30 +++--------------------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass index a45fbce..66132da 100644 --- a/meta/classes/dpkg-base.bbclass +++ b/meta/classes/dpkg-base.bbclass @@ -2,7 +2,7 @@ # Copyright (C) 2017 Siemens AG # Add dependency from buildchroot creation -do_build[depends] = "buildchroot:do_setup_mounts" +do_build[depends] = "buildchroot:do_build" # Add dependency between Isar recipes DEPENDS ?= "" @@ -20,11 +20,22 @@ dpkg_runbuild() { die "This should never be called, overwrite it in your derived class" } +mount_if_needed() { + + # The test may race with parallel builds. So probe, mount if needed, and + # then only fail if both the mount and yet another probe failed as well. + grep -q $2 /proc/mounts || sudo mount $1 $2 || grep -q $2 /proc/mounts +} + # Wrap the function dpkg_runbuild with the bind mount for buildroot do_build() { mkdir -p ${BUILDROOT} sudo mount --bind ${WORKDIR} ${BUILDROOT} + mount_if_needed "--bind ${DEPLOY_DIR_APT}/${DISTRO}" ${BUILDCHROOT_DIR}/isar-apt + mount_if_needed "-t devtmpfs -o mode=0755,nosuid devtmpfs" ${BUILDCHROOT_DIR}/dev + mount_if_needed "-t proc none" ${BUILDCHROOT_DIR}/proc + dpkg_runbuild sudo umount ${BUILDROOT} 2>/dev/null || true diff --git a/meta/recipes-devtools/buildchroot/buildchroot.bb b/meta/recipes-devtools/buildchroot/buildchroot.bb index 570c0ad..cd91228 100644 --- a/meta/recipes-devtools/buildchroot/buildchroot.bb +++ b/meta/recipes-devtools/buildchroot/buildchroot.bb @@ -60,7 +60,9 @@ do_build() { -e 's|##DIR_HOOKS##|./'"$WORKDIR_REL"'/hooks_multistrap|g' \ "${WORKDIR}/multistrap.conf.in" > "${WORKDIR}/multistrap.conf" - do_setup_mounts + sudo mount --bind ${DEPLOY_DIR_APT}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt + sudo mount -t devtmpfs -o mode=0755,nosuid devtmpfs ${BUILDCHROOT_DIR}/dev + sudo mount -t proc none ${BUILDCHROOT_DIR}/proc # Create root filesystem sudo -E multistrap -a ${DISTRO_ARCH} -d "${BUILDCHROOT_DIR}" -f "${WORKDIR}/multistrap.conf" @@ -70,30 +72,4 @@ do_build() { # Configure root filesystem sudo chroot ${BUILDCHROOT_DIR} /configscript.sh - - do_cleanup_mounts -} - -# Invalidate stamp for do_setup_mounts before each build start. -# This will guarantee that this function will be executed once -# per build. -python __anonymous() { - stamp = d.getVar("STAMP") + ".do_setup_mounts." + d.getVarFlag("do_setup_mounts", 'stamp-extra-info') - os.remove(stamp) if os.path.exists(stamp) else None -} - -do_setup_mounts[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}" - -do_setup_mounts() { - sudo mount --bind ${DEPLOY_DIR_APT}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt - sudo mount -t devtmpfs -o mode=0755,nosuid devtmpfs ${BUILDCHROOT_DIR}/dev - sudo mount -t proc none ${BUILDCHROOT_DIR}/proc -} - -addtask setup_mounts after do_build - -do_cleanup_mounts() { - sudo umount ${BUILDCHROOT_DIR}/isar-apt 2>/dev/null || true - sudo umount ${BUILDCHROOT_DIR}/dev 2>/dev/null || true - sudo umount ${BUILDCHROOT_DIR}/proc 2>/dev/null || true } -- 2.13.6