summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSven Schwermer <sven.schwermer@disruptive-technologies.com>2024-04-11 12:10:29 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-04-23 13:40:24 +0100
commite4c3483ecf496b7637d1e9fd3b0eb9ace94a09d2 (patch)
tree60a70522da14217629ff00f725c84db7edc72822 /scripts
parent0d6a71d49217eb2f036374eef2285a9046b69dc4 (diff)
downloadpoky-e4c3483ecf496b7637d1e9fd3b0eb9ace94a09d2.tar.gz
recipetool: Handle unclean response in go resolver
It appears that some go modules repond with a 404 error when trying to resolve them dynamically. The response body may still contain the go-import meta tag. An example for such behaviour is gonum.org/v1/gonum. (From OE-Core rev: 8f2e14ab6562a9a68819a960c66a258ea9dbe246) 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')
-rw-r--r--scripts/lib/recipetool/create_go.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/lib/recipetool/create_go.py b/scripts/lib/recipetool/create_go.py
index c560831442..0fb7115e26 100644
--- a/scripts/lib/recipetool/create_go.py
+++ b/scripts/lib/recipetool/create_go.py
@@ -16,7 +16,7 @@ from html.parser import HTMLParser
16from recipetool.create import RecipeHandler, handle_license_vars 16from recipetool.create import RecipeHandler, handle_license_vars
17from recipetool.create import guess_license, tidy_licenses, fixup_license 17from recipetool.create import guess_license, tidy_licenses, fixup_license
18from recipetool.create import determine_from_url 18from recipetool.create import determine_from_url
19from urllib.error import URLError 19from urllib.error import URLError, HTTPError
20 20
21import bb.utils 21import bb.utils
22import json 22import json
@@ -251,15 +251,18 @@ class GoRecipeHandler(RecipeHandler):
251 req = urllib.request.Request(url) 251 req = urllib.request.Request(url)
252 252
253 try: 253 try:
254 resp = urllib.request.urlopen(req) 254 body = urllib.request.urlopen(req).read()
255 255 except HTTPError as http_err:
256 logger.warning(
257 "Unclean status when fetching page from [%s]: %s", url, str(http_err))
258 body = http_err.fp.read()
256 except URLError as url_err: 259 except URLError as url_err:
257 logger.warning( 260 logger.warning(
258 "Failed to fetch page from [%s]: %s", url, str(url_err)) 261 "Failed to fetch page from [%s]: %s", url, str(url_err))
259 return None 262 return None
260 263
261 parser = GoImportHTMLParser() 264 parser = GoImportHTMLParser()
262 parser.feed(resp.read().decode('utf-8')) 265 parser.feed(body.decode('utf-8'))
263 parser.close() 266 parser.close()
264 267
265 return GoImport(parser.import_prefix, parser.vcs, parser.repourl, None) 268 return GoImport(parser.import_prefix, parser.vcs, parser.repourl, None)