From: Jan Kiszka <
jan.k...@siemens.com>
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.
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