Allow overwriting old images
The two duplicated functions, save_image and finish_image will move an existing image out of the way if it exists, but it isn't configurable. Check an environment variable is 0 before doing so. Switch save_image to just calling finish_image, rather than duplicating its code exactly. Change-Id: I26a5a8fa4b6e853c9440bffab195b0bc3728be40
This commit is contained in:
parent
3cdfd9565e
commit
84b2ac45de
@ -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
|
||||
============
|
||||
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user