diff --git a/slapos/recipe/wrapper.py b/slapos/recipe/wrapper.py index 8bb3cd1c08bdc87d97b8daf52b1347ebb6740bda..9bf484e87fca0915b4c1dfaae3b0078cc9300f55 100644 --- a/slapos/recipe/wrapper.py +++ b/slapos/recipe/wrapper.py @@ -30,25 +30,32 @@ import shlex from slapos.recipe.librecipe import GenericBaseRecipe class Recipe(GenericBaseRecipe): - def install(self): - command_line = shlex.split(self.options['command-line']) - + wrapper_path = self.options['wrapper-path'] wait_files = self.options.get('wait-for-files') + environment = self.options.get('environment') + + if not wait_files and not environment: + # Create a simple wrapper as shell script + return [self.createWrapper( + name=wrapper_path, + command=command_line[0], + parameters=command_line[1:], + )] + + # More complex needs: create a Python script as wrapper + if wait_files is not None: wait_files = [filename.strip() for filename in wait_files.split() if filename.strip()] - - environment = self.options.get('environment') if environment is not None: environment = dict((k.strip(), v.strip()) for k, v in [ line.split('=') for line in environment.split('\n') ]) - return [self.createPythonScript( - self.options['output'], + wrapper_path, 'slapos.recipe.librecipe.execute.generic_exec', (command_line, wait_files, environment,), )]