mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
import Utils
|
|
from TaskGen import feature, before
|
|
import Task
|
|
import os
|
|
|
|
# fixme: this seems to hang waf with 100% CPU
|
|
|
|
def detect(conf):
|
|
conf.find_program("mkisofs",mandatory=True,var='MKISOFS')
|
|
|
|
def iso_up(task):
|
|
tgt = task.outputs[0].bldpath(task.env)
|
|
if os.path.exists(tgt): os.unlink(tgt)
|
|
inps = []
|
|
for inp in task.inputs:
|
|
if inp.id&3==Node.BUILD:
|
|
src = inp.bldpath(task.env)
|
|
srcname = src
|
|
srcname = "/".join(srcname.split("/")[1:]) # chop off default/
|
|
else:
|
|
src = inp.srcpath(task.env)
|
|
srcname = src
|
|
srcname = "/".join(srcname.split("/")[1:]) # chop off ../
|
|
inps.append(src)
|
|
ret = Utils.exec_command(
|
|
[
|
|
task.generator.env.MKISOFS,
|
|
"-quiet",
|
|
"-r",
|
|
"-o",tgt,
|
|
] + inps, shell=False)
|
|
if ret != 0: return ret
|
|
if task.chmod: os.chmod(tgt,task.chmod)
|
|
|
|
def apply_iso(self):
|
|
Utils.def_attrs(self,fun=iso_up)
|
|
self.default_install_path=0
|
|
lst=self.to_list(self.source)
|
|
self.meths.remove('apply_core')
|
|
self.dict=getattr(self,'dict',{})
|
|
out = self.path.find_or_declare(self.target)
|
|
ins = []
|
|
for x in Utils.to_list(self.source):
|
|
node = self.path.find_resource(x)
|
|
if not node:raise Utils.WafError('cannot find input file %s for processing'%x)
|
|
ins.append(node)
|
|
if self.dict and not self.env['DICT_HASH']:
|
|
self.env=self.env.copy()
|
|
keys=list(self.dict.keys())
|
|
keys.sort()
|
|
lst=[self.dict[x]for x in keys]
|
|
self.env['DICT_HASH']=str(Utils.h_list(lst))
|
|
tsk=self.create_task('iso',ins,out)
|
|
tsk.fun=self.fun
|
|
tsk.dict=self.dict
|
|
tsk.dep_vars=['DICT_HASH']
|
|
tsk.install_path=self.install_path
|
|
tsk.chmod=self.chmod
|
|
if not tsk.env:
|
|
tsk.debug()
|
|
raise Utils.WafError('task without an environment')
|
|
|
|
Task.task_type_from_func('iso',func=iso_up)
|
|
feature('iso')(apply_iso)
|
|
before('apply_core')(apply_iso) |