[PATCH v3] configure: Add 'mkdir build' check

Dinah Baum posted 1 patch 1 year, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230217204007.371525-1-dinahbaum123@gmail.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Thomas Huth <thuth@redhat.com>
There is a newer version of this series
configure | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
[PATCH v3] configure: Add 'mkdir build' check
Posted by Dinah Baum 1 year, 2 months ago
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
Signed-off-by: Dinah Baum <dinahbaum123@gmail.com>
---
Changes since v2:
Updated error message
Reverted changes to 'help' command

 configure | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 00415f0b48..784f9d18a5 100755
--- a/configure
+++ b/configure
@@ -31,7 +31,12 @@ then
         fi
     fi
 
-    mkdir build
+    if ! mkdir build || ! touch $MARKER
+    then
+        echo "ERROR: Could not create ./build directory. Check the permissions on
+            your source directory, or try doing an out-of-tree build."
+        exit 1
+    fi
     touch $MARKER
 
     cat > GNUmakefile <<'EOF'
-- 
2.30.2
Re: [PATCH v3] configure: Add 'mkdir build' check
Posted by Peter Maydell 1 year, 2 months ago
On Fri, 17 Feb 2023 at 20:41, Dinah Baum <dinahbaum123@gmail.com> 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
> Signed-off-by: Dinah Baum <dinahbaum123@gmail.com>
> ---
> Changes since v2:
> Updated error message
> Reverted changes to 'help' command
>
>  configure | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 00415f0b48..784f9d18a5 100755
> --- a/configure
> +++ b/configure
> @@ -31,7 +31,12 @@ then
>          fi
>      fi
>
> -    mkdir build
> +    if ! mkdir build || ! touch $MARKER
> +    then
> +        echo "ERROR: Could not create ./build directory. Check the permissions on
> +            your source directory, or try doing an out-of-tree build."

This works, but the second line ends up a bit oddly indented in
the output (because the indent in the source file at the start
of the second line gets output verbatim). Using a second 'echo'
command for the second line is the easiest way to fix that.

If you fix that and resend this patch, then you can put

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

in the commit message under your signed-off-by line.

thanks
-- PMM