diff options
author | Sven Schwermer <sven.schwermer@disruptive-technologies.com> | 2024-04-11 12:10:30 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-04-23 13:40:24 +0100 |
commit | 8219eefdd808bc1abed165cec3764cc5583c2149 (patch) | |
tree | e737b47bc60a8d0f4365436fff08b1cb874b61b7 /scripts/lib | |
parent | e4c3483ecf496b7637d1e9fd3b0eb9ace94a09d2 (diff) | |
download | poky-8219eefdd808bc1abed165cec3764cc5583c2149.tar.gz |
recipetool: Handle several go-import tags in go resolver
When dynamically resolving go modules, the HTML page may contain several
go-import meta tags. We must handle all and pick the correct one based
on the module name. An example for such a behaviour is
gonum.org/v1/gonum:
<meta name="go-import" content="gonum.org/v1/exp git https://github.com/gonum/exp">
<meta name="go-import" content="gonum.org/v1/gonum git https://github.com/gonum/gonum">
<meta name="go-import" content="gonum.org/v1/hdf5 git https://github.com/gonum/hdf5">
<meta name="go-import" content="gonum.org/v1/netlib git https://github.com/gonum/netlib">
<meta name="go-import" content="gonum.org/v1/plot git https://github.com/gonum/plot">
<meta name="go-import" content="gonum.org/v1/tools git https://github.com/gonum/tools">
(From OE-Core rev: 9c36a61e29359067165bddc7f2accdf2c4c8a761)
Signed-off-by: Sven Schwermer <sven.schwermer@disruptive-technologies.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/recipetool/create_go.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/scripts/lib/recipetool/create_go.py b/scripts/lib/recipetool/create_go.py index 0fb7115e26..a85a2f2786 100644 --- a/scripts/lib/recipetool/create_go.py +++ b/scripts/lib/recipetool/create_go.py | |||
@@ -225,7 +225,7 @@ class GoRecipeHandler(RecipeHandler): | |||
225 | 225 | ||
226 | def __init__(self): | 226 | def __init__(self): |
227 | super().__init__() | 227 | super().__init__() |
228 | self.__srv = [] | 228 | self.__srv = {} |
229 | 229 | ||
230 | def handle_starttag(self, tag, attrs): | 230 | def handle_starttag(self, tag, attrs): |
231 | if tag == 'meta' and list( | 231 | if tag == 'meta' and list( |
@@ -233,19 +233,14 @@ class GoRecipeHandler(RecipeHandler): | |||
233 | content = list( | 233 | content = list( |
234 | filter(lambda a: (a[0] == 'content'), attrs)) | 234 | filter(lambda a: (a[0] == 'content'), attrs)) |
235 | if content: | 235 | if content: |
236 | self.__srv = content[0][1].split() | 236 | srv = content[0][1].split() |
237 | self.__srv[srv[0]] = srv | ||
237 | 238 | ||
238 | @property | 239 | def go_import(self, modulepath): |
239 | def import_prefix(self): | 240 | if modulepath in self.__srv: |
240 | return self.__srv[0] if len(self.__srv) else None | 241 | srv = self.__srv[modulepath] |
241 | 242 | return GoImport(srv[0], srv[1], srv[2], None) | |
242 | @property | 243 | return None |
243 | def vcs(self): | ||
244 | return self.__srv[1] if len(self.__srv) else None | ||
245 | |||
246 | @property | ||
247 | def repourl(self): | ||
248 | return self.__srv[2] if len(self.__srv) else None | ||
249 | 244 | ||
250 | url = url.geturl() + "?go-get=1" | 245 | url = url.geturl() + "?go-get=1" |
251 | req = urllib.request.Request(url) | 246 | req = urllib.request.Request(url) |
@@ -265,7 +260,7 @@ class GoRecipeHandler(RecipeHandler): | |||
265 | parser.feed(body.decode('utf-8')) | 260 | parser.feed(body.decode('utf-8')) |
266 | parser.close() | 261 | parser.close() |
267 | 262 | ||
268 | return GoImport(parser.import_prefix, parser.vcs, parser.repourl, None) | 263 | return parser.go_import(modulepath) |
269 | 264 | ||
270 | def __resolve_from_golang_proxy(self, modulepath, version): | 265 | def __resolve_from_golang_proxy(self, modulepath, version): |
271 | """ | 266 | """ |