From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6657829413861720064 X-Received: by 2002:a17:906:470f:: with SMTP id y15mr564449ejq.14.1550160496579; Thu, 14 Feb 2019 08:08:16 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a50:b7fc:: with SMTP id i57ls804615ede.4.gmail; Thu, 14 Feb 2019 08:08:16 -0800 (PST) X-Google-Smtp-Source: AHgI3IZvLzUOt9OTw0A6ixXPyB66w/xh0xJLhByTnmklSrkWCfxhYg91Qpj7C4whZiG9TehdvYyA X-Received: by 2002:a50:b781:: with SMTP id h1mr612383ede.3.1550160496209; Thu, 14 Feb 2019 08:08:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550160496; cv=none; d=google.com; s=arc-20160816; b=mkOxS0h6GTwTtCVUq1IAtjUrloWgytlOCPf6r6O38HyGCLhkhOdo/6HWyuk9cx6YG4 zo+zkUil/wqfKIM+u+PStNi0OUIqO5fKjKzHzB9I4xn9bYIWNXauk+cmOXSpdthvn+Uf Fj/uyJgsHwE7MESNlCShHHT+wq26NzWyk3G4Naluh6nhseTgr3ZdA796i0mssmM4aHou cQOlA+WToxvZesSNWZBv5N4bvhOpBgIxGzwvdZ0Q04sIlwK7SxGulg+eB4KkNWbI+CCT 1DjHeKMVw2vQnMBHXss8oPpDGQRMUQCYmfQACVQLwq+WMFeScpCWnKe8DaExYc7gWPJN K60Q== 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=oE54SlXmmY5y60PmrTh8JF8O1YXcwBehGjOV+JlzWE0=; b=Us2yIsKDSdkwmSfeTMc5d45h+dxe9KZzU4f4q54RgYZ1PepEPMcrN4bxW/PaGUikot woVZCtRll1isab8FfnmX5WyLH/KHKapJV8XRCx9LHfGl8DBDYNjBIltBTvDrUFK/SAXz 05mo9p7fMwDVPvvC90DO4UAID8iKQgMF4hwyPdxlAJ6jkvPGLk+nOLBSZ5rB+tpokRHZ wXAzDMC79FcHIija7EiI3aaxuyR9WdAnI+ISURJyfhyqa8cWdp+R0rNVu38G48DCYkL3 ZwloJKPKGw6v7DZKiEamSOyP0lfECI8WoDep0Q0zxu8gM7DzvfXtT+1u8ZxZ6fmYdd8M SwxQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Return-Path: Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id l1si167457ejs.1.2019.02.14.08.08.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 08:08:16 -0800 (PST) Received-SPF: pass (google.com: domain of claudius.heine.ext@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 claudius.heine.ext@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id x1EG8Coc021361 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Feb 2019 17:08:13 +0100 Received: from ring.ppmd.siemens.net (linux-ses-ext02.ppmd.siemens.net [139.25.69.232]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id x1EG8CI3002860; Thu, 14 Feb 2019 17:08:12 +0100 From: claudius.heine.ext@siemens.com To: isar-users@googlegroups.com Cc: Claudius Heine Subject: [PATCH v2] meta: refactored flock usage Date: Thu, 14 Feb 2019 17:08:05 +0100 Message-Id: <20190214160805.19980-1-claudius.heine.ext@siemens.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190214121819.22037-1-claudius.heine.ext@siemens.com> References: <20190214121819.22037-1-claudius.heine.ext@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: jYnSP5yXRZo4 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 76602d8..5367a37 100644 --- a/meta/classes/wic-img.bbclass +++ b/meta/classes/wic-img.bbclass @@ -87,14 +87,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.20.1