From: "Andreas J. Reichel" <andreas.reichel.ext@siemens.com>
To: isar-users@googlegroups.com
Cc: Claudius Heine <ch@denx.de>
Subject: [PATCH v4 1/6] meta: refactored flock usage
Date: Thu, 7 Mar 2019 15:22:59 +0100 [thread overview]
Message-ID: <20190307142304.14508-2-andreas.reichel.ext@siemens.com> (raw)
In-Reply-To: <20190307142304.14508-1-andreas.reichel.ext@siemens.com>
From: Claudius Heine <ch@denx.de>
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 <ch@denx.de>
---
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
next prev parent reply other threads:[~2019-03-07 14:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-07 14:22 [PATCH v4 0/6] Fixes usage of additional apt keys and repos Andreas J. Reichel
2019-03-07 14:22 ` Andreas J. Reichel [this message]
2019-03-07 14:23 ` [PATCH v4 2/6] Revert "isar-bootstrap: Allow to set local keys in DISTRO_APT_KEYS" Andreas J. Reichel
2019-03-07 14:23 ` [PATCH v4 3/6] Remove duplicate code from apt-keyring generation Andreas J. Reichel
2019-03-07 14:46 ` Henning Schild
2019-03-18 10:14 ` Andreas Reichel
2019-03-07 14:23 ` [PATCH v4 4/6] Fix fetched key location in apt-keyring generator Andreas J. Reichel
2019-03-07 14:23 ` [PATCH v4 5/6] Use apt-key to generate apt-keyring Andreas J. Reichel
2019-03-07 14:51 ` Henning Schild
2019-03-18 12:57 ` Andreas Reichel
2019-03-07 14:58 ` Claudius Heine
2019-03-18 10:21 ` Andreas Reichel
2019-03-18 11:48 ` Claudius Heine
2019-03-18 11:49 ` Andreas Reichel
2019-03-18 11:53 ` Andreas Reichel
2019-03-07 14:23 ` [PATCH v4 6/6] If we use a custom keyring debootstrap may fall to https Andreas J. Reichel
2019-03-07 14:54 ` Henning Schild
2019-03-18 10:09 ` Andreas Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190307142304.14508-2-andreas.reichel.ext@siemens.com \
--to=andreas.reichel.ext@siemens.com \
--cc=ch@denx.de \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox