From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6521574339082452992 X-Received: by 10.46.50.5 with SMTP id y5mr182955ljy.34.1518553079837; Tue, 13 Feb 2018 12:17:59 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 10.25.26.13 with SMTP id a13ls1662726lfa.5.gmail; Tue, 13 Feb 2018 12:17:58 -0800 (PST) X-Google-Smtp-Source: AH8x2271i88yuytVYvKOz1DmHI+wVb44O0q0s+8DnJVbzwdontM3A5efXDty+DM/k8ZTJ3k5mXlP X-Received: by 10.25.31.66 with SMTP id f63mr204624lff.42.1518553078818; Tue, 13 Feb 2018 12:17:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518553078; cv=none; d=google.com; s=arc-20160816; b=vKM5MpD55NIanwCPdCgRZ51bTJ/PhpszwchSehMFNxSwsBvYcWcEWoyCkuWep1wdNs oMeVyZzXYNlB0YcSrW1t6gbIOon09Z+YWnIrAqGsiMMbIiMbA8CQnhuMphvpn7KfTsEf 58UITGOJvTd0TlcLeI3TvueVN03m4VNY8dPulVHq0lQQlANkBIRaz0xr2dkBxgSjqDXu qQGVbyspuUktF9NSVQJkrgBjZZYC5/31N0oJZVTLZjvlOcXtfSZYBvCqCJqK/chhdeur 6MtUQCyJVEq1C9iFbxRTrB+v+BBxCHqNIj9PPoSwTibmsLOygX/pcPkAVJauKkqHCtyo rTHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject :arc-authentication-results; bh=VxQiARjYd9o/DUKr06jtWzACw8VKwBaof5/cmDs/qaE=; b=yg0uG07htzTR4QnqUjTq/Ua0ptONyk5qkf2QdZzv0hedMGe/BgT6VarPDc2VmuzoBe 5wqhR3wV9RHLtcrgBpxKFLo8wkuFilW6TW7GZuv5klxu9dg7i2U2G+VFH77NtBUpvzdH 4Ytzzk4S2WwiA1SguOQE/m30h9SeyXgGOCWwAPmZCb5NPO3m9jMlMsOBMYVVYq6HazRh /2w57XlsvsUzwPly+J3mmwKNa4xbMpgpeR3jluXH5gtPdQbaCZJB+Vy1digNP6mr7/iY CP8B5G0W4uVn1ozsA9Uus6IK/sXbdcOIBpv8zNLb1cDflRSH/zg5TBKVy+sKAMLdAMFD 9QKA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=asmirnov@ilbers.de Return-Path: Received: from aqmola.ilbers.de (aqmola.ilbers.de. [85.214.62.211]) by gmr-mx.google.com with ESMTPS id w20si593059ljd.2.2018.02.13.12.17.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 12:17:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) client-ip=85.214.62.211; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=asmirnov@ilbers.de Received: from [10.0.2.15] ([188.227.110.165]) (authenticated bits=0) by aqmola.ilbers.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id w1DKHrcL007461 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Tue, 13 Feb 2018 21:17:55 +0100 Subject: Re: [PATCH v2 5/9] Move buildchroot mounts into dpkg-base class To: Jan Kiszka , isar-users References: <697b09bb60a515430f655989e859263922148264.1518552327.git.jan.kiszka@siemens.com> From: Alexander Smirnov Message-ID: <640ea89d-7320-30b9-fd22-4747ee3f727f@ilbers.de> Date: Tue, 13 Feb 2018 23:17:48 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <697b09bb60a515430f655989e859263922148264.1518552327.git.jan.kiszka@siemens.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: FxyW0FN4Fc6B On 02/13/2018 11:05 PM, Jan Kiszka wrote: > 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 This could lead to have lots of remounts on the same folder during parallel execution. This should be done in a separate task and protected by [lockfiles]. Alex > +} > + > # 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 > } > -- With best regards, Alexander Smirnov ilbers GmbH Baierbrunner Str. 28c D-81379 Munich +49 (89) 122 67 24-0 http://ilbers.de/ Commercial register Munich, HRB 214197 General manager: Baurzhan Ismagulov