[elbe-devel] [PATCH v2 08/15] Change os.sytem to shellhelper::system for "efilesystem.py"
dion at linutronix.de
dion at linutronix.de
Mon Jun 24 17:39:05 CEST 2019
From: Olivier Dion <dion at linutronix.de>
Signed-off-by: Olivier Dion <dion at linutronix.de>
---
elbepack/efilesystem.py | 50 ++++++++++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
index 1f6428e0..35dd6a9b 100644
--- a/elbepack/efilesystem.py
+++ b/elbepack/efilesystem.py
@@ -13,6 +13,7 @@ import subprocess
import io
import stat
+
from elbepack.asciidoclog import CommandError
from elbepack.filesystem import Filesystem
from elbepack.version import elbe_version
@@ -20,6 +21,7 @@ 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.shellhelper import system
def copy_filelist(src, filelist, dst):
@@ -186,20 +188,22 @@ class ChRootFilesystem(ElbeFilesystem):
ui = "/usr/share/elbe/qemu-elbe/" + self.interpreter
if not os.path.exists(ui):
ui = "/usr/bin/" + self.interpreter
- os.system('cp %s %s' % (ui, self.fname("usr/bin")))
+ system('cp %s %s' % (ui, self.fname("usr/bin")))
if self.exists("/etc/resolv.conf"):
- os.system('mv %s %s' % (self.fname("etc/resolv.conf"),
- self.fname("etc/resolv.conf.orig")))
- os.system('cp %s %s' % ("/etc/resolv.conf",
- self.fname("etc/resolv.conf")))
+ system('mv %s %s' % (self.fname("etc/resolv.conf"),
+ self.fname("etc/resolv.conf.orig")))
+
+ system('cp %s %s' % ("/etc/resolv.conf",
+ self.fname("etc/resolv.conf")))
if self.exists("/etc/apt/apt.conf"):
- os.system('cp %s %s' % (self.fname("/etc/apt/apt.conf"),
- self.fname("/etc/apt/apt.conf.orig")))
+ system('cp %s %s' % (self.fname("/etc/apt/apt.conf"),
+ self.fname("/etc/apt/apt.conf.orig")))
+
if os.path.exists("/etc/apt/apt.conf"):
- os.system('cp %s %s' % ("/etc/apt/apt.conf",
- self.fname("/etc/apt/")))
+ system('cp %s %s' % ("/etc/apt/apt.conf",
+ self.fname("/etc/apt/")))
self.mkdir_p("usr/sbin")
self.write_file("usr/sbin/policy-rc.d",
@@ -213,33 +217,33 @@ class ChRootFilesystem(ElbeFilesystem):
self.leave_chroot()
self.umount()
if self.interpreter:
- os.system('rm -f %s' %
- os.path.join(self.path, "usr/bin/" + self.interpreter))
+ system('rm -f %s' % os.path.join(self.path,
+ "usr/bin/" + self.interpreter))
- os.system('rm -f %s' % (self.fname("etc/resolv.conf")))
+ system('rm -f %s' % (self.fname("etc/resolv.conf")))
if self.exists("/etc/resolv.conf.orig"):
- os.system('mv %s %s' % (self.fname("etc/resolv.conf.orig"),
- self.fname("etc/resolv.conf")))
+ system('mv %s %s' % (self.fname("etc/resolv.conf.orig"),
+ self.fname("etc/resolv.conf")))
if self.exists("/etc/apt/apt.conf"):
- os.system('rm -f %s' % (self.fname("etc/apt/apt.conf")))
+ system('rm -f %s' % (self.fname("etc/apt/apt.conf")))
if self.exists("/etc/apt/apt.conf.orig"):
- os.system('mv %s %s' % (self.fname("etc/apt/apt.conf.orig"),
- self.fname("etc/apt/apt.conf")))
+ system('mv %s %s' % (self.fname("etc/apt/apt.conf.orig"),
+ self.fname("etc/apt/apt.conf")))
if self.exists("/usr/sbin/policy-rc.d"):
- os.system('rm -f %s' % (self.fname("usr/sbin/policy-rc.d")))
+ system('rm -f %s' % (self.fname("usr/sbin/policy-rc.d")))
def mount(self):
if self.path == '/':
return
try:
- os.system("mount -t proc none %s/proc" % self.path)
- os.system("mount -t sysfs none %s/sys" % self.path)
- os.system("mount -o bind /dev %s/dev" % self.path)
- os.system("mount -o bind /dev/pts %s/dev/pts" % self.path)
+ system("mount -t proc none %s/proc" % self.path)
+ system("mount -t sysfs none %s/sys" % self.path)
+ system("mount -o bind /dev %s/dev" % self.path)
+ system("mount -o bind /dev/pts %s/dev/pts" % self.path)
except BaseException:
self.umount()
raise
@@ -261,7 +265,7 @@ class ChRootFilesystem(ElbeFilesystem):
def _umount(self, path):
if os.path.ismount(path):
- os.system("umount %s" % path)
+ system("umount %s" % path)
def umount(self):
if self.path == '/':
--
2.11.0
More information about the elbe-devel
mailing list