summaryrefslogtreecommitdiff
path: root/morphlib/bins.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2011-12-08 08:33:37 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2011-12-08 09:56:29 +0000
commit007f2e556796f749ab24d79106cd0f1da46b00c3 (patch)
treee80221342522d9f5b0d7ab361143004461d06965 /morphlib/bins.py
parent38d6f5c1b3cb4890d105fdda07f87e0f78522e21 (diff)
downloadmorph-007f2e556796f749ab24d79106cd0f1da46b00c3.tar.gz
Make the install parts of morphs run as sudo
Then fix all the places where this broke things because they didn't have the required permissions. This is a potential security risk of course, it would be preferable if the install commands were run in a fakeroot session and only the final image building was run as root, but it needs to work first
Diffstat (limited to 'morphlib/bins.py')
-rw-r--r--morphlib/bins.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/morphlib/bins.py b/morphlib/bins.py
index d8cbf8e0..2fbe6d98 100644
--- a/morphlib/bins.py
+++ b/morphlib/bins.py
@@ -95,9 +95,11 @@ def create_chunk(rootdir, chunk_filename, regexps, dump_memory_profile=None):
for filename in reversed(include):
if os.path.isdir(filename) and not os.path.islink(filename):
if not os.listdir(filename):
- os.rmdir(filename)
+ #os.rmdir(filename) doesn't have permission
+ ex.runv(['rmdir', filename], as_root=True)
else:
- os.remove(filename)
+ #os.remove(filename) doesn't have permission
+ ex.runv(['rm', filename], as_root=True)
dump_memory_profile('after removing in create_chunks')
@@ -118,5 +120,6 @@ def unpack_binary(filename, dirname):
logging.debug('Unpacking %s into %s' % (filename, dirname))
ex = morphlib.execute.Execute(dirname, msg=lambda s: None)
- ex.runv(['tar', '-xvf', filename])
+ # tar must be run as root, as it is creating a real image now
+ ex.runv(['tar', '-xvf', filename], as_root=True)