Commit 34c4526c authored by Kirill Smelkov's avatar Kirill Smelkov

Add support for zc.recipe.egg:eggs and zc.recipe.egg:scripts

Notes:

- egg can come with options, e.g. 'neoppod[admin, ctl, master]'
- eggs are separated by \n, not space
- we ignore *.egg-link because those softwares are reported due to their
  original downloading sections
parent 59db6ac4
......@@ -147,19 +147,28 @@ def bom_software(installed_software_path): # -> {} name -> PkgInfo
if isegg: # ignore .egg-link - we declare it through the place
addbom(eggpath, 'egg') # from where destination is downloaded from
elif recipe == 'zc.recipe.egg':
elif recipe in ('zc.recipe.egg', 'zc.recipe.egg:eggs', 'zc.recipe.egg:scripts'):
# XXX sadly zc.recipe.egg neither saves in .installed.cfg information about where the eggs are installed,
# nor there are [versions] save.
# -> look the egg on the filesystem
# TODO it is better to fix zc.recipe.egg to save the full information, so that we can build BOM just from .installed.cfg
eggdir = part['_e']
eggdev = part['_d']
eggs = part['eggs'].split()
eggs = part['eggs'].split('\n')
for eggname in eggs:
eggv = glob('%s/%s-*.egg' % (eggdir, eggname))
eggv += glob('%s/%s-*.egg' % (eggdev, eggname))
m = _egg_re.match(eggname)
assert m is not None, eggname
eggname = m.group('name') # neoppod[admin, ctl, master] -> neoppod
if glob('%s/%s.egg-link' % (eggdev, eggname)):
continue # e.g. wendelin.core.egg-link points to wendelin.core cloned via git and already reported as git
installed_eggs = [basename(_) for _ in (glob('%s/*.egg' % eggdir) +
glob('%s/*.egg' % eggdev))]
eggv = [_ for _ in installed_eggs if _.startswith('%s-' % eggname)]
if len(eggv) == 0:
raise ValueError('egg %s not found' % egg)
raise ValueError('egg %s not found' % eggname)
if len(eggv) > 1:
raise ValueError('egg %s is present multiple times: %s' % (egg, eggv))
addbom(eggv[0], 'egg')
......@@ -190,6 +199,8 @@ def geturl(part, default=_missing):
raise KeyError('section %s has no url' % part)
return url
_egg_re = re.compile(r'^(?P<name>[\w\-\.]+)(\[.*\])?$')
def bom_node(XXX):
1/0
......
......@@ -165,6 +165,35 @@ lxml 4.9.1 https://pypi.org/project/lxml/4.9.1/
pycurl 7.43.0 https://pypi.org/project/pycurl/7.43.0/
""")
case1("""\
[ZODB5]
recipe = zc.recipe.egg:eggs
_d = /ROOT/develop-eggs
_e = /ROOT/eggs
eggs = ZODB
BTrees
-- /ROOT/eggs/ZODB-5.8.0-py2.7.egg/x --
-- /ROOT/develop-eggs/BTrees-4.11.3-py2.7-linux-x86_64.egg/x --
""", """
>>> eggs:
BTrees 4.11.3 https://pypi.org/project/BTrees/4.11.3/
ZODB 5.8.0 https://pypi.org/project/ZODB/5.8.0/
""")
case1("""\
[erp5-python-interpreter]
recipe = zc.recipe.egg:scripts
_d = /ROOT/develop-eggs
_e = /ROOT/eggs
eggs = pygolang
neoppod[admin, ctl, master]
-- /ROOT/develop-eggs/pygolang-0.1-py2.7-linux-x86_64.egg/x --
-- /ROOT/develop-eggs/neoppod.egg-link --
""", """
>>> eggs:
pygolang 0.1 https://pypi.org/project/pygolang/0.1/
""")
# %20 in URL
case1("""\
[zabbix-agent]
......
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