Skip to contentSkip to conversation

sanity.bbclass: Check if /tmp is writable

PATCH New [email protected] 1 participant 1 message Jul 7, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 1/1 sanity.bbclass: Check if /tmp is writable

From: Mariano Lopez <[email protected]>

Used mkstemp instead of raw open file call.
Also added the exception message to the output of
the sanity check.

[YOCTO #7922]

---
 meta/classes/sanity.bbclass | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
meta/classes/sanity.bbclass +7 -6
index 7a580da..125cc4c 100644
@@ -707,15 +707,16 @@ def check_sanity_everybuild(status, d):
     # Check if /tmp is writable
     from string import ascii_letters
     from random import choice
-    filename = "bb_writetest.%s" % os.getpid()
-    testfile = os.path.join("/tmp", filename)
+    from tempfile import mkstemp
+    tmpfd, tmppath = mkstemp()
     try:
-        f = open(testfile, "w")
+        f = os.fdopen(tmpfd, "wt")
         f.write("".join(choice(ascii_letters) for x in range(1024)))
         f.close()
-        os.remove(testfile)
-    except:
-        status.addresult("Failed to write into /tmp. Please verify your filesystem.")
+    except Exception as err:
+        status.addresult("Failed to write into /tmp; %s. Please verify your filesystem." % err)
+    finally:
+        os.remove(tmppath)
 
     # Check that the DISTRO is valid, if set
     # need to take into account DISTRO renaming DISTRO
Signature · 1 line
1.8.4.5