Skip to contentSkip to conversation

configure: Add 'mkdir build' check

PATCH Superseded Dinah Baum 2 participants 2 messages Feb 17, 2023 – Feb 20, 2023

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Dinah Baum

author
#0 lore raw

PATCH v3 1/1 configure: Add 'mkdir build' check

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

---
Changes since v2:
Updated error message
Reverted changes to 'help' command

 configure | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
configure +6 -1
index 00415f0b48..784f9d18a5 100755
@@ -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'
Signature · 1 line
2.30.2
Reviewed-by on v3 1/1
#1 lore raw
Quoted 21 lines · 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

---
Changes since v2:
Updated error message
Reverted changes to 'help' command

 configure | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
configure +0 -0
index 00415f0b48..784f9d18a5 100755

configure then · line 37

Quoted 8 lines
configure +4 -1
@@ -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

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

thanks
-- PMM