Skip to content

Commit

Permalink
Use mktemp when generating the archive
Browse files Browse the repository at this point in the history
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à <[email protected]>
  • Loading branch information
mssola committed Nov 27, 2024
1 parent b0ea42e commit 45fa70a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)"

##
Expand All @@ -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:
Expand Down

0 comments on commit 45fa70a

Please sign in to comment.