Commit b1742031 authored by Kirill Smelkov's avatar Kirill Smelkov

slapos.recipe.build:download* : Ignore urls that point to file coming from SR itself

Without this fix SR files fetched via slapos.recipe.build:download and
slapos.recipe.build:download-unpacked produce leat to error e.g. like

urlpath = '/SR-BASE/stack/erp5/instance-mariadb-resiliency-after-import-script.sh.in', kind = '', version = None

    def addbom(urlpath, kind, version=None):
        name, ver = namever(urlpath)
        if version is not None:
            assert ver is None
            ver = version
        ver = removeprefix(ver, name+'-')   # wendelin.core-2.0.alpha3-0-g6315384  -> 2.0.alpha3-0-g6315384
        if '//' in urlpath:
            url = urlpath
        else:
            if kind == 'egg':
                # XXX not strictly correct -> better retrieve the actual URL, but buildout does not save it in installed.cfg
                url = 'https://pypi.org/project/%s/%s/' % (name, ver)
            else:
>               raise NotImplementedError('TODO url for kind %r  (urlpath: %r)' % (kind, urlpath))
E               NotImplementedError: TODO url for kind ''  (urlpath: '/SR-BASE/stack/erp5/instance-mariadb-resiliency-after-import-script.sh.in')

nxdbom/__init__.py:64: NotImplementedError
parent 673189bd
...@@ -61,7 +61,7 @@ def bom_software(installed_software_path): # -> {} name -> PkgInfo ...@@ -61,7 +61,7 @@ def bom_software(installed_software_path): # -> {} name -> PkgInfo
# XXX not strictly correct -> better retrieve the actual URL, but buildout does not save it in installed.cfg # XXX not strictly correct -> better retrieve the actual URL, but buildout does not save it in installed.cfg
url = 'https://pypi.org/project/%s/%s/' % (name, ver) url = 'https://pypi.org/project/%s/%s/' % (name, ver)
else: else:
raise NotImplementedError('TODO url for kind %s' % kind) raise NotImplementedError('TODO url for kind %r (urlpath: %r)' % (kind, urlpath))
info = PkgInfo(name, ver, kind, url) info = PkgInfo(name, ver, kind, url)
...@@ -111,13 +111,19 @@ def bom_software(installed_software_path): # -> {} name -> PkgInfo ...@@ -111,13 +111,19 @@ def bom_software(installed_software_path): # -> {} name -> PkgInfo
if isconf(url): if isconf(url):
continue continue
# if url refer to local filesystem and comes as /base/... - it
# comes from the SR itself and should be ignored
base = part.get('_profile_base_location_') # not always present, e.g. no on
if base is not None and url.startswith(base): # ocropy-eng-traineddata
continue
# let's see if maybe its an archive from known place # let's see if maybe its an archive from known place
_ = namever(url, failonerr=False) _ = namever(url, failonerr=False)
if _ is not None: if _ is not None:
addbom(url, '') # XXX detect kind addbom(url, '') # XXX detect kind
continue continue
raise NotImplementedError('%s uses %s with url that does not look like a .conf or archive file: %s' % (s, recipe, url)) raise NotImplementedError('%s uses %s with url that does not look like a .conf, archive or SR file: %s' % (s, recipe, url))
elif recipe.startswith('slapos.recipe.template'): elif recipe.startswith('slapos.recipe.template'):
......
...@@ -110,6 +110,14 @@ url = https://osdn.net/frs/redir.php?f=ipafonts%2F57330%2FIPAexfont00201.zip ...@@ -110,6 +110,14 @@ url = https://osdn.net/frs/redir.php?f=ipafonts%2F57330%2FIPAexfont00201.zip
IPAexfont 00201 https://osdn.net/frs/redir.php?f=ipafonts%2F57330%2FIPAexfont00201.zip IPAexfont 00201 https://osdn.net/frs/redir.php?f=ipafonts%2F57330%2FIPAexfont00201.zip
""") """)
# download from local filesystem - ignore if that file comes from the profile itself
case1("""\
[mariadb-resiliency-after-import-script]
recipe = slapos.recipe.build:download
url = /BASE/stack/erp5/instance-mariadb-resiliency-after-import-script.sh.in
_profile_base_location_ = /BASE
""", '')
for x in ('gcc', 'python', 'ZODB', 'ZEO', 'tempstorage'): for x in ('gcc', 'python', 'ZODB', 'ZEO', 'tempstorage'):
case1("""\ case1("""\
[%s] [%s]
......
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