From 19ee1b87c37accbcf51361c573a6ce11e48c4798 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 1 Dec 2015 14:13:23 +0000 Subject: [PATCH] Tidying --- src/freedombone-image | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/freedombone-image b/src/freedombone-image index 9b5bfbab..e048c668 100755 --- a/src/freedombone-image +++ b/src/freedombone-image @@ -177,6 +177,15 @@ if [ ! $PASSWORD ]; then PASSWORD="$(openssl rand -base64 10 | cut -c1-8)" fi +image_types=( bz2 img sig vdi qcow2 ) +for im in "${image_types[@]}" +do + no_of_files=$(ls -afq ${CURR_DIR}/${PROJECT_NAME}*.${im} | wc -l) + if (( no_of_files > 0 )); then + rm ${CURR_DIR}/${PROJECT_NAME}*.${im} + fi +done + rm $CURR_DIR/${PROJECT_NAME}*.img.bz2 rm $CURR_DIR/${PROJECT_NAME}*.img rm $CURR_DIR/${PROJECT_NAME}*.sig @@ -239,26 +248,14 @@ if [ ${#imgfiles[@]} -eq 0 ]; then exit 2 fi -no_of_files=$(ls -afq build/${PROJECT_NAME}*.bz2 | wc -l) -if (( no_of_files > 0 )); then - mv build/${PROJECT_NAME}*.bz2 ${CURR_DIR} -fi -no_of_files=$(ls -afq build/${PROJECT_NAME}*.img | wc -l) -if (( no_of_files > 0 )); then - mv build/${PROJECT_NAME}*.img ${CURR_DIR} -fi -no_of_files=$(ls -afq build/${PROJECT_NAME}*.sig | wc -l) -if (( no_of_files > 0 )); then - mv build/${PROJECT_NAME}*.sig ${CURR_DIR} -fi -no_of_files=$(ls -afq build/${PROJECT_NAME}*.vdi | wc -l) -if (( no_of_files > 0 )); then - mv build/${PROJECT_NAME}*.vdi ${CURR_DIR} -fi -no_of_files=$(ls -afq build/${PROJECT_NAME}*.qcow2 | wc -l) -if (( no_of_files > 0 )); then - mv build/${PROJECT_NAME}*.qcow2 ${CURR_DIR} -fi +# Move images to the current directory +for im in "${image_types[@]}" +do + no_of_files=$(ls -afq build/${PROJECT_NAME}*.${im} | wc -l) + if (( no_of_files > 0 )); then + mv build/${PROJECT_NAME}*.${im} ${CURR_DIR} + fi +done rm -rf ${BUILD_DIR}