summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@chromium.org>2021-05-28 03:45:43 -0400
committerCommit Bot <commit-bot@chromium.org>2021-06-04 14:36:10 +0000
commit85e5e9dcf2dca0f3589161ad231b0d4053102c05 (patch)
tree2a82ad1fd081ed48bcdabedb32475da9e97e67db
parentb38e3a63a8b1d42fd707e4c23e71c3f3ed84e6ad (diff)
downloadvboot-85e5e9dcf2dca0f3589161ad231b0d4053102c05.tar.gz
image_signing: simplify & fix mount cleanups
We don't need all this infrastructure for arbitrary cleanups when we only ever run 2 clean up steps. This also fixes a subtle bug in the old logic: we registered cleanups in the logical order of (1) mounts and then (2) loopbacks, but the cleanup loop walks the registered calls in reverse order. This means the loopback cleanup would fail and timeout because we hadn't unmounted the partitions yet. The overall script doesn't fail as cleanup uses `set +e`, but it makes every script waste ~10 seconds at exit. BUG=None TEST=running set_lsb_release.sh on images works quickly now BRANCH=None Change-Id: Ibd25ad6ba149c64e08ac3ab860342fe7b2cc7851 Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2923825 Reviewed-by: George Engelbrecht <engeg@google.com>
-rw-r--r--scripts/image_signing/common.sh27
1 files changed, 2 insertions, 25 deletions
diff --git a/scripts/image_signing/common.sh b/scripts/image_signing/common.sh
index 9541ca08..efa00a20 100644
--- a/scripts/image_signing/common.sh
+++ b/scripts/image_signing/common.sh
@@ -10,25 +10,6 @@
. "$(dirname "$0")/common_minimal.sh"
CROS_LOG_PREFIX="${PROG}: "
-# Array of actions that are executed during the clean up process.
-declare -a cleanup_actions
-
-# Adds an action to be executed during the clean up process.
-# Actions are executed in the reverse order of when they were added.
-# ARGS: ACTION
-add_cleanup_action() {
- cleanup_actions[${#cleanup_actions[*]}]=$1
-}
-
-# Performs the latest clean up action and removes it from the list.
-perform_latest_cleanup_action() {
- local num_actions=${#cleanup_actions[*]}
- if [ "${num_actions}" -gt 0 ]; then
- eval "${cleanup_actions[$num_actions-1]} || true" > /dev/null 2>&1
- unset "cleanup_actions[$num_actions-1]"
- fi
-}
-
# Performs clean up by executing actions in the cleanup_actions array in
# reversed order.
cleanup() {
@@ -36,9 +17,8 @@ cleanup() {
rv=$?
set +e
- while [ ${#cleanup_actions[*]} -gt 0 ]; do
- perform_latest_cleanup_action
- done
+ cleanup_temps_and_mounts
+ cleanup_loopbacks
set -e
return $rv
@@ -158,6 +138,3 @@ restore_lsb_selinux() {
# This will override the trap set in common_minmal.sh
trap "cleanup" INT TERM EXIT
-
-add_cleanup_action "cleanup_temps_and_mounts"
-add_cleanup_action "cleanup_loopbacks"