From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6665315485307895808 X-Received: by 2002:a50:b361:: with SMTP id r30mr4951803edd.8.1551968711159; Thu, 07 Mar 2019 06:25:11 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a50:b136:: with SMTP id k51ls1447078edd.6.gmail; Thu, 07 Mar 2019 06:25:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzGrFRa88FYJRHqd9shLSbKB3juSgr4Jr5al8RlOXRNGkxPT9f+TDNWTdKzibw+qnlUInt1 X-Received: by 2002:a50:eb05:: with SMTP id y5mr4947557edp.5.1551968710741; Thu, 07 Mar 2019 06:25:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551968710; cv=none; d=google.com; s=arc-20160816; b=G45YiQMUz04Ok7firgVyyhPI7ovfw59RnsHJ6rqb/mkZhvT6JuE4DpyG43YhFX49Uc WxKl3b+4sce370Zfp8JIp0y7sceXRWYK2eZAzabEth4RSBSm1ZcxDRI1q2GIPLvK4nuU 9jchSnLyLHWfeg7Pte6nhvJlOHdpDdMwsG0UPfjIdByxNCsJODsLfwsUL1tJCihAbgRy M0IlOKQipvAc/vQU5vq3xIgMf8Tq5ekhpbv/DL2vaZGRxaThGM/rRlhmKPgyFFpnmJeX 9ktUJO7+36qVvOpwBEJRBN+X8GqaJCF/qwsh6Cdf+e0odj7uoCvdZ8KRDD9knTpwD/Vf YzqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=3egFcokCcnUEgEtxKuAsioADNrANdvQ2211g0lFFnCs=; b=eEB53OQY/fQEJyHl0zdjYzgdOWWipWOcqmEfI82Oo58r28VlrvUM9rGRJ/Fic7rRnD i6MJt7a7Ws/SSts6akIuNwcUKDCJJL1uNFrYesCvmqT7YAoyM3AWxeKD/t/Jgdqqigm3 uUMmLN+JH8g3RniCZlqAuyxVIesquYRK/GzxZMNazYixS58WGXwPFKIfocJC+6C0YJEy nIX4XPuHmx5d+p7BU7UE46OeOpbGd/RHJaEkcVs7CloKCe59B2s9hJeaKc7nHIiyokvB gUOM9h2r6mlnvljCahAJa69QEY7UnA2pVZp7sGQ1yKRuJp0hEultpl4jl/oTyTvjbr9a bJDA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of andreas.reichel.ext@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=andreas.reichel.ext@siemens.com Return-Path: Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id r37si271813edd.2.2019.03.07.06.25.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 06:25:10 -0800 (PST) Received-SPF: pass (google.com: domain of andreas.reichel.ext@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of andreas.reichel.ext@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=andreas.reichel.ext@siemens.com Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id x27EP9QX004422 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 7 Mar 2019 15:25:09 +0100 Received: from localhost.localdomain (golem.ppmd.siemens.net [139.25.69.17]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id x27EP9RG020333; Thu, 7 Mar 2019 15:25:09 +0100 From: "Andreas J. Reichel" To: isar-users@googlegroups.com Cc: Claudius Heine Subject: [PATCH v4 1/6] meta: refactored flock usage Date: Thu, 7 Mar 2019 15:22:59 +0100 Message-Id: <20190307142304.14508-2-andreas.reichel.ext@siemens.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190307142304.14508-1-andreas.reichel.ext@siemens.com> References: <20190307142304.14508-1-andreas.reichel.ext@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: vZr80W+klaDc From: Claudius Heine Currently much care has to be taken in order to correctly escape strings inside flock commands. And there is also on instance where this was incorrectly used (isar-bootstrap.inc). The usage of flock was changed to no longer require single or double ticks. Instead commands are run inside a subshell. Signed-off-by: Claudius Heine --- meta/classes/buildchroot.bbclass | 6 ++++-- meta/classes/wic-img.bbclass | 6 ++++-- meta/recipes-core/isar-bootstrap/isar-bootstrap.inc | 10 +++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/meta/classes/buildchroot.bbclass b/meta/classes/buildchroot.bbclass index 0d4ff4e..c017b25 100644 --- a/meta/classes/buildchroot.bbclass +++ b/meta/classes/buildchroot.bbclass @@ -22,7 +22,8 @@ python __anonymous() { MOUNT_LOCKFILE = "${BUILDCHROOT_DIR}/mount.lock" buildchroot_do_mounts() { - sudo flock ${MOUNT_LOCKFILE} -c ' \ + sudo -s <<'EOSUDO' + ( flock 9 set -e if ! grep -q ${BUILDCHROOT_DIR}/isar-apt /proc/mounts; then mount --bind ${REPO_ISAR_DIR}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt @@ -36,5 +37,6 @@ buildchroot_do_mounts() { # Refresh /etc/resolv.conf at this chance cp -L /etc/resolv.conf ${BUILDCHROOT_DIR}/etc - ' + ) 9>${MOUNT_LOCKFILE} +EOSUDO } diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass index c9d90a9..ac85254 100644 --- a/meta/classes/wic-img.bbclass +++ b/meta/classes/wic-img.bbclass @@ -136,14 +136,16 @@ do_build[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}" do_wic_image() { buildchroot_do_mounts - sudo flock ${MOUNT_LOCKFILE} -c ' \ + sudo -s <<'EOSUDO' + ( flock 9 for dir in ${BBLAYERS} ${STAGING_DIR} ${ISARROOT}/scripts; do mkdir -p ${BUILDCHROOT_DIR}/$dir if ! mountpoint ${BUILDCHROOT_DIR}/$dir >/dev/null 2>&1; then mount --bind --make-private $dir ${BUILDCHROOT_DIR}/$dir fi done - ' + ) 9>${MOUNT_LOCKFILE} +EOSUDO export FAKEROOTCMD=${FAKEROOTCMD} export BUILDDIR=${BUILDDIR} export MTOOLS_SKIP_CHECK=1 diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc index 234d339..9c82184 100644 --- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc +++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc @@ -207,14 +207,16 @@ isar_bootstrap() { esac shift done - debootstrap_args="--verbose --variant=minbase --include='${DISTRO_BOOTSTRAP_BASE_PACKAGES}'" + debootstrap_args="--verbose --variant=minbase --include=${DISTRO_BOOTSTRAP_BASE_PACKAGES}" if [ "${ISAR_USE_CACHED_BASE_REPO}" = "1" ]; then if [ -z "${BASE_REPO_KEY}" ] ; then debootstrap_args="$debootstrap_args --no-check-gpg" fi fi E="${@bb.utils.export_proxies(d)}" - sudo -E flock "${ISAR_BOOTSTRAP_LOCK}" -c "\ + export IS_HOST debootstrap_args E + sudo -E -s <<'EOSUDO' + ( flock 9 set -e if [ ! -e "${DEPLOY_ISAR_BOOTSTRAP}" ]; then rm -rf "${ROOTFSDIR}" @@ -295,7 +297,9 @@ isar_bootstrap() { # Finalize debootstrap by setting the link in deploy ln -Tfsr "${ROOTFSDIR}" "${DEPLOY_ISAR_BOOTSTRAP}" - fi" + fi + ) 9>'${ISAR_BOOTSTRAP_LOCK}' +EOSUDO } CLEANFUNCS = "clean_deploy" -- 2.21.0