[elbe-devel] [PATCH 24/32] Nuke ASCIIDocLog from efilesystem

dion at linutronix.de dion at linutronix.de
Fri Jun 14 22:13:38 CEST 2019


From: Olivier Dion <dion at linutronix.de>

Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 elbepack/commands/genlicence.py |  2 +-
 elbepack/efilesystem.py         | 30 +++++++++++++++---------------
 elbepack/elbeproject.py         | 19 +++++++++----------
 elbepack/filesystem.py          |  9 +++++----
 4 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/elbepack/commands/genlicence.py b/elbepack/commands/genlicence.py
index 1cdbf292..fdb4236b 100644
--- a/elbepack/commands/genlicence.py
+++ b/elbepack/commands/genlicence.py
@@ -39,5 +39,5 @@ def run_command(argv):
     else:
         f = io.open('licence.txt', "w+", encoding='utf-8')
 
-    rfs.write_licenses(f, log, opt.xml)
+    rfs.write_licenses(f, opt.xml)
     f.close()
diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
index 39335057..7e130d6b 100644
--- a/elbepack/efilesystem.py
+++ b/elbepack/efilesystem.py
@@ -13,13 +13,14 @@ import subprocess
 import io
 import stat
 
-from elbepack.asciidoclog import CommandError
 from elbepack.filesystem import Filesystem
 from elbepack.version import elbe_version
 from elbepack.hdimg import do_hdimg
 from elbepack.fstab import fstabentry
 from elbepack.licencexml import copyright_xml
 from elbepack.packers import default_packer
+from elbepack.log import log
+from elbepack.shellhelper import CommandError, do, chroot, get_command_out
 
 
 def copy_filelist(src, filelist, dst):
@@ -41,7 +42,7 @@ def copy_filelist(src, filelist, dst):
             shutil.copystat(src.fname(f), dst.fname(f))
 
 
-def extract_target(src, xml, dst, log, cache):
+def extract_target(src, xml, dst, cache):
 
     # pylint: disable=too-many-locals
     # pylint: disable=too-many-branches
@@ -102,19 +103,19 @@ def extract_target(src, xml, dst, log, cache):
             for item in pkglist:
                 f.write("%s  install\n" % item)
 
-        host_arch = log.get_command_out("dpkg --print-architecture").strip()
+        host_arch = get_command_out("dpkg --print-architecture").strip()
         if xml.is_cross(host_arch):
             ui = "/usr/share/elbe/qemu-elbe/" + str(xml.defs["userinterpr"])
             if not os.path.exists(ui):
                 ui = "/usr/bin/" + str(xml.defs["userinterpr"])
-            log.do('cp %s %s' % (ui, dst.fname("usr/bin")))
+            do('cp %s %s' % (ui, dst.fname("usr/bin")))
 
-        log.chroot(dst.path, "/usr/bin/dpkg --clear-selections")
-        log.chroot(
+        chroot(dst.path, "/usr/bin/dpkg --clear-selections")
+        chroot(
             dst.path,
             "/usr/bin/dpkg --set-selections < %s " %
             dst.fname(psel))
-        log.chroot(dst.path, "/usr/bin/dpkg --purge -a")
+        chroot(dst.path, "/usr/bin/dpkg --purge -a")
 
 
 class ElbeFilesystem(Filesystem):
@@ -136,15 +137,15 @@ class ElbeFilesystem(Filesystem):
         xml.xml.write(elbe_base)
         self.chmod("etc/elbe_base.xml", stat.S_IREAD)
 
-    def write_licenses(self, f, log, xml_fname=None):
+    def write_licenses(self, f, xml_fname=None):
         licence_xml = copyright_xml()
         for d in self.listdir("usr/share/doc/", skiplinks=True):
             try:
                 with io.open(os.path.join(d, "copyright"), "rb") as lic:
                     lic_text = lic.read()
             except IOError as e:
-                log.printo("Error while processing license file %s: '%s'" %
-                           (os.path.join(d, "copyright"), e.strerror))
+                log.error("Error while processing license file %s: '%s'" %
+                          (os.path.join(d, "copyright"), e.strerror))
                 lic_text = "Error while processing license file %s: '%s'" % (
                     os.path.join(d, "copyright"), e.strerror)
 
@@ -285,9 +286,8 @@ class ChRootFilesystem(ElbeFilesystem):
 
 
 class TargetFs(ChRootFilesystem):
-    def __init__(self, path, log, xml, clean=True):
+    def __init__(self, path, xml, clean=True):
         ChRootFilesystem.__init__(self, path, xml.defs["userinterpr"], clean)
-        self.log = log
         self.xml = xml
         self.images = []
         self.image_packers = {}
@@ -329,7 +329,7 @@ class TargetFs(ChRootFilesystem):
                     fname=targz_name,
                     sdir=self.fname('')
                 )
