From 91a035965b641a2b3b6c353b9acd9091c5917204 Mon Sep 17 00:00:00 2001 From: Jonatan Schlag Date: Thu, 15 Nov 2018 13:35:58 +0000 Subject: [PATCH] Refactor cleanup. All stuffs now is located inside the working dir so we just need to delete this dir in the end. Images are copied to the path were they should be published, so this dir contains nothing useful after build. Signed-off-by: Jonatan Schlag --- generate_image.sh | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/generate_image.sh b/generate_image.sh index c8f0a9d..13c8343 100755 --- a/generate_image.sh +++ b/generate_image.sh @@ -31,33 +31,15 @@ cleanup() { # Unmount image umount ${IMAGE_MOUNT_DIR} - # Drop image mount dir - if [ -d ${IMAGE_MOUNT_DIR} ]; then - rm -df ${IMAGE_MOUNT_DIR} - fi - # Remove partition from the kernel table. partx -d ${outlo}p1 # Remove loopback device losetup -d ${outlo} - # Drop local repository. - if [ -d "${LOCAL_REPO_DIR}" ]; then - rm -dfR "${LOCAL_REPO_DIR}" - fi - - # Drop local repository file. - if [ -f "${LOCAL_REPO_FILE}" ]; then - rm -dfR "${LOCAL_REPO_FILE}" - fi -} - -cleanup_after_failure () { - cleanup - - if [ -f ${IMAGE_BASE_FILE} ]; then - rm -f ${IMAGE_BASE_FILE} + # Drop working dir + if [ -d "${WORKING_DIR}" ]; then + rm -dfR "${WORKING_DIR}" fi } @@ -377,7 +359,7 @@ if [ "${USE_LOCAL_REPO}" == "True" ]; then # Master repository. if ! pakfire-server repo create ${LOCAL_REPO_DIR} ${LOCAL_REPO_SOURCE_PATH}; then log ERROR "Failed to create a local respository" - cleanup_after_failure + cleanup exit 1 fi -- 2.39.2