Skip to contentSkip to conversation

configure: Add 'mkdir build' check

PATCH In review Dinah Baum 3 participants 3 messages Feb 21, 2023

lore
Share & tools
lore

Dinah Baum

author
#0 lore raw

PATCH v4 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

---
 configure | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
configure +6 -1
index cf6db3d551..1ef3e7f77d 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"
+        echo "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 v4 1/1
#1 lore raw
Quoted 18 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

---
  configure | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
configure +0 -0
index cf6db3d551..1ef3e7f77d 100755
@@ -31,7 +31,12 @@ then
          fi

configure then · line 40

Quoted 10 lines
configure +6 -1
      fi
 
-    mkdir build
+    if ! mkdir build || ! touch $MARKER
+    then
+        echo "ERROR: Could not create ./build directory. Check the permissions on"
+        echo "your source directory, or try doing an out-of-tree build."
+        exit 1
+    fi
      touch $MARKER

Nit: I think the final "touch $MARKER" could now be removed, too, since the code either exits above, or runs the "|| ! touch $MARKER" part there already.

Anyway, it's just a nit, and maybe could also be fixed while picking up the patch, thus:

#2 lore raw
Quoted 32 lines · Thomas Huth
Quoted 20 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

---
  configure | 7 ++++++-

  1 file changed, 6 insertions(+), 1 deletion(-)
configure +0 -0
index cf6db3d551..1ef3e7f77d 100755
@@ -31,7 +31,12 @@ then

          fi
      fi
-    mkdir build

Quoted 8 lines

+    if ! mkdir build || ! touch $MARKER
+    then
+        echo "ERROR: Could not create ./build directory. Check the permissions on"
+        echo "your source directory, or try doing an out-of-tree build." +        exit 1
+    fi
      touch $MARKER

Nit: I think the final "touch $MARKER" could now be removed, too, since the code either exits above, or runs the "|| ! touch $MARKER" part there already.

Quoted 1 line

Anyway, it's just a nit, and maybe could also be fixed while picking up the patch,

Yes please :)

Quoted 5 lines

thus: