[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] configure: Add 'mkdir build' check
From: |
Peter Maydell |
Subject: |
Re: [PATCH 1/2] configure: Add 'mkdir build' check |
Date: |
Thu, 16 Feb 2023 14:21:02 +0000 |
On Wed, 8 Feb 2023 at 23:32, 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
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 <your@email>
> ---
> 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