Commit 21bad144 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 40c4ed81
......@@ -20,7 +20,7 @@
# See https://www.nexedi.com/licensing for rationale and options.
"""Program nxd-bom generates bill of material for a software-release or slapos node
Usage: nxd-bom software <.installed.cfg>
Usage: nxd-bom software <path-to-installed-software>
nxd-bom node <slapos deploy-script>
"""
......@@ -31,21 +31,21 @@ from os.path import basename
# bom_software retrieves BOM from .installed.cfg generated by buildout along the build.
def bom_software(installed_cfg): # -> set of 'name-version' XXX
def bom_software(installed_software_path): # -> {} name -> version + XXX
bom = {} # name -> ver + ... XXX
inst = configparser.ConfigParser()
inst.read(installed_cfg)
idb = configparser.ConfigParser()
idb.read('%s/.installed.cfg' % installed_software_path)
eggs_todo = set() # eggs listed in zc.recipe.egg - XXX
for s in inst.sections():
for s in idb.sections():
if s == 'buildout':
continue # [buildout] is used internally
#print(s)
part = inst[s]
part = idb[s]
recipe = part['recipe']
if recipe == 'slapos.recipe.cmmi':
......@@ -132,8 +132,8 @@ _github_re = re.compile(r'github.com/\w+/(?P<name>\w+)/archive/(?P<rev>\w+)')
def namever(url): # -> (name, ver)
name, ver = _namever(url)
for tail in ('tgz', 'tar.gz', 'tbz', 'tar.bz2', 'tar.xz', 'tar.lz'):
ver = ver.removesuffix('.'+tail)
ver.removeprefix('v')
ver = removesuffix(ver, '.'+tail)
ver = removeprefix(ver, 'v')
return name, ver
def _namever(url):
......@@ -163,6 +163,17 @@ def isconf(url):
return True
return False
# removeprefix/removesuffix provides fallbacks similarly-named str methods.
def removeprefix(s, prefix):
if s.startswith(prefix):
s = s[len(prefix):]
return s
def removesuffix(s, suffix):
if s.endswith(suffix):
s = s[:len(s)-len(suffix)]
return s
# ----------------------------------------
def main():
......
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