Molecule:

- implement sandbox support on ChrootHandler


git-svn-id: http://svn.sabayonlinux.org/projects/molecule/trunk@3104 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
lxnay
2009-03-03 12:20:43 +00:00
parent 2554dd1743
commit fae805e3fd
2 changed files with 18 additions and 1 deletions
+10 -1
View File
@@ -248,6 +248,15 @@ class ChrootHandler(GenericHandlerInterface):
# now remove paths to remove (...)
remove_paths = self.metadata.get('paths_to_remove',[])
# setup sandbox
sb_dirs = [self.dest_dir]
sb_env = {
'SANDBOX_WRITE': ':'.join(sb_dirs),
}
myenv = os.environ.copy()
myenv.update(sb_env)
for mypath in remove_paths:
mypath = self.dest_dir+mypath
self.Output.updateProgress("[%s|%s] %s: %s" % (
@@ -255,7 +264,7 @@ class ChrootHandler(GenericHandlerInterface):
_("removing dir"),mypath,
)
)
rc = molecule.utils.remove_path(mypath)
rc = molecule.utils.remove_path_sandbox(mypath, sb_env)
if rc != 0:
self.Output.updateProgress("[%s|%s] %s: %s: %s" % (
blue("ChrootHandler"),darkred(self.spec_name),
+8
View File
@@ -19,6 +19,7 @@
from __future__ import with_statement
import os
import sys
import time
import subprocess
import shutil
@@ -75,5 +76,12 @@ def empty_dir(dest_dir):
def remove_path(path):
return subprocess.call('rm -rf %s' % (path,), shell = True)
def remove_path_sandbox(path, sandbox_env):
p = subprocess.Popen(["sandbox", "rm", "-rf", path],
stdout = sys.stdout, stderr = sys.stderr,
env = sandbox_env
)
return p.wait()
def get_random_number():
return abs(hash(os.urandom(2)))%99999