osbuilder: Allow running the tool several times

Once the ${ROOTFS_DIR} is created, the tool can't run the second
time since the directory is populated and the debootstrap tool
will fail.

Fix by deleting the contents of ${ROOTFS_DIR} if the directory exists.
Note that running make clean will also allow the re-run, it
is only an optimization for some cases the build fails in the middle.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
This commit is contained in:
Marcel Apfelbaum 2021-08-25 19:49:14 +00:00
parent a4214738b9
commit 65a1e13195

View File

@ -326,7 +326,11 @@ build_rootfs_distro()
trap error_handler ERR
fi
mkdir -p ${ROOTFS_DIR}
if [ -d "${ROOTFS_DIR}" ] && [ "${ROOTFS_DIR}" != "/" ]; then
rm -rf "${ROOTFS_DIR}"/*
else
mkdir -p ${ROOTFS_DIR}
fi
# need to detect rustc's version too?
detect_rust_version ||