Molecule: implement prechroot facility

git-svn-id: http://svn.sabayonlinux.org/projects/molecule/trunk@2992 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
lxnay
2009-02-05 12:13:40 +00:00
parent 0d469c494a
commit 5f8bd237d1
3 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -147,7 +147,7 @@ class ChrootHandler(GenericHandlerInterface):
dest_exec = tmp_exec[len(self.dest_dir):]
if not dest_exec.startswith("/"):
dest_exec = "/%s" % (dest_exec,)
rc = molecule.utils.exec_chroot_cmd([dest_exec], self.dest_dir)
rc = molecule.utils.exec_chroot_cmd([dest_exec], self.dest_dir, self.metadata.get('prechroot',[]))
if rc != 0:
self.Output.updateProgress("[%s|%s] %s: %s" % (blue("ChrootHandler"),darkred(self.spec_name),_("inner chroot hook failed"),rc,))
return rc
+1 -1
View File
@@ -168,7 +168,7 @@ class SpecParser:
self.parser_data_path = {
'prechroot': {
'cb': valid_exec,
've': ve_string_stripper,
've': ve_string_splitter,
},
'release_string': {
'cb': ne_string, # validation callback
+5 -5
View File
@@ -49,17 +49,17 @@ def exec_cmd(args):
# wildcards automatically ==> rsync no workie
return subprocess.call(' '.join(args), shell = True)
def exec_chroot_cmd(args, chroot):
def exec_chroot_cmd(args, chroot, pre_chroot = []):
pid = os.fork()
if pid == 0:
os.chroot(chroot)
os.chdir("/")
p = subprocess.Popen(args)
rc = p.wait()
myargs = pre_chroot+args
rc = subprocess.call(myargs)
os._exit(rc)
else:
pid, status = os.waitpid(pid,0)
return status
rcpid, rc = os.waitpid(pid,0)
return rc
def empty_dir(dest_dir):
for el in os.listdir(dest_dir):