From 65a1e13195817cb84498153e4371924ee8faa66c Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Wed, 25 Aug 2021 19:49:14 +0000 Subject: [PATCH] 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 --- tools/osbuilder/rootfs-builder/rootfs.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/osbuilder/rootfs-builder/rootfs.sh b/tools/osbuilder/rootfs-builder/rootfs.sh index c058c257a..b63567ad5 100755 --- a/tools/osbuilder/rootfs-builder/rootfs.sh +++ b/tools/osbuilder/rootfs-builder/rootfs.sh @@ -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 ||