Commit 9f37fa98 authored by Jérome Perrin's avatar Jérome Perrin

support rubygemsrecipe recipe

The approach is to look in the parts directory and report everything
that has been installed in lib/ruby/gems/specifications/*.gemspec
To find the name and version, instead of trying to deduct from the
filename, we read the stub metadata from the gemspec file, using the
same login as what rubygems does in
https://github.com/rubygems/rubygems/blob/6b360fdcd2cbd72a902f4107a1deb264a6e7d3ca/lib/rubygems/stub_specification.rb#L4-L10
parent 782f8a1f
...@@ -81,6 +81,8 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo ...@@ -81,6 +81,8 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
url = '%s/%s-%s.tar.gz' % (nxdbase, name, v) url = '%s/%s-%s.tar.gz' % (nxdbase, name, v)
else: else:
url = 'https://pypi.org/project/%s/%s/' % (name, v) url = 'https://pypi.org/project/%s/%s/' % (name, v)
elif kind == 'gem':
url = 'https://rubygems.org/gems/%s/versions/%s' % (name, ver)
else: else:
raise NotImplementedError('TODO url for kind %r (urlpath: %r)' % (kind, urlpath)) raise NotImplementedError('TODO url for kind %r (urlpath: %r)' % (kind, urlpath))
...@@ -257,6 +259,11 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo ...@@ -257,6 +259,11 @@ def bom_software(installed_software_path): # -> {} (name,kind) -> PkgInfo
ver = 'HEAD' ver = 'HEAD'
addbom(repo, 'git', ver) addbom(repo, 'git', ver)
elif recipe in ('rubygemsrecipe',):
location = part.get('location', raw=True)
for gemspec in glob('%s/lib/ruby/gems/specifications/*.gemspec' % location):
addbom(gemspec, 'gem')
elif recipe in ('plone.recipe.command',): elif recipe in ('plone.recipe.command',):
# not downloading anything # not downloading anything
pass pass
...@@ -416,6 +423,14 @@ def _namever(url, failonerr): ...@@ -416,6 +423,14 @@ def _namever(url, failonerr):
if m is not None: if m is not None:
url = unquote(m.group('f')) url = unquote(m.group('f'))
if url.endswith('.gemspec'):
with open(url) as f:
_ = f.readline()
stub_line = f.readline()
dash, stub, name, ver, _, _ = stub_line.split()
assert (dash, stub) == ('#', 'stub:')
return name, ver
filename = basename(url) filename = basename(url)
name = filename name = filename
......
...@@ -453,6 +453,49 @@ case1("""\ ...@@ -453,6 +453,49 @@ case1("""\
recipe = plone.recipe.command==1.1 recipe = plone.recipe.command==1.1
""", '') """, '')
# ruby gems
case1("""\
[gems]
recipe = rubygemsrecipe
location = /ROOT/parts/gems
-- /ROOT/parts/gems/lib/ruby/gems/specifications/gitlab-puma-4.3.3.gitlab.2.gemspec --
# -*- encoding: utf-8 -*-
# stub: gitlab-puma 4.3.3.gitlab.2 ruby lib
# stub: ext/puma_http11/extconf.rb
-- /ROOT/parts/gems/lib/ruby/gems/specifications/pyu-ruby-sasl-0.0.3.3.gemspec --
# -*- encoding: utf-8 -*-
# stub: pyu-ruby-sasl 0.0.3.3 ruby lib
-- /ROOT/parts/gems/lib/ruby/gems/specifications/toml-rb-1.0.0.gemspec --
# -*- encoding: utf-8 -*-
# stub: toml-rb 1.0.0 ruby lib
-- /ROOT/parts/gems/lib/ruby/gems/specifications/tzinfo-1.2.6.gemspec --
# -*- encoding: utf-8 -*-
# stub: tzinfo 1.2.6 ruby lib
-- /ROOT/parts/gems/lib/ruby/gems/specifications/google-protobuf-3.8.0-x86_64-linux.gemspec --
# -*- encoding: utf-8 -*-
# stub: google-protobuf 3.8.0 x86_64-linux lib
-- /ROOT/parts/gems/lib/ruby/gems/specifications/apollo_upload_server-2.0.0.beta.3.gemspec --
# -*- encoding: utf-8 -*-
# stub: apollo_upload_server 2.0.0.beta.3 ruby lib
-- /ROOT/parts/gems/lib/ruby/gems/specifications/omniauth-gitlab-1.0.3.gemspec --
# -*- encoding: utf-8 -*-
# stub: omniauth-gitlab 1.0.3 ruby lib
-- /ROOT/parts/gems/lib/ruby/gems/specifications/diff_match_patch-0.1.0.gemspec --
# -*- encoding: utf-8 -*-
# stub: diff_match_patch 0.1.0 ruby lib
""", """
>>> gems:
apollo_upload_server 2.0.0.beta.3 https://rubygems.org/gems/apollo_upload_server/versions/2.0.0.beta.3
diff_match_patch 0.1.0 https://rubygems.org/gems/diff_match_patch/versions/0.1.0
gitlab-puma 4.3.3.gitlab.2 https://rubygems.org/gems/gitlab-puma/versions/4.3.3.gitlab.2
google-protobuf 3.8.0 https://rubygems.org/gems/google-protobuf/versions/3.8.0
omniauth-gitlab 1.0.3 https://rubygems.org/gems/omniauth-gitlab/versions/1.0.3
pyu-ruby-sasl 0.0.3.3 https://rubygems.org/gems/pyu-ruby-sasl/versions/0.0.3.3
toml-rb 1.0.0 https://rubygems.org/gems/toml-rb/versions/1.0.0
tzinfo 1.2.6 https://rubygems.org/gems/tzinfo/versions/1.2.6
""")
# readline 8 and 5 used simultaneously -> older one is presented as readline5 # readline 8 and 5 used simultaneously -> older one is presented as readline5
# libpng 12 and 16 used simultaneously -> ----//---- libpng12 # libpng 12 and 16 used simultaneously -> ----//---- libpng12
# ----/---- Python2 and Python3 # ----/---- Python2 and Python3
......
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