* [PATCH 0/3] Fail under flock & cleanups
@ 2018-08-12 8:33 Jan Kiszka
2018-08-12 8:33 ` [PATCH 1/3] Exit if commands fail under flock Jan Kiszka
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Jan Kiszka @ 2018-08-12 8:33 UTC (permalink / raw)
To: isar-users
This replaces and enhances "isar-bootstrap: exit if command fails under
flock" and adds some smaller cleanups to that code paths.
Jan
Jan Kiszka (3):
Exit if commands fail under flock
isar-bootstrap: Remove redundant sudos
dpkg-base: Reformat flock-protected commands
meta/classes/dpkg-base.bbclass | 11 +--
.../recipes-core/isar-bootstrap/isar-bootstrap.inc | 85 +++++++++++-----------
2 files changed, 49 insertions(+), 47 deletions(-)
--
2.16.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] Exit if commands fail under flock
2018-08-12 8:33 [PATCH 0/3] Fail under flock & cleanups Jan Kiszka
@ 2018-08-12 8:33 ` Jan Kiszka
2018-08-12 8:33 ` [PATCH 2/3] isar-bootstrap: Remove redundant sudos Jan Kiszka
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2018-08-12 8:33 UTC (permalink / raw)
To: isar-users
From: Jan Kiszka <jan.kiszka@siemens.com>
Add set -e to the shells spawned by flock so that any failure of a
command will lead to an immediate termination and reporting of the
failure. E.g., do_bootstrap could have silently failed so far.
Derived from patch by Maxim Osipov.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
meta/classes/dpkg-base.bbclass | 1 +
meta/recipes-core/isar-bootstrap/isar-bootstrap.inc | 1 +
2 files changed, 2 insertions(+)
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 674c0b5..9b42c42 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -63,6 +63,7 @@ do_build() {
sudo mount --bind ${WORKDIR} ${BUILDROOT}
sudo flock ${MOUNT_LOCKFILE} -c ' \
+ set -e
if ! grep -q ${BUILDCHROOT_DIR}/isar-apt /proc/mounts; then \
mount --bind ${DEPLOY_DIR_APT}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt; \
mount --bind ${DL_DIR} ${BUILDCHROOT_DIR}/downloads; \
diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
index 8afd470..5fba3dd 100644
--- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
+++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
@@ -172,6 +172,7 @@ isar_bootstrap() {
shift
done
sudo flock "${ISAR_BOOTSTRAP_LOCK}" -c "\
+ set -e
if [ ! -e "${DEPLOY_ISAR_BOOTSTRAP}" ]; then
if [ -e "${ROOTFSDIR}" ]; then
sudo umount -l "${ROOTFSDIR}/dev" || true
--
2.16.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] isar-bootstrap: Remove redundant sudos
2018-08-12 8:33 [PATCH 0/3] Fail under flock & cleanups Jan Kiszka
2018-08-12 8:33 ` [PATCH 1/3] Exit if commands fail under flock Jan Kiszka
@ 2018-08-12 8:33 ` Jan Kiszka
2018-08-12 8:33 ` [PATCH 3/3] dpkg-base: Reformat flock-protected commands Jan Kiszka
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2018-08-12 8:33 UTC (permalink / raw)
To: isar-users
From: Jan Kiszka <jan.kiszka@siemens.com>
The flock command is already called via sudo, thus the shell it spawns
is run as root as well.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
.../recipes-core/isar-bootstrap/isar-bootstrap.inc | 84 +++++++++++-----------
1 file changed, 42 insertions(+), 42 deletions(-)
diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
index 5fba3dd..bc91f35 100644
--- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
+++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
@@ -175,69 +175,69 @@ isar_bootstrap() {
set -e
if [ ! -e "${DEPLOY_ISAR_BOOTSTRAP}" ]; then
if [ -e "${ROOTFSDIR}" ]; then
- sudo umount -l "${ROOTFSDIR}/dev" || true
- sudo umount -l "${ROOTFSDIR}/proc" || true
- sudo rm -rf "${ROOTFSDIR}"
+ umount -l "${ROOTFSDIR}/dev" || true
+ umount -l "${ROOTFSDIR}/proc" || true
+ rm -rf "${ROOTFSDIR}"
fi
E="${@bb.utils.export_proxies(d)}"
if [ ${IS_HOST} ]; then
- sudo -E "${DEBOOTSTRAP}" --verbose \
- --variant=minbase \
- --include=locales \
- ${@get_distro_components_argument(d, True)} \
- ${DEBOOTSTRAP_KEYRING} \
- "${@get_distro_suite(d, True)}" \
- "${ROOTFSDIR}" \
- "${@get_distro_source(d, True)}"
+ ${DEBOOTSTRAP} --verbose \
+ --variant=minbase \
+ --include=locales \
+ ${@get_distro_components_argument(d, True)} \
+ ${DEBOOTSTRAP_KEYRING} \
+ "${@get_distro_suite(d, True)}" \
+ "${ROOTFSDIR}" \
+ "${@get_distro_source(d, True)}"
else
- sudo -E "${DEBOOTSTRAP}" --verbose \
- --variant=minbase \
- --arch="${DISTRO_ARCH}" \
- --include=locales \
- ${@get_distro_components_argument(d, False)} \
- ${DEBOOTSTRAP_KEYRING} \
- "${@get_distro_suite(d, False)}" \
- "${ROOTFSDIR}" \
- "${@get_distro_source(d, False)}"
+ "${DEBOOTSTRAP}" --verbose \
+ --variant=minbase \
+ --arch="${DISTRO_ARCH}" \
+ --include=locales \
+ ${@get_distro_components_argument(d, False)} \
+ ${DEBOOTSTRAP_KEYRING} \
+ "${@get_distro_suite(d, False)}" \
+ "${ROOTFSDIR}" \
+ "${@get_distro_source(d, False)}"
fi
# Install apt config
- sudo mkdir -p "${ROOTFSDIR}/etc/apt/preferences.d"
- sudo install -v -m644 "${APTPREFS}" \
- "${ROOTFSDIR}/etc/apt/preferences.d/bootstrap"
- sudo mkdir -p "${ROOTFSDIR}/etc/apt/sources.list.d"
- sudo install -v -m644 "${APTSRCS}" \
- "${ROOTFSDIR}/etc/apt/sources.list.d/bootstrap.list"
- sudo rm -f "${ROOTFSDIR}/etc/apt/sources.list"
- sudo mkdir -p "${ROOTFSDIR}/etc/apt/apt.conf.d"
- sudo install -v -m644 "${WORKDIR}/isar-apt.conf" \
- "${ROOTFSDIR}/etc/apt/apt.conf.d/50isar.conf"
+ mkdir -p "${ROOTFSDIR}/etc/apt/preferences.d"
+ install -v -m644 "${APTPREFS}" \
+ "${ROOTFSDIR}/etc/apt/preferences.d/bootstrap"
+ mkdir -p "${ROOTFSDIR}/etc/apt/sources.list.d"
+ install -v -m644 "${APTSRCS}" \
+ "${ROOTFSDIR}/etc/apt/sources.list.d/bootstrap.list"
+ rm -f "${ROOTFSDIR}/etc/apt/sources.list"
+ mkdir -p "${ROOTFSDIR}/etc/apt/apt.conf.d"
+ install -v -m644 "${WORKDIR}/isar-apt.conf" \
+ "${ROOTFSDIR}/etc/apt/apt.conf.d/50isar.conf"
if [ "${@get_distro_suite(d, True)}" = "stretch" ] && [ "${@get_host_release().split('.')[0]}" -lt "4" ]; then
- sudo install -v -m644 "${WORKDIR}/isar-apt-fallback.conf" \
- "${ROOTFSDIR}/etc/apt/apt.conf.d/55isar-fallback.conf"
+ install -v -m644 "${WORKDIR}/isar-apt-fallback.conf" \
+ "${ROOTFSDIR}/etc/apt/apt.conf.d/55isar-fallback.conf"
fi
# Set locale
- sudo install -v -m644 "${WORKDIR}/locale" "${ROOTFSDIR}/etc/locale"
+ install -v -m644 "${WORKDIR}/locale" "${ROOTFSDIR}/etc/locale"
- sudo sed -i '/en_US.UTF-8 UTF-8/s/^#//g' "${ROOTFSDIR}/etc/locale.gen"
- sudo -E chroot "${ROOTFSDIR}" /usr/sbin/locale-gen
+ sed -i '/en_US.UTF-8 UTF-8/s/^#//g' "${ROOTFSDIR}/etc/locale.gen"
+ chroot "${ROOTFSDIR}" /usr/sbin/locale-gen
# setup chroot
- sudo install -v -m755 "${WORKDIR}/chroot-setup.sh" "${ROOTFSDIR}/chroot-setup.sh"
- sudo "${ROOTFSDIR}/chroot-setup.sh" "setup" "${ROOTFSDIR}"
+ install -v -m755 "${WORKDIR}/chroot-setup.sh" "${ROOTFSDIR}/chroot-setup.sh"
+ "${ROOTFSDIR}/chroot-setup.sh" "setup" "${ROOTFSDIR}"
# update APT
- sudo mount -t devtmpfs -o mode=0755,nosuid devtmpfs ${ROOTFSDIR}/dev
- sudo mount -t proc none ${ROOTFSDIR}/proc
+ mount -t devtmpfs -o mode=0755,nosuid devtmpfs ${ROOTFSDIR}/dev
+ mount -t proc none ${ROOTFSDIR}/proc
E="${@bb.utils.export_proxies(d)}"
export DEBIAN_FRONTEND=noninteractive
- sudo -E chroot "${ROOTFSDIR}" /usr/bin/apt-get update -y
- sudo -E chroot "${ROOTFSDIR}" /usr/bin/apt-get dist-upgrade -y \
- -o Debug::pkgProblemResolver=yes
+ chroot "${ROOTFSDIR}" /usr/bin/apt-get update -y
+ chroot "${ROOTFSDIR}" /usr/bin/apt-get dist-upgrade -y \
+ -o Debug::pkgProblemResolver=yes
# Finalize debootstrap by setting the link in deploy
ln -Tfsr "${ROOTFSDIR}" "${DEPLOY_ISAR_BOOTSTRAP}"
--
2.16.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] dpkg-base: Reformat flock-protected commands
2018-08-12 8:33 [PATCH 0/3] Fail under flock & cleanups Jan Kiszka
2018-08-12 8:33 ` [PATCH 1/3] Exit if commands fail under flock Jan Kiszka
2018-08-12 8:33 ` [PATCH 2/3] isar-bootstrap: Remove redundant sudos Jan Kiszka
@ 2018-08-12 8:33 ` Jan Kiszka
2018-08-13 8:35 ` [PATCH 0/3] Fail under flock & cleanups Henning Schild
2018-08-14 10:31 ` Maxim Yu. Osipov
4 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2018-08-12 8:33 UTC (permalink / raw)
To: isar-users
From: Jan Kiszka <jan.kiszka@siemens.com>
We do not need that ugly line-continuations here.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
meta/classes/dpkg-base.bbclass | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 9b42c42..a41df2c 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -64,11 +64,11 @@ do_build() {
sudo flock ${MOUNT_LOCKFILE} -c ' \
set -e
- if ! grep -q ${BUILDCHROOT_DIR}/isar-apt /proc/mounts; then \
- mount --bind ${DEPLOY_DIR_APT}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt; \
- mount --bind ${DL_DIR} ${BUILDCHROOT_DIR}/downloads; \
- mount -t devtmpfs -o mode=0755,nosuid devtmpfs ${BUILDCHROOT_DIR}/dev; \
- mount -t proc none ${BUILDCHROOT_DIR}/proc; \
+ if ! grep -q ${BUILDCHROOT_DIR}/isar-apt /proc/mounts; then
+ mount --bind ${DEPLOY_DIR_APT}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt
+ mount --bind ${DL_DIR} ${BUILDCHROOT_DIR}/downloads
+ mount -t devtmpfs -o mode=0755,nosuid devtmpfs ${BUILDCHROOT_DIR}/dev
+ mount -t proc none ${BUILDCHROOT_DIR}/proc
fi'
dpkg_runbuild
--
2.16.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] Fail under flock & cleanups
2018-08-12 8:33 [PATCH 0/3] Fail under flock & cleanups Jan Kiszka
` (2 preceding siblings ...)
2018-08-12 8:33 ` [PATCH 3/3] dpkg-base: Reformat flock-protected commands Jan Kiszka
@ 2018-08-13 8:35 ` Henning Schild
2018-08-14 10:31 ` Maxim Yu. Osipov
4 siblings, 0 replies; 6+ messages in thread
From: Henning Schild @ 2018-08-13 8:35 UTC (permalink / raw)
To: Jan Kiszka; +Cc: isar-users
Ok, forget what i commented before. Seems like Jan fixed it in this
series.
Henning
Am Sun, 12 Aug 2018 10:33:35 +0200
schrieb "Jan Kiszka" <jan.kiszka@siemens.com>:
> This replaces and enhances "isar-bootstrap: exit if command fails
> under flock" and adds some smaller cleanups to that code paths.
>
> Jan
>
> Jan Kiszka (3):
> Exit if commands fail under flock
> isar-bootstrap: Remove redundant sudos
> dpkg-base: Reformat flock-protected commands
>
> meta/classes/dpkg-base.bbclass | 11 +--
> .../recipes-core/isar-bootstrap/isar-bootstrap.inc | 85
> +++++++++++----------- 2 files changed, 49 insertions(+), 47
> deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] Fail under flock & cleanups
2018-08-12 8:33 [PATCH 0/3] Fail under flock & cleanups Jan Kiszka
` (3 preceding siblings ...)
2018-08-13 8:35 ` [PATCH 0/3] Fail under flock & cleanups Henning Schild
@ 2018-08-14 10:31 ` Maxim Yu. Osipov
4 siblings, 0 replies; 6+ messages in thread
From: Maxim Yu. Osipov @ 2018-08-14 10:31 UTC (permalink / raw)
To: Jan Kiszka, isar-users
On 08/12/2018 11:33 AM, Jan Kiszka wrote:
> This replaces and enhances "isar-bootstrap: exit if command fails under
> flock" and adds some smaller cleanups to that code paths.
Applied to the 'next'.
Thanks,
Maxim.
> Jan
>
> Jan Kiszka (3):
> Exit if commands fail under flock
> isar-bootstrap: Remove redundant sudos
> dpkg-base: Reformat flock-protected commands
>
> meta/classes/dpkg-base.bbclass | 11 +--
> .../recipes-core/isar-bootstrap/isar-bootstrap.inc | 85 +++++++++++-----------
> 2 files changed, 49 insertions(+), 47 deletions(-)
>
--
Maxim Osipov
ilbers GmbH
Maria-Merian-Str. 8
85521 Ottobrunn
Germany
+49 (151) 6517 6917
mosipov@ilbers.de
http://ilbers.de/
Commercial register Munich, HRB 214197
General Manager: Baurzhan Ismagulov
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-08-14 10:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-12 8:33 [PATCH 0/3] Fail under flock & cleanups Jan Kiszka
2018-08-12 8:33 ` [PATCH 1/3] Exit if commands fail under flock Jan Kiszka
2018-08-12 8:33 ` [PATCH 2/3] isar-bootstrap: Remove redundant sudos Jan Kiszka
2018-08-12 8:33 ` [PATCH 3/3] dpkg-base: Reformat flock-protected commands Jan Kiszka
2018-08-13 8:35 ` [PATCH 0/3] Fail under flock & cleanups Henning Schild
2018-08-14 10:31 ` Maxim Yu. Osipov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox