Skip to contentSkip to conversation

Makefile: avoid leaving the temporary QEMU_PKGVERSION header file

PATCH In review Lin Ma 2 participants 2 messages Feb 15, 2017 Kbuild

lore
Share & tools
lore

Lin Ma

author
#0 lore raw

PATCH v3 1/1 Makefile: avoid leaving the temporary QEMU_PKGVERSION header file

By commit 67a1de0d, When we perform 'git pull && make && sudo make install', In 'make' stage a qemu-version.h.tmp will be generated. If the content of qemu-version.h.tmp and qemu-version.h aren't consistent, The qemu-version.h.tmp will be renamed to qemu-version.h. Because of the target FORCE, The same action will be do again in 'make install' stage.

In 'make install' stage, If there is no qemu-version.h.tmp exists and we run 'make install' with sudo, The owner and group of new qemu-version.h.tmp will be privileged user/group. When we run 'make' next time, qemu-version.h.tmp can't be overwritten because of permission issue.

This patch removed qemu-version.h.tmp after build to fix this issue.

---
 Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Makefile +5 -1
index b993741..830fa5a 100644
@@ -299,7 +299,11 @@ qemu-version.h: FORCE
 				printf '""\n'; \
 			fi; \
 		fi) > [email protected])
-	$(call quiet-command, cmp -s $@ [email protected] || mv [email protected] $@)
+	$(call quiet-command, if ! cmp -s $@ [email protected]; then \
+	  mv [email protected] $@; \
+	 else \
+	  rm [email protected]; \
+	 fi)
 
 config-host.h: config-host.h-timestamp
 config-host.h-timestamp: config-host.mak
Signature · 1 line
2.9.2
Reviewed-by on v3 1/1
#1 lore raw
Quoted 38 lines · Lin Ma

By commit 67a1de0d, When we perform 'git pull && make && sudo make install', In 'make' stage a qemu-version.h.tmp will be generated. If the content of qemu-version.h.tmp and qemu-version.h aren't consistent, The qemu-version.h.tmp will be renamed to qemu-version.h. Because of the target FORCE, The same action will be do again in 'make install' stage.

In 'make install' stage, If there is no qemu-version.h.tmp exists and we run 'make install' with sudo, The owner and group of new qemu-version.h.tmp will be privileged user/group. When we run 'make' next time, qemu-version.h.tmp can't be overwritten because of permission issue.

This patch removed qemu-version.h.tmp after build to fix this issue.

---
 Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Makefile +5 -1
index b993741..830fa5a 100644
@@ -299,7 +299,11 @@ qemu-version.h: FORCE
 				printf '""\n'; \
 			fi; \
 		fi) > [email protected])
-	$(call quiet-command, cmp -s $@ [email protected] || mv [email protected] $@)
+	$(call quiet-command, if ! cmp -s $@ [email protected]; then \
+	  mv [email protected] $@; \
+	 else \
+	  rm [email protected]; \
+	 fi)
 
 config-host.h: config-host.h-timestamp
 config-host.h-timestamp: config-host.mak
Signature · 1 line
2.9.2