aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-05-20 01:03:34 -0400
committerMike Frysinger <vapier@gentoo.org>2016-05-20 01:31:57 -0400
commit64255565bf45bd07a66405d876bbbe58b7a0c441 (patch)
tree609eb8cfebb8adcf106744dc4b5dde8208c43854
parentcmd: drop |myexc| argument (diff)
downloadcatalyst-64255565bf45bd07a66405d876bbbe58b7a0c441.tar.gz
catalyst-64255565bf45bd07a66405d876bbbe58b7a0c441.tar.bz2
catalyst-64255565bf45bd07a66405d876bbbe58b7a0c441.zip
use native code in more places for file ops
Rather than shell out to cp/rm/mv, use python native code to do things.
-rw-r--r--catalyst/base/stagebase.py39
1 files changed, 15 insertions, 24 deletions
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 2009ab60..0b25516d 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1013,8 +1013,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
else:
log.notice('Setting up chroot...')
- cmd("cp /etc/resolv.conf " + self.settings["chroot_path"] + "/etc/",
- env=self.env)
+ shutil.copy('/etc/resolv.conf', self.settings['chroot_path'] + '/etc/')
# Copy over the envscript, if applicable
if "envscript" in self.settings:
@@ -1030,18 +1029,15 @@ class StageBase(TargetBase, ClearBase, GenBase):
'Catalyst Maintainers use VERY minimal envscripts, if used at all.\n'
'You have been warned.')
- cmd("cp "+self.settings["envscript"]+" "+\
- self.settings["chroot_path"]+"/tmp/envscript",\
- env=self.env)
+ shutil.copy(self.settings['envscript'],
+ self.settings['chroot_path'] + '/tmp/envscript')
# Copy over /etc/hosts from the host in case there are any
# specialties in there
- if os.path.exists(self.settings["chroot_path"]+"/etc/hosts"):
- cmd("mv "+self.settings["chroot_path"]+"/etc/hosts "+\
- self.settings["chroot_path"]+"/etc/hosts.catalyst",\
- env=self.env)
- cmd("cp /etc/hosts "+self.settings["chroot_path"]+"/etc/hosts",\
- env=self.env)
+ hosts_file = self.settings['chroot_path'] + '/etc/hosts'
+ if os.path.exists(hosts_file):
+ os.rename(hosts_file, hosts_file + '.catalyst')
+ shutil.copy('/etc/hosts', hosts_file)
# Modify and write out make.conf (for the chroot)
makepath = normpath(self.settings["chroot_path"] +
@@ -1162,10 +1158,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
clear_path(self.settings["destpath"] + x)
# Put /etc/hosts back into place
- if os.path.exists(self.settings["chroot_path"]+"/etc/hosts.catalyst"):
- cmd("mv -f "+self.settings["chroot_path"]+"/etc/hosts.catalyst "+\
- self.settings["chroot_path"]+"/etc/hosts",\
- env=self.env)
+ hosts_file = self.settings['chroot_path'] + '/etc/hosts'
+ if os.path.exists(hosts_file + '.catalyst'):
+ os.rename(hosts_file + '.catalyst', hosts_file)
# Remove our overlay
if os.path.exists(self.settings["chroot_path"] + self.settings["local_overlay"]):
@@ -1565,11 +1560,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
if "boot/kernel/"+kname+"/initramfs_overlay" in self.settings:
- if os.path.exists(self.settings["chroot_path"]+\
- "/tmp/initramfs_overlay/"):
- log.notice('Cleaning up temporary overlay dir')
- cmd("rm -R "+self.settings["chroot_path"]+\
- "/tmp/initramfs_overlay/",env=self.env)
+ log.notice('Cleaning up temporary overlay dir')
+ clear_dir(self.settings['chroot_path'] + '/tmp/initramfs_overlay/')
self.resume.is_enabled("build_kernel_"+kname)
@@ -1586,11 +1578,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings[key])
try:
- cmd('cp ' + self.settings[key] + ' ' +
- self.settings['chroot_path'] + '/var/tmp/' + kname + '.config',
- env=self.env)
+ shutil.copy(self.settings[key],
+ self.settings['chroot_path'] + '/var/tmp/' + kname + '.config')
- except CatalystError:
+ except IOError:
self.unbind()
def _copy_initramfs_overlay(self, kname):