diff mbox

build: don't create temporary files in source dir

Message ID 20171026130656.31067-1-berrange@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel P. Berrangé Oct. 26, 2017, 1:06 p.m. UTC
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.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 scripts/git-submodule.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Alexey Kardashevskiy Oct. 27, 2017, 4:06 a.m. UTC | #1
On 27/10/17 00:06, Daniel P. Berrange wrote:
> 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.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  scripts/git-submodule.sh | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh
> index c66567d409..586ff32293 100755
> --- a/scripts/git-submodule.sh
> +++ b/scripts/git-submodule.sh
> @@ -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.


> -    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)
>
diff mbox

Patch

diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh
index c66567d409..586ff32293 100755
--- a/scripts/git-submodule.sh
+++ b/scripts/git-submodule.sh
@@ -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)