+ return result
+
+def exports(export_type, recipe, packages, output):
+ logger = logging.getLogger(__name__)
+ if not export_type:
+ export_type='ks'
+ logger.info('set default export format(.ks)')
+
+ if not recipe:
+ raise TICError('No recipe defined')
+ if not packages or type(packages) is not list:
+ raise TICError('No packages defined')
+
+ #TODO recipe parsing
+ # Temporary code for 1st prototype release
+ if recipe.get('name') == 'default':
+ recipe = get_default_recipe()
+ config = recipe.get('Configurations')[0]
+ for key in ['Default', config['Platform']]:
+ recipe[key]['Groups']=[]
+ recipe[key]['ExtraPackages']=[]
+ config['Groups']=[]
+ config['ExtraPackages'] = packages
+ else:
+ raise TICError('No recipes defined')
+
+ # create the yaml
+ yaml_info = convert_recipe_to_yaml(recipe, DEFAULT_KICKSTARTDIR)
+
+ # create kickstart(.ks) using kickstarter tool
+ options = KSoption(yaml_info.configs, yaml_info.repos, yaml_info.cachedir)
+ kswriter(options)
+
+ # check whether the ks exists
+ baseline=recipe['Default'].get('Baseline')
+ ksname= ''.join([config.get('FileName'), '.ks'])
+ kspath=os.path.join(yaml_info.cachedir, baseline, ksname)
+ if not os.path.exists(kspath):
+ raise TICError('No ks file was created from kickstarter')
+
+ # copy the ks to output directory
+ shutil.copy(kspath, output)
+ logger.info('copy the ks file from %s to dst:%s', kspath, output)
+
+ return output