From 5238124f3b06ec059ad7fcdd37d9730177f870b0 Mon Sep 17 00:00:00 2001 From: Nils Freydank Date: Sun, 1 Oct 2023 18:50:24 +0200 Subject: [PATCH] Add more error handling --- build-image.sh | 9 +++++---- build-packages.sh | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/build-image.sh b/build-image.sh index 63bf7ab..b268535 100755 --- a/build-image.sh +++ b/build-image.sh @@ -59,11 +59,12 @@ _mkdir "${DISTFILES}" _mkdir "${BINPKG}" _mkdir "${LOGDIR}" -podman pull gentoo/stage3:amd64-nomultilib-systemd -podman build "${PODMAN_BUILD_ARGS[@]}" +podman pull gentoo/stage3:amd64-nomultilib-systemd || exit_err "Could not fetch the image." +podman build "${PODMAN_BUILD_ARGS[@]}" || exit_err "Build failed." # Update the tag 'latest'. -podman tag rm "${REGISTRY}:latest" -podman tag "${REGISTRY}:${VERSION}" "${REGISTRY}:latest" +podman tag rm "${REGISTRY}:latest" # Do not exit_err here. At least on first run + # there is no latest tag to delete. +podman tag "${REGISTRY}:${VERSION}" "${REGISTRY}:latest" || exit_err "Could not tag new image as 'latest'." # vim:fileencoding=utf-8:ts=4:syntax=bash:expandtab diff --git a/build-packages.sh b/build-packages.sh index 902a560..ace1f21 100755 --- a/build-packages.sh +++ b/build-packages.sh @@ -58,8 +58,9 @@ _mkdir "${LOGDIR}" podman run "${PODMAN_BUILD_ARGS[@]}" "${REGISTRY}:${VERSION}" \ bash -c "emerge --usepkg --newuse --keep-going --oneshot --deep --update @world \ && emerge @golang-rebuild @rust-rebuild \ - && eclean-pkg --deep" + && eclean-pkg --deep" \ + || exit_err "Could not build packages." -podman unshare chown -R "0:0" "${LOGDIR}" +podman unshare chown -R "0:0" "${LOGDIR}" || exit_err "Could not fix access right post build." # vim:fileencoding=utf-8:ts=4:syntax=bash:expandtab