1 |
Rather than shell out to cp/rm/mv, use python native code to do things. |
2 |
--- |
3 |
catalyst/base/stagebase.py | 39 +++++++++++++++------------------------ |
4 |
1 file changed, 15 insertions(+), 24 deletions(-) |
5 |
|
6 |
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py |
7 |
index 2009ab6..0b25516 100644 |
8 |
--- a/catalyst/base/stagebase.py |
9 |
+++ b/catalyst/base/stagebase.py |
10 |
@@ -1013,8 +1013,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
11 |
else: |
12 |
log.notice('Setting up chroot...') |
13 |
|
14 |
- cmd("cp /etc/resolv.conf " + self.settings["chroot_path"] + "/etc/", |
15 |
- env=self.env) |
16 |
+ shutil.copy('/etc/resolv.conf', self.settings['chroot_path'] + '/etc/') |
17 |
|
18 |
# Copy over the envscript, if applicable |
19 |
if "envscript" in self.settings: |
20 |
@@ -1030,18 +1029,15 @@ class StageBase(TargetBase, ClearBase, GenBase): |
21 |
'Catalyst Maintainers use VERY minimal envscripts, if used at all.\n' |
22 |
'You have been warned.') |
23 |
|
24 |
- cmd("cp "+self.settings["envscript"]+" "+\ |
25 |
- self.settings["chroot_path"]+"/tmp/envscript",\ |
26 |
- env=self.env) |
27 |
+ shutil.copy(self.settings['envscript'], |
28 |
+ self.settings['chroot_path'] + '/tmp/envscript') |
29 |
|
30 |
# Copy over /etc/hosts from the host in case there are any |
31 |
# specialties in there |
32 |
- if os.path.exists(self.settings["chroot_path"]+"/etc/hosts"): |
33 |
- cmd("mv "+self.settings["chroot_path"]+"/etc/hosts "+\ |
34 |
- self.settings["chroot_path"]+"/etc/hosts.catalyst",\ |
35 |
- env=self.env) |
36 |
- cmd("cp /etc/hosts "+self.settings["chroot_path"]+"/etc/hosts",\ |
37 |
- env=self.env) |
38 |
+ hosts_file = self.settings['chroot_path'] + '/etc/hosts' |
39 |
+ if os.path.exists(hosts_file): |
40 |
+ os.rename(hosts_file, hosts_file + '.catalyst') |
41 |
+ shutil.copy('/etc/hosts', hosts_file) |
42 |
|
43 |
# Modify and write out make.conf (for the chroot) |
44 |
makepath = normpath(self.settings["chroot_path"] + |
45 |
@@ -1162,10 +1158,9 @@ class StageBase(TargetBase, ClearBase, GenBase): |
46 |
clear_path(self.settings["destpath"] + x) |
47 |
|
48 |
# Put /etc/hosts back into place |
49 |
- if os.path.exists(self.settings["chroot_path"]+"/etc/hosts.catalyst"): |
50 |
- cmd("mv -f "+self.settings["chroot_path"]+"/etc/hosts.catalyst "+\ |
51 |
- self.settings["chroot_path"]+"/etc/hosts",\ |
52 |
- env=self.env) |
53 |
+ hosts_file = self.settings['chroot_path'] + '/etc/hosts' |
54 |
+ if os.path.exists(hosts_file + '.catalyst'): |
55 |
+ os.rename(hosts_file + '.catalyst', hosts_file) |
56 |
|
57 |
# Remove our overlay |
58 |
if os.path.exists(self.settings["chroot_path"] + self.settings["local_overlay"]): |
59 |
@@ -1565,11 +1560,8 @@ class StageBase(TargetBase, ClearBase, GenBase): |
60 |
env=self.env) |
61 |
|
62 |
if "boot/kernel/"+kname+"/initramfs_overlay" in self.settings: |
63 |
- if os.path.exists(self.settings["chroot_path"]+\ |
64 |
- "/tmp/initramfs_overlay/"): |
65 |
- log.notice('Cleaning up temporary overlay dir') |
66 |
- cmd("rm -R "+self.settings["chroot_path"]+\ |
67 |
- "/tmp/initramfs_overlay/",env=self.env) |
68 |
+ log.notice('Cleaning up temporary overlay dir') |
69 |
+ clear_dir(self.settings['chroot_path'] + '/tmp/initramfs_overlay/') |
70 |
|
71 |
self.resume.is_enabled("build_kernel_"+kname) |
72 |
|
73 |
@@ -1586,11 +1578,10 @@ class StageBase(TargetBase, ClearBase, GenBase): |
74 |
self.settings[key]) |
75 |
|
76 |
try: |
77 |
- cmd('cp ' + self.settings[key] + ' ' + |
78 |
- self.settings['chroot_path'] + '/var/tmp/' + kname + '.config', |
79 |
- env=self.env) |
80 |
+ shutil.copy(self.settings[key], |
81 |
+ self.settings['chroot_path'] + '/var/tmp/' + kname + '.config') |
82 |
|
83 |
- except CatalystError: |
84 |
+ except IOError: |
85 |
self.unbind() |
86 |
|
87 |
def _copy_initramfs_overlay(self, kname): |
88 |
-- |
89 |
2.8.2 |