Commit 3143874b authored by Antoine Catton's avatar Antoine Catton

Add the ability to specify filemode to template recipe

parent fe4734e4
...@@ -24,17 +24,23 @@ ...@@ -24,17 +24,23 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
import os
from slapos.recipe.librecipe import GenericBaseRecipe from slapos.recipe.librecipe import GenericBaseRecipe
class Recipe(GenericBaseRecipe): class Recipe(GenericBaseRecipe):
def install(self): def install(self):
mapping = self.options.copy() mapping = self.options.copy()
for key in ('output', 'template', 'recipe', ): for key in ('output', 'template', 'recipe', 'mode'):
if key in mapping:
del mapping[key] del mapping[key]
with open(self.options['output'], 'w') as output, \ with open(self.options['output'], 'w') as output, \
open(self.options['template'], 'r') as template: open(self.options['template'], 'r') as template:
output.write(template.read() % mapping) output.write(template.read() % mapping)
if 'mode' in self.options:
os.chmod(self.options['output'], int(self.options['mode'], 8))
return [self.options['output'], ] return [self.options['output'], ]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment