[elbe-devel] [PATCH v5 3/5] archivedir: move archive_tmpfile to archivedir

Akash Satamkar akash at linutronix.de
Mon Sep 23 16:16:14 CEST 2019


Move the archive_tmpfile function from elbexml to archivedir.
No use of self parameter in archive_tmpfile.

Signed-off-by: Akash Satamkar <akash at linutronix.de>
---
 elbepack/archivedir.py | 9 +++++++++
 elbepack/dump.py       | 3 ++-
 elbepack/elbexml.py    | 9 ---------
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/elbepack/archivedir.py b/elbepack/archivedir.py
index 10155228..bacbdf25 100644
--- a/elbepack/archivedir.py
+++ b/elbepack/archivedir.py
@@ -16,6 +16,7 @@ except ImportError:
 from base64 import standard_b64encode
 from bz2 import compress as bz2compress
 from subprocess import CalledProcessError
+from tempfile import NamedTemporaryFile
 
 from elbepack.treeutils import etree
 from elbepack.shellhelper import system
@@ -67,6 +68,14 @@ def chg_archive(xml, path, keep):
 
     return xml
 
+
+def archive_tmpfile(arch_elem):
+    fp = NamedTemporaryFile()
+    fp.write(standard_b64decode(arch_elem))
+    fp.file.flush()
+    return fp
+
+
 def prepare_path(url):
     url = urlparse(url)
     path = url.geturl().replace("%s://"%url.scheme, '', 1)
diff --git a/elbepack/dump.py b/elbepack/dump.py
index 4642ae92..a7eb4011 100644
--- a/elbepack/dump.py
+++ b/elbepack/dump.py
@@ -11,6 +11,7 @@ from datetime import datetime
 
 from apt import Cache
 
+from elbepack.archivedir import archive_tmpfile
 from elbepack.finetuning import do_finetuning
 from elbepack.filesystem import hostfs
 from elbepack.version import elbe_version
@@ -195,7 +196,7 @@ def elbe_report(xml, buildenv, cache, targetfs):
     report.info("Archive extract")
 
     if xml.has("archive") and not xml.text("archive") is None:
-        with xml.archive_tmpfile() as fp:
+        with archive_tmpfile(xml.text("archive")) as fp:
             do('tar xvfj "%s" -h -C "%s"' % (fp.name, targetfs.path))
         mt_index_postarch = targetfs.mtime_snap()
     else:
diff --git a/elbepack/elbexml.py b/elbepack/elbexml.py
index 5972600c..2dd5c0f4 100644
--- a/elbepack/elbexml.py
+++ b/elbepack/elbexml.py
@@ -12,9 +12,6 @@ import os
 import re
 import urllib2
 
-from base64 import standard_b64decode
-from tempfile import NamedTemporaryFile
-
 from elbepack.treeutils import etree
 from elbepack.validate import validate_xml
 from elbepack.xmldefaults import ElbeDefaults
@@ -364,12 +361,6 @@ class ElbeXML(object):
     def append_initvm_pkg(self, aptpkg):
         self.append_pkg(aptpkg, 'initvmpkgs')
 
-    def archive_tmpfile(self):
-        fp = NamedTemporaryFile()
-        fp.write(standard_b64decode(self.text("archive")))
-        fp.file.flush()
-        return fp
-
     def get_debootstrappkgs_from(self, other):
         tree = self.xml.ensure_child('debootstrappkgs')
         tree.clear()
-- 
2.20.1




More information about the elbe-devel mailing list