Skip to contentSkip to conversation

build: don't create temporary files in source dir

PATCH In review Daniel P. Berrange 2 participants 2 messages Oct 26, 2017 – Oct 27, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: don't create temporary files in source dir

There are cases where users do VPATH builds with the source directory being on a read-only volume. In such a case they have to manually run the command 'git-submodule.sh ...modules...' manually ahead of time. When checking for status we should not then write into the source dir.

---
 scripts/git-submodule.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
scripts/git-submodule.sh +4 -4
index c66567d409..586ff32293 100755
@@ -31,10 +31,10 @@ fi
 case "$command" in
 status)
     test -f "$substat" || exit 1
-    trap "rm -f ${substat}.tmp" EXIT
-    $GIT submodule status $modules > "${substat}.tmp"
-    test $? -ne 0 && error "failed to query git submodule status"
-    diff "${substat}" "${substat}.tmp" >/dev/null
+    substat_tmp=$(mktemp)
+    trap "rm -f ${substat_tmp}" EXIT
+    $GIT submodule status $modules > "${substat_tmp}"
+    diff "${substat}" "${substat_tmp}" >/dev/null
     exit $?
     ;;
 update)
Signature · 1 line
2.13.6
#1 lore raw
Quoted 15 lines · Daniel P. Berrange

There are cases where users do VPATH builds with the source directory being on a read-only volume. In such a case they have to manually run the command 'git-submodule.sh ...modules...' manually ahead of time. When checking for status we should not then write into the source dir.

---
 scripts/git-submodule.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
scripts/git-submodule.sh +0 -0
index c66567d409..586ff32293 100755

scripts/git-submodule.sh fi · line 36

Quoted 6 lines
scripts/git-submodule.sh +0 -3
@@ -31,10 +31,10 @@ fi
 case "$command" in
 status)
     test -f "$substat" || exit 1
-    trap "rm -f ${substat}.tmp" EXIT
-    $GIT submodule status $modules > "${substat}.tmp"
-    test $? -ne 0 && error "failed to query git submodule status"

This does not apply on any public tree, the error message and $GIT are missing.

Quoted 9 lines
scripts/git-submodule.sh +4 -1
-    diff "${substat}" "${substat}.tmp" >/dev/null
+    substat_tmp=$(mktemp)
+    trap "rm -f ${substat_tmp}" EXIT
+    $GIT submodule status $modules > "${substat_tmp}"
+    diff "${substat}" "${substat_tmp}" >/dev/null
     exit $?
     ;;
 update)
Signature · 1 line
Alexey