buildman: Deal more nicely with invalid build-status file
authorSimon Glass <sjg@chromium.org>
Sat, 27 Apr 2019 01:02:23 +0000 (19:02 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 21 May 2019 23:33:23 +0000 (17:33 -0600)
The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. At present buildman dies with
an exception when using -s to check the build status. Fix this.

Seriesl-cc: trini

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/buildman/builder.py

index 6a6c83bf3368dfb48fa3a2a846d11002dcb45158..fbb236676c70c08acf9c57af9ef35442caec44a5 100644 (file)
@@ -673,7 +673,12 @@ class Builder:
         environment = {}
         if os.path.exists(done_file):
             with open(done_file, 'r') as fd:
-                return_code = int(fd.readline())
+                try:
+                    return_code = int(fd.readline())
+                except ValueError:
+                    # The file may be empty due to running out of disk space.
+                    # Try a rebuild
+                    return_code = 1
                 err_lines = []
                 err_file = self.GetErrFile(commit_upto, target)
                 if os.path.exists(err_file):