diff --git a/README.md b/README.md index 1074695c..5426fd10 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,11 @@ It's a colon (:) separated path list, and it will work in a first path/element f first served approach. The included elements tree is used when no path is supplied, and is added to the end of the path if a path is supplied. +By default, the image building scripts will not overwrite existing disk images, +allowing you to compare the newly built image with the existing one. To change +that behaviour, set the variable OVERWRITE\_OLD\_IMAGE to any value that isn't +0. + Requirements ============ diff --git a/lib/common-functions b/lib/common-functions index c9efe893..ab4801d0 100644 --- a/lib/common-functions +++ b/lib/common-functions @@ -43,9 +43,9 @@ function mk_build_dir () { } function finish_image () { - if [ -f $1 ]; then + if [ -f $1 -a ${OVERWRITE_OLD_IMAGE:-0} -eq 0 ]; then old_image="${1%.*}"-$(date +%Y.%m.%d-%H.%M.%S).${1##*.} - echo "Old image is found. Renaming it to $old_image" + echo "Old image found. Renaming it to $old_image" mv "$1" "$old_image" fi @@ -57,17 +57,7 @@ function finish_image () { } function save_image () { - if [ -f $1 ] ; then - old_image="${1%.*}"-$(date +%Y.%m.%d-%H.%M.%S).${1##*.} - echo "Old image is found. Renaming it to $old_image" - mv "$1" "$old_image" - fi - - cp $TMP_IMAGE_PATH $1 - cleanup_dirs - # All done! - trap EXIT - echo "Image file $1 created..." + finish_image $1 } function element_pre_check() {