Commit 673189bd authored by Kirill Smelkov's avatar Kirill Smelkov

slapos.recipe.build:download* : Recognize supported archives and don't complain about them

e.g.

	https://raw.githubusercontent.com/zuphilip/ocropy-models/master/en-default.pyrnn.gz

is fetched via slapos.recipe.build:download in ERP5 SR.
parent 43319739
......@@ -104,15 +104,20 @@ def bom_software(installed_software_path): # -> {} name -> PkgInfo
else:
addbom(url, '') # XXX detect kind?
elif recipe == 'slapos.recipe.build:download':
elif recipe in ('slapos.recipe.build:download', 'slapos.recipe.build:download-unpacked'):
# slapos.recipe.build:download is often used to download .conf files, but sometimes it is used to download e.g. binaries
# skip the part, if we can detect that downloaded item is a configuration file
url = geturl(part)
if isconf(url):
continue
# TODO binary -> parse name/ver
raise NotImplementedError('%s uses %s with url that does not look like a .conf file: %s' % (s, recipe, url))
# let's see if maybe its an archive from known place
_ = namever(url, failonerr=False)
if _ is not None:
addbom(url, '') # XXX detect kind
continue
raise NotImplementedError('%s uses %s with url that does not look like a .conf or archive file: %s' % (s, recipe, url))
elif recipe.startswith('slapos.recipe.template'):
......@@ -214,7 +219,7 @@ _SF_re = re.compile(r'/sourceforge.net/.+/(?P<name>[\w\_]+)-(?P<rev>[\w\.]+)
_git_re = re.compile(r'/(?P<name>[\w\.\-]+)\.git$')
_go_re = re.compile(r'/golang.org/dl/(?P<name>go)(?P<rev>[\w\.]+).src$')
_osdn_f = re.compile(r'/osdn.net/frs/redir.php\?f=(?P<f>.+)$')
def namever(url): # -> (name, ver)
def namever(url, failonerr=True): # -> (name, ver) | None if !failonerr
# http://www.ijg.org/files/jpegsrc.v9d.tar.gz -> http://www.ijg.org/files/jpegsrc.v9d
def del_tgztail(s):
for tail in ('.tgz', '.tar.gz', '.tbz', '.tar.bz2', '.tar.xz', '.tar.lz', '.zip',
......@@ -223,7 +228,12 @@ def namever(url): # -> (name, ver)
return s
url = del_tgztail(url)
name, ver = _namever(url)
_ = _namever(url, failonerr)
if _ is None:
assert not failonerr
return None
name, ver = _
if ver is not None:
# swig-3.0.12.tar.gz -> swig-3.0.12
# originally from https://sourceforge.net/projects/swig/files/swig/swig-3.0.12/swig-3.0.12.tar.gz/download
......@@ -231,7 +241,7 @@ def namever(url): # -> (name, ver)
ver = removeprefix(ver, 'v')
return name, ver
def _namever(url):
def _namever(url, failonerr):
for r in (_gitweb_re, _github_re, _github_rre, _SF_re, _go_re):
m = r.search(url)
if m is not None:
......@@ -263,6 +273,9 @@ def _namever(url):
if m is not None:
return m.group('name'), m.group('rev')
if not failonerr:
return None
raise RuntimeError('Unsupported url: %r' % (url,))
......
......@@ -86,6 +86,30 @@ repository = https://lab.nexedi.com/nexedi/neoppod.git
neoppod HEAD https://lab.nexedi.com/nexedi/neoppod.git
""")
case1("""\
[ocropy-eng-traineddata]
recipe = slapos.recipe.build:download
url = https://raw.githubusercontent.com/zuphilip/ocropy-models/master/en-default.pyrnn.gz
""", """\
ocropy-models master https://raw.githubusercontent.com/zuphilip/ocropy-models/master/en-default.pyrnn.gz
""")
case1("""\
[scons]
recipe = slapos.recipe.build:download-unpacked
url = https://prdownloads.sourceforge.net/scons/scons-local-2.3.0.tar.gz
""", """\
scons-local 2.3.0 https://prdownloads.sourceforge.net/scons/scons-local-2.3.0.tar.gz
""")
case1("""\
[ipaex-fonts]
recipe = slapos.recipe.build:download-unpacked
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
""")
for x in ('gcc', 'python', 'ZODB', 'ZEO', 'tempstorage'):
case1("""\
[%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