From 2fdb758f6be0ee3b8dd550fc8f7cce712b7105dc Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Thu, 26 May 2016 16:59:15 +1000 Subject: [PATCH] BUG: repeated failing makes could generate bad output. This is a quick fix to address two issues: * Firstly, if the mec-tools mec_encrypt binary cannot be compiled, gcc still produces an output file - it is a non executable "precompiled header" file. I assume there is a bug in the mec-tools makefile logic, which I will look for later. * Secondly, because I am using stdout for file generation, many commands will still produce an output file even when they fail. This output file then looks "good" to the make command, which will carry on to do the next step. Since fixing the failed commands in my Makefile makes things more robust in general, it also avoids the compile issue with the mec-tools. --- .gitignore | 3 +++ Makefile | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index fce6977..f964ec6 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ # ignore generated files *.bat + +# Temp are (should be) just junk +*.tmp diff --git a/Makefile b/Makefile index e4c3fe2..079a123 100644 --- a/Makefile +++ b/Makefile @@ -95,10 +95,12 @@ DEPSDIR := .d $(shell mkdir -p $(DEPSDIR)) -include $(DEPSDIR)/slice.extract.deps $(DEPSDIR)/slice.extract.deps: Makefile - for i in *.slice; do read SLICEE other <$$i; echo $$i: $$SLICEE; done >$@ + for i in *.slice; do read SLICEE other <$$i; echo $$i: $$SLICEE; done >$@.tmp + mv $@.tmp $@ -include $(DEPSDIR)/slice.insert.deps $(DEPSDIR)/slice.insert.deps: Makefile - for i in *.slice; do read SLICEE other <$$i; echo `basename $$SLICEE .orig`: $$i `basename $$i .slice`; done >$@ + for i in *.slice; do read SLICEE other <$$i; echo `basename $$SLICEE .orig`: $$i `basename $$i .slice`; done >$@.tmp + mv $@.tmp $@ # FIXME - the slice.deps targets basically do not handle add/del/change of # the *.slice files. I dont use any of the regular tricks because I also @@ -121,7 +123,8 @@ $(DEPSDIR)/slice.insert.deps: Makefile ./slice.extract $< $@ %.img.orig: %.img.enc.orig %.img.orig.sha1 mec-tools/mec_encrypt - mec-tools/mec_encrypt -d $< >$@ + mec-tools/mec_encrypt -d $< >$@.tmp + mv $@.tmp $@ sha1sum -c $@.sha1 # a generic encryptor @@ -147,7 +150,8 @@ $(DEPSDIR)/slice.insert.deps: Makefile # my mind to it.. # %.iso.bat: %.iso.orig %.iso.orig.desc autoexec.bat.template - sed -e "s%__DIR%`mdir -/ -b -i $<@@$(FAT_OFFSET) |grep FL2 |cut -d/ -f3`%; s%__FL2%`mdir -/ -b -i $<@@$(FAT_OFFSET) |grep FL2 |cut -d/ -f4`%; s%__DESC%`cat $<.desc`%" autoexec.bat.template >$@ + sed -e "s%__DIR%`mdir -/ -b -i $<@@$(FAT_OFFSET) |grep FL2 |cut -d/ -f3`%; s%__FL2%`mdir -/ -b -i $<@@$(FAT_OFFSET) |grep FL2 |cut -d/ -f4`%; s%__DESC%`cat $<.desc`%" autoexec.bat.template >$@.tmp + mv $@.tmp $@ # helper to write the ISO onto a cdrw %.iso.blank_burn: %.iso @@ -158,11 +162,13 @@ $(DEPSDIR)/slice.insert.deps: Makefile cp --reflink=auto $< $(basename $<) %.hex: % - hd -v $< >$@ + hd -v $< >$@.tmp + mv $@.tmp $@ # Generate a patch report %.diff: %.hex %.orig.hex - -diff -u $(basename $@).orig.hex $(basename $@).hex >$@ + -diff -u $(basename $@).orig.hex $(basename $@).hex >$@.tmp + mv $@.tmp $@ cat $@ # If we ever want a copy of the dosflash.exe, just get it from the iso image