[elbe-devel] [PATCH v2 08/15] Change os.sytem to shellhelper::system for "efilesystem.py"

Torben Hohn torben.hohn at linutronix.de
Tue Jun 25 13:59:01 CEST 2019


On Mon, Jun 24, 2019 at 05:39:05PM +0200, dion at linutronix.de wrote:
> From: Olivier Dion <dion at linutronix.de>
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>

Reviewed-by: Torben Hohn <torben.hohn 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
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list