-                self.log.do(cmd % args)
+                do(cmd % args)
                 # only append filename if creating tarball was successful
                 self.images.append(targz_name)
             except CommandError:
@@ -341,7 +341,7 @@ class TargetFs(ChRootFilesystem):
             cpio_name = self.xml.text("target/package/cpio/name")
             os.chdir(self.fname(''))
             try:
-                self.log.do(
+                do(
                     "find . -print | cpio -ov -H newc >%s" %
                     os.path.join(
                         targetdir, cpio_name))
@@ -356,7 +356,7 @@ class TargetFs(ChRootFilesystem):
             sfs_name = self.xml.text("target/package/squashfs/name")
             os.chdir(self.fname(''))
             try:
-                self.log.do(
+                do(
                     "mksquashfs %s %s/%s -noappend -no-progress" %
                     (self.fname(''), targetdir, sfs_name))
                 # only append filename if creating mksquashfs was successful
diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index 0269a638..a4b25376 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -202,8 +202,8 @@ class ElbeProject (object):
 
         # Create TargetFs instance, if the target directory exists
         if os.path.exists(self.targetpath) and self.buildenv:
-            self.targetfs = TargetFs(self.targetpath, self.log,
-                                     self.buildenv.xml, clean=False)
+            self.targetfs = TargetFs(self.targetpath, self.buildenv.xml,
+                                     clean=False)
         else:
             self.targetfs = None
 
@@ -538,11 +538,11 @@ class ElbeProject (object):
 
         # Extract target FS. We always create a new instance here with
         # clean=true, because we want a pristine directory.
-        self.targetfs = TargetFs(self.targetpath, self.log,
-                                 self.buildenv.xml, clean=True)
+        self.targetfs = TargetFs(self.targetpath, self.buildenv.xml,
+                                 clean=True)
         os.chdir(self.buildenv.rfs.fname(''))
         extract_target(self.buildenv.rfs, self.xml, self.targetfs,
-                       self.log, self.get_rpcaptcache())
+                       self.get_rpcaptcache())
 
         # The validation file is created using check_full_pkgs() and
         # elbe_report(), both opening the file in append mode. So if an
@@ -598,9 +598,8 @@ class ElbeProject (object):
                     "licence.txt"),
                 "w+",
                 encoding='utf-8')
-            self.buildenv.rfs.write_licenses(
-                f, self.log, os.path.join(
-                    self.builddir, "licence.xml"))
+            self.buildenv.rfs.write_licenses(f,
+                                             os.path.join(self.builddir, "licence.xml"))
         except Exception:
             self.log.printo("error during generating licence.txt/xml")
             self.log.printo(sys.exc_info()[0])
@@ -867,8 +866,8 @@ class ElbeProject (object):
         # We use the old content of the directory if no rebuild is done, so
         # don't clean it (yet).
         if os.path.exists(self.targetpath):
-            self.targetfs = TargetFs(self.targetpath, self.log,
-                                     self.xml, clean=False)
+            self.targetfs = TargetFs(self.targetpath, self.xml,
+                                     clean=False)
         else:
             self.targetfs = None
 
diff --git a/elbepack/filesystem.py b/elbepack/filesystem.py
index cc7d08f5..47bd8f88 100644
--- a/elbepack/filesystem.py
+++ b/elbepack/filesystem.py
@@ -13,6 +13,8 @@ from glob import glob
 from tempfile import mkdtemp
 from string import digits
 
+from elbepack.shellhelper import do
+
 def size_to_int(size):
     if size[-1] in digits:
         return int(size)
@@ -263,20 +265,19 @@ class TmpdirFilesystem (Filesystem):
 
 
 class ImgMountFilesystem(Filesystem):
-    def __init__(self, mntpoint, dev, log):
+    def __init__(self, mntpoint, dev):
         Filesystem.__init__(self, mntpoint)
 
         self.dev = dev
-        self.log = log
 
     def __enter__(self):
         cmd = 'mount "%s" "%s"' % (self.dev, self.path)
-        self.log.do(cmd)
+        do(cmd)
 
         return self
 
     def __exit__(self, typ, value, traceback):
-        self.log.do('umount "%s"' % self.path)
+        do('umount "%s"' % self.path)
 
 
 hostfs = Filesystem('/')
-- 
2.11.0




More information about the elbe-devel mailing list