diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-10-05 12:19:13 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-10-05 12:19:13 +0100 |
commit | c25c7fae299b7ac8fc2e92f4214272aaf3de336b (patch) | |
tree | 8fe988e7bd9d888882642a53ee57824391475786 /morphlib/execute.py | |
parent | 1cc271c29d48eb1863fca3d3fe4276ce4f8141c9 (diff) | |
download | morph-c25c7fae299b7ac8fc2e92f4214272aaf3de336b.tar.gz |
Differentiate between real and fake root.
Diffstat (limited to 'morphlib/execute.py')
-rw-r--r-- | morphlib/execute.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/morphlib/execute.py b/morphlib/execute.py index 18030ccc..b1221b80 100644 --- a/morphlib/execute.py +++ b/morphlib/execute.py @@ -38,7 +38,7 @@ class Execute(object): def _setup_env(self): self.env = dict(os.environ) - def run(self, commands, as_root=False): + def run(self, commands, as_root=False, as_fakeroot=False): '''Execute a list of commands. If a command fails (returns non-zero exit code), the rest are @@ -51,6 +51,8 @@ class Execute(object): self.msg('# %s' % command) argv = ['sh', '-c', command] if as_root: + argv = ['sudo'] + argv # pragma: no cover + elif as_fakeroot: argv = ['fakeroot'] + argv p = subprocess.Popen(argv, shell=False, stdout=subprocess.PIPE, @@ -67,7 +69,7 @@ class Execute(object): stdouts.append(out) return stdouts - def runv(self, argv, as_root=False): + def runv(self, argv, as_root=False, as_fakeroot=False): '''Run a command given as a list of argv elements. Return standard output. Raise ``CommandFailure`` if the command @@ -76,6 +78,8 @@ class Execute(object): ''' if as_root: + argv = ['sudo'] + argv # pragma: no cover + elif as_fakeroot: argv = ['fakeroot'] + argv self.msg('# %s' % ' '.join(argv)) p = subprocess.Popen(argv, stdout=subprocess.PIPE, |