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:
+10
-1
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user