• Antoine Catton's avatar
    Add escape option in order to avoid script formatting · 125fdd0f
    Antoine Catton authored
    The script is formatted with self.options dictionnary.
    
    For example :
    
      [foobar]
      recipe = slapos.recipe.build
      foo = bar
      script =
        print '%(foo)s'
    
    Produces :
    
      Installing foobar.
      bar
    
    But this can mess up the python code, because there's no
    escaping. For example :
    
      [foobar]
      recipe = slapos.recipe.build
      foo = bar's
      script =
        print '%(foo)s'
    
    Produces :
    
      While:
        Installing foobar.
    
      An internal error occurred due to a bug in either zc.buildout or in a
      recipe being used:
      Traceback (most recent call last):
        File "<string>", line 2
          print 'bar's'
                     ^
      SyntaxError: invalid syntax
    
    We can workaround this by using :
    
      [foobar]
      recipe = slapos.recipe.build
      foo = bar's
      script =
          print '%%s' %% self.options['foo']
    
    But every percent sign has to be escaped. That's why, this
    commit introduces :
    
      [foobar]
      recipe = slapos.recipe.build
      foo = bar's
      format = no
      script =
          print '%s' % self.options['foo']
    
    NB: This commit doesn't remove formating for backward compatibility.
    125fdd0f
build.py 14.8 KB