Commit f672573a authored by Dmitry Blinov's avatar Dmitry Blinov

propagate strip_top_level_dir option to slapos.recipe.build:downloadunpacked

Don't force strip_top_level_dir option to be false when calling for slapos.recipe.build:downloadunpacked - let the user decide.

Effectively adds strip_top_level_dir option to the script which allows for shorter and more consistent paths.
Also it can help mitigating the variability of path length between archives downloaded for branch, commit hash and release.
parent 2563fc98
...@@ -16,6 +16,11 @@ Supported options ...@@ -16,6 +16,11 @@ Supported options
script. The ``url`` option can not be used at the same time with script. The ``url`` option can not be used at the same time with
``path``. ``path``.
``strip-top-level-dir``
Omit the topmost directory of the package when unpacking.
true or false. Defaults to false.
``prefix`` ``prefix``
Custom installation prefix passed to the ``--prefix`` option of the Custom installation prefix passed to the ``--prefix`` option of the
......
...@@ -110,6 +110,7 @@ class Recipe(object): ...@@ -110,6 +110,7 @@ class Recipe(object):
options['url'] = options.get('url', '').strip() options['url'] = options.get('url', '').strip()
options['path'] = options.get('path', '').strip() options['path'] = options.get('path', '').strip()
options['promises'] = options.get('promises', '') options['promises'] = options.get('promises', '')
options['strip-top-level-dir'] = options.get('strip-top-level-dir', 'false').strip()
if options['url'] and options['path']: if options['url'] and options['path']:
raise zc.buildout.UserError('You must use either "url" or "path", not both!') raise zc.buildout.UserError('You must use either "url" or "path", not both!')
...@@ -318,7 +319,6 @@ class Recipe(object): ...@@ -318,7 +319,6 @@ class Recipe(object):
self.options.get('md5sum') # so that buildout does not complain "unused option md5sum" self.options.get('md5sum') # so that buildout does not complain "unused option md5sum"
opt = self.options.copy() opt = self.options.copy()
opt['destination'] = compile_dir opt['destination'] = compile_dir
opt['strip-top-level-dir'] = 'false'
# no need to shared build for compile dir # no need to shared build for compile dir
opt['shared'] = 'false' opt['shared'] = 'false'
slapos.recipe.downloadunpacked.Recipe( slapos.recipe.downloadunpacked.Recipe(
......
...@@ -164,6 +164,23 @@ class NonInformativeTests(unittest.TestCase): ...@@ -164,6 +164,23 @@ class NonInformativeTests(unittest.TestCase):
with self.assertRaises(zc.buildout.UserError): with self.assertRaises(zc.buildout.UserError):
recipe.run('this-command-does-not-exist') recipe.run('this-command-does-not-exist')
def test_strip_top_dir_control(self):
recipe = self.make_recipe({}, 'test', {
'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__),
'keep-compile-dir': 'true'})
os.chdir(self.dir)
recipe.install()
self.assertTrue(os.path.exists('test_parts/test__compile__/package-0.0.0'))
def test_strip_top_dir(self):
recipe = self.make_recipe({}, 'test', {
'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__),
'keep-compile-dir': 'true',
'strip-top-level-dir': 'true'})
os.chdir(self.dir)
recipe.install()
self.assertTrue(os.path.exists('test_parts/test__compile__/configure'))
def test_stop_shell_on_error_midway(self): def test_stop_shell_on_error_midway(self):
recipe = self.make_recipe({}, 'test', { recipe = self.make_recipe({}, 'test', {
'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__), 'url': 'file://%s/testdata/package-0.0.0.tar.gz' % os.path.dirname(__file__),
......
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