[elbe-devel] [PATCH 2/3] validation file: fix archive validation overwrite

John Ogness john.ogness at linutronix.de
Fri Apr 27 01:43:06 CEST 2018


With 502442c7b ("dump: remove 2nd extract of archive") a new section
for validating the archive was introduced. This uses the ASCIIDocLog
class to append the new section. However, by default that class
creates a new file instead of appending.

Append to the validation file instead of re-creating it.

Rather than assume the ordering of check_full_pkgs() and
elbe_report(), change both functions to append and handle the
deletion of an old validation file separately.

Signed-off-by: John Ogness <john.ogness at linutronix.de>
---
 elbepack/dump.py        | 4 ++--
 elbepack/elbeproject.py | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/elbepack/dump.py b/elbepack/dump.py
index cd2aa490..e7a47e4f 100644
--- a/elbepack/dump.py
+++ b/elbepack/dump.py
@@ -80,7 +80,7 @@ def dump_initvmpkgs(xml):
 
 
 def check_full_pkgs(pkgs, fullpkgs, errorname, cache):
-    elog = ASCIIDocLog(errorname)
+    elog = ASCIIDocLog(errorname, True)
 
     elog.h1("ELBE Package validation")
     elog.h2("Package List validation")
@@ -292,7 +292,7 @@ def elbe_report(xml, buildenv, cache, reportname, errorname, targetfs):
     if not xml.has("archive") or xml.text("archive") is None:
         return
 
-    elog = ASCIIDocLog(errorname)
+    elog = ASCIIDocLog(errorname, True)
 
     elog.h2("Archive validation")
 
diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index 7ec1887d..9c1692eb 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -392,6 +392,11 @@ class ElbeProject (object):
                        self.log, self.get_rpcaptcache())
 
         validationpath = os.path.join(self.builddir, "validation.txt")
+        # The validation file is created using check_full_pkgs() and
+        # elbe_report(), both opening the file in append mode. So if an
+        # old validation file already exists, it must be deleted first.
+        if os.path.isfile(validationpath):
+            os.unlink(validationpath)
 
         # Package validation and package list
         if not skip_pkglist:
-- 
2.11.0




More information about the elbe-devel mailing list