Re: [PATCH 1/2] configure: Add 'mkdir build' check

2023-02-16 Thread Peter Maydell
On Wed, 8 Feb 2023 at 23:32, Dinah Baum  wrote:
>
> QEMU configure script goes into an infinite error printing loop
> when in read only directory due to 'build' dir never being created.
>
> Checking if 'mkdir dir' succeeds prevents this error.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/321

This commit message needs your Signed-off-by: line on it. This is how
you say that you're legally OK to put the change into QEMU and that
you're happy for it to happen; the details are at
https://www.qemu.org/docs/master/devel/submitting-a-patch.html#patch-emails-must-include-a-signed-off-by-line

It's just a line
Signed-off-by: Your Name 

> ---
>  configure | 15 ++-
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/configure b/configure
> index 64960c6000..3b384914ce 100755
> --- a/configure
> +++ b/configure
> @@ -31,10 +31,11 @@ then
>  fi
>  fi
>
> -mkdir build
> -touch $MARKER
> +if mkdir build
> +then
> +touch $MARKER
>
> -cat > GNUmakefile <<'EOF'
> +cat > GNUmakefile <<'EOF'
>  # This file is auto-generated by configure to support in-source tree
>  # 'make' command invocation
>
> @@ -56,8 +57,12 @@ force: ;
>  GNUmakefile: ;
>
>  EOF
> -cd build
> -exec "$source_path/configure" "$@"
> +cd build
> +exec "$source_path/configure" "$@"
> +else
> +echo "ERROR: Unable to use ./build dir, try using a 
> ../qemu/configure build"
> +exit 1
> +fi
>  fi

Hi; I think that because the "happy path" inside this if..then is
quite large, we can make the code more readable by reversing the
sense of the condition and putting the error exit early, like this:

if ! mkdir build || ! touch $MARKER ; then
   echo "ERROR ..."
   exit 1
fi

cat > GNUmakefile <<'EOF'
etc etc as before

I'm also going to suggest a tweak to the error text:

   "ERROR: Could not create ./build directory. Check the permissions on
your source directory, or try doing an out-of-tree build."

thanks
-- PMM



Re: [PATCH 1/2] configure: Add 'mkdir build' check

2023-02-15 Thread Dinah B
*ping*

Patch series:
https://lore.kernel.org/qemu-devel/20230208233111.398577-1-dinahbaum...@gmail.com/

-Dinah

On Wed, Feb 8, 2023 at 6:31 PM Dinah Baum  wrote:

> QEMU configure script goes into an infinite error printing loop
> when in read only directory due to 'build' dir never being created.
>
> Checking if 'mkdir dir' succeeds prevents this error.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/321
> ---
>  configure | 15 ++-
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/configure b/configure
> index 64960c6000..3b384914ce 100755
> --- a/configure
> +++ b/configure
> @@ -31,10 +31,11 @@ then
>  fi
>  fi
>
> -mkdir build
> -touch $MARKER
> +if mkdir build
> +then
> +touch $MARKER
>
> -cat > GNUmakefile <<'EOF'
> +cat > GNUmakefile <<'EOF'
>  # This file is auto-generated by configure to support in-source tree
>  # 'make' command invocation
>
> @@ -56,8 +57,12 @@ force: ;
>  GNUmakefile: ;
>
>  EOF
> -cd build
> -exec "$source_path/configure" "$@"
> +cd build
> +exec "$source_path/configure" "$@"
> +else
> +echo "ERROR: Unable to use ./build dir, try using a
> ../qemu/configure build"
> +exit 1
> +fi
>  fi
>
>  # Temporary directory used for files created while
> --
> 2.30.2
>
>


[PATCH 1/2] configure: Add 'mkdir build' check

2023-02-08 Thread Dinah Baum
QEMU configure script goes into an infinite error printing loop
when in read only directory due to 'build' dir never being created.

Checking if 'mkdir dir' succeeds prevents this error.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/321
---
 configure | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 64960c6000..3b384914ce 100755
--- a/configure
+++ b/configure
@@ -31,10 +31,11 @@ then
 fi
 fi
 
-mkdir build
-touch $MARKER
+if mkdir build
+then
+touch $MARKER
 
-cat > GNUmakefile <<'EOF'
+cat > GNUmakefile <<'EOF'
 # This file is auto-generated by configure to support in-source tree
 # 'make' command invocation
 
@@ -56,8 +57,12 @@ force: ;
 GNUmakefile: ;
 
 EOF
-cd build
-exec "$source_path/configure" "$@"
+cd build
+exec "$source_path/configure" "$@"
+else
+echo "ERROR: Unable to use ./build dir, try using a ../qemu/configure 
build"
+exit 1
+fi
 fi
 
 # Temporary directory used for files created while
-- 
2.30.2