From b8fc106ca8d173ffb5b24748184626f4c6373e06 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Mon, 30 Sep 2013 22:56:19 +0000 Subject: [PATCH] Write files atomically in the microcode makefile. Use a temporary file and rename it over the permanent one only if the command succeeded. That way, we don't leave truncated files around on failure. --- src/microcode/makegen/Makefile.in.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/microcode/makegen/Makefile.in.in b/src/microcode/makegen/Makefile.in.in index 94a89d14f..2cf602cda 100644 --- a/src/microcode/makegen/Makefile.in.in +++ b/src/microcode/makegen/Makefile.in.in @@ -161,7 +161,8 @@ MAINTAINER_CLEAN_FILES = Makefile.in Makefile.deps liarc-vars liarc-rules \ $(COMPILE) -o $@ -c $< .m4.s: - $(EXPAND) $< > $@ + -rm -f $@.tmp + $(EXPAND) $< > $@.tmp && mv -f $@.tmp $@ .s.o: $(ASSEMBLE) -o $@ $< @@ -175,8 +176,8 @@ scheme: $(scheme_OBJECTS) $(scheme_DEPENDENCIES) $(LINK) $(scheme_LDFLAGS) $(scheme_OBJECTS) $(scheme_LIBS) usrdef.c: $(STD_SOURCES) findprim Makefile - -rm -f $@ - ./findprim $(STD_SOURCES) > usrdef.c + -rm -f $@.tmp + ./findprim $(STD_SOURCES) > $@.tmp && mv -f $@.tmp $@ findprim: $(findprim_OBJECTS) $(findprim_DEPENDENCIES) -rm -f $@ -- 2.25.1