Commit 22950eb6 authored by Jérome Perrin's avatar Jérome Perrin

relax detection of slapos.recipe.build without url

While running nxdbom on all software releases, it turned out that the
initial approach of listing all sections using slapos.recipe.build
without url= option was not practical, because there are tens of such
sections and it would be problematic if we need to change nxdbom every
time we add such a section.

Instead, just skip sections without an `url` option, keeping a small
heuristic to try not to miss usages: options that look like an URL are
flagged.
parent 0daf7c4e
......@@ -124,17 +124,15 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
elif recipe == 'slapos.recipe.build':
# slapos.recipe.build is often used in creative ways to actually
# run python code during the build. Let's detect this via lack of
# `url`, but be careful and explicitly list name of such sections
# `url`, but be careful and try to detect options looking like URLs
# not to miss a normal part.
url = geturl(part, None)
if url is None:
# [gcc] is generic section to either use system gcc, or install one via slapos
# the one installed via slapos will come in its own section
# [python] is similar - it picks up python2 or python3
# ZODB, ZEO, ... are similar as well
if s in ('gcc', 'python', 'ZODB', 'ZEO', 'tempstorage', 'generic_testrunner_init'):
continue
raise NotImplementedError('%s uses %s without url' % (s, recipe))
def raw_values(p):
for k in p:
yield p.get(k, raw=True)
if any(v.strip().startswith('http') for v in raw_values(part)):
raise NotImplementedError('%s might be using url with %s in an unsupported way' % (s, recipe))
else:
addbom(url, '') # XXX detect kind?
......
......@@ -194,6 +194,60 @@ for x in ('gcc', 'python', 'ZODB', 'ZEO', 'tempstorage', 'generic_testrunner_ini
recipe = slapos.recipe.build
""" % x, '') # empty
case1("""\
[without-url]
recipe = slapos.recipe.build
init = do something
""",
''
)
case1("""\
[without-url]
recipe = slapos.recipe.build
install = install from path
path = somewhere
""",
''
)
# wrapper scripts generated by slapos.recipe.build (firefox-wrapper-*
# chromium-wrapper-* )
case1("""\
[wrapper-script]
recipe = slapos.recipe.build
install = ( create a wrapper from another part )
location = /ROOT/bin/executable
-- /ROOT/bin/executable --
""", '')
case1("""\
[without-url]
recipe = slapos.recipe.build
install =
some_python_that_we_cannot_introspect()
location = somewhere
""",
''
)
case1("""\
[url-detection]
recipe = slapos.recipe.build
xxx-url = https://lab.nexedi.com/...
location = somewhere
""",
NotImplementedError('url-detection might be using url with slapos.recipe.build in an unsupported way')
)
case1("""\
[url-detection]
recipe = slapos.recipe.build
xxx = interpqolation %s # this should not confuse the detection of urls
location = somewhere
""",
''
)
case1("""\
[template-logrotate-base]
......
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