@@ -111,7 +111,7 @@ def dir_current():
111
111
cwd = '/'
112
112
return cwd
113
113
114
- def system_command (command , shell = False , cwd = None , catch = False , env = None ):
114
+ def system_command (command , shell = False , cwd = None , env = None ):
115
115
if not cwd :
116
116
cwd = dir_current ()
117
117
elif not os .path .isdir (cwd ):
@@ -120,7 +120,7 @@ def system_command(command, shell=False, cwd=None, catch=False, env=None):
120
120
env = os .environ
121
121
if isinstance (command , str ) and not shell :
122
122
command = shlex .split (command )
123
- if catch or CATCH :
123
+ if CATCH :
124
124
pipe = subprocess .Popen (command , stderr = subprocess .PIPE , \
125
125
shell = shell , cwd = cwd , env = env )
126
126
pipe .wait ()
@@ -130,12 +130,16 @@ def system_command(command, shell=False, cwd=None, catch=False, env=None):
130
130
else :
131
131
return subprocess .check_call (command , shell = shell , cwd = cwd , env = env )
132
132
133
- def chroot_exec (command , prepare = True , mount = True , output = False , xnest = False , shell = False ):
133
+ def chroot_exec (command , prepare = True , mount = True , output = False , xnest = False , shell = False , cwd = None ):
134
134
out = None
135
135
mount = whereis ('mount' )
136
136
umount = whereis ('umount' )
137
137
chroot = whereis ('chroot' )
138
- chroot_command = [chroot , config .FILESYSTEM_DIR ]
138
+ if isinstance (command , str ):
139
+ chroot_command = '%s %s %s' % (chroot , config .FILESYSTEM_DIR , command )
140
+ else :
141
+ chroot_command = [chroot , config .FILESYSTEM_DIR ]
142
+ chroot_command .extend (command )
139
143
try :
140
144
if prepare :
141
145
resolv = '%s/etc/resolv.conf' % config .FILESYSTEM_DIR
@@ -201,14 +205,11 @@ def chroot_exec(command, prepare=True, mount=True, output=False, xnest=False, sh
201
205
environment ['DEBCONF_NONINTERACTIVE_SEEN' ] = 'true'
202
206
environment ['DEBCONF_NOWARNINGS' ] = 'true'
203
207
204
- if isinstance (command , str ):
205
- command = shlex .split (command )
206
- chroot_command .extend (command )
207
208
if output :
208
209
out = get_output (chroot_command )
209
210
else :
210
211
system_command (chroot_command , shell = shell , \
211
- env = environment )
212
+ env = environment , cwd = cwd )
212
213
finally :
213
214
if mount :
214
215
for s in reversed (pseudofs ):
0 commit comments