From 45fa70a9c9892c980561785db323016e6080177d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Sabat=C3=A9=20Sol=C3=A0?= Date: Wed, 27 Nov 2024 16:30:00 +0100 Subject: [PATCH] Use mktemp when generating the archive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of manually making a temporary directory, do it through 'mktemp', which feels cleaner. Moreover, the base directory will now by named 'fbos' instead of the cryptic 'tmp' one. This is quite relevant when you uncompress the archive into another machine. Signed-off-by: Miquel Sabaté Solà --- Makefile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index bf27042..70000a1 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,6 @@ KRNL = fbos USR = usr/bin/init usr/bin/fizz usr/bin/buzz usr/bin/fizzbuzz INIT = usr/initramfs.cpio TESTS = test/test_dt test/test_initrd -TMP = tmp/ ARCHIVE = fbos.tar.gz LDFLAGS += -T $(LINKER) @@ -134,11 +133,10 @@ test/%: test/%.o .PHONY: archive archive: all - $(Q) rm -rf $(TMP) && mkdir -p $(TMP) - $(Q) cp -r usr/ $(TMP) && rm -r $(TMP)/usr/src - $(Q) cp $(KRNL) $(TMP) - $(Q) tar czf $(ARCHIVE) $(TMP) - $(Q) rm -rf $(TMP) + $(Q) $(eval DIR := $(shell mktemp -d)) + $(Q) mkdir -p $(DIR)/fbos && cp $(KRNL) $(INIT) $(DIR)/fbos/ + $(Q) cd $(DIR) && tar czf $(ARCHIVE) fbos/ + $(Q) cp $(DIR)/$(ARCHIVE) . $(E) " TAR $(ARCHIVE)" ## @@ -158,7 +156,7 @@ gdb: .PHONY: clean clean: - $(Q) rm -rf $(OBJ) $(KRNL) $(LINKER) $(USR) usr/src/*.o $(INIT) test/*.o test/lib/*.o $(TESTS) $(TMP) $(ARCHIVE) + $(Q) rm -rf $(OBJ) $(KRNL) $(LINKER) $(USR) usr/src/*.o $(INIT) test/*.o test/lib/*.o $(TESTS) $(ARCHIVE) .PHONY: lint lint: