summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorThiago Abdo2019-10-29 13:20:34 +0100
committerThiago Abdo2019-10-29 13:20:34 +0100
commit919a52e7878bd57a2b8dcc2ef946c66904b2375f (patch)
treef0c955f45cb395d26929816c13f8d4bfd4dae361 /Makefile
parentSafely remove targets (diff)
downloadpacker-templates-919a52e7878bd57a2b8dcc2ef946c66904b2375f.tar.gz
packer-templates-919a52e7878bd57a2b8dcc2ef946c66904b2375f.tar.xz
packer-templates-919a52e7878bd57a2b8dcc2ef946c66904b2375f.zip
When removing a target you should also remove the link to it
Signed-off-by: Thiago Abdo <tjabdo@inf.ufpr.br>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile9
1 files changed, 7 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 7486bc9..f662007 100644
--- a/Makefile
+++ b/Makefile
@@ -220,11 +220,16 @@ $(COMPRESSTARGETS):
# Safe removal of images
$(BASERMTARGETS):
rm/%: %/*.backinglock
- @rm -rf $(@)
+ $(eval BUILD_DIR := $(subst rm/,,$(@)))
+ @rm -rf $(BUILD_DIR)
$(PROVRMTARGETS):
rm/%: %/build/*.backinglock
- @rm -rf $(@)
+ $(eval BUILD_DIR := $(subst rm/,,$(@))/build)
+ $(eval FATHER_BUILD := $(dir $(shell qemu-img info $(BUILD_DIR)/rootfs-image | grep "backing file" | cut -d\ -f3-)))
+ $(eval BUILD_TIME := $(subst .,,$(suffix $(@))))
+ @rm -rf $(FATHER_BUILD)/$(BUILD_TIME).backinglock
+ @rm -rf $(BUILD_DIR)
%.backinglock: backinglock
@qemu-img convert -f qcow2 $(@)/build/rootfs-image -O qcow2 $(@)/build/rootfs-image.tmp