diff options
| author | Vyacheslav Yurkov <uvv.mail@gmail.com> | 2024-01-16 09:23:19 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-01-19 12:21:22 +0000 |
| commit | 0161d08ac93a286f09c4e757d817a40f1a2a1602 (patch) | |
| tree | 597876153b6a13ce0b1b9264170db7fe191e1484 /scripts/lib | |
| parent | 376a8a1f3addd9a942829329475b2b7e7a08b2a6 (diff) | |
| download | poky-0161d08ac93a286f09c4e757d817a40f1a2a1602.tar.gz | |
recipetool: Don't fail on local go modules
Local modules are usually referenced with a 'replace' directive in
go.mod file. If that's the case, remove them from populating SRC_URI.
(From OE-Core rev: 9f220f61e3e44a650a46ee997b47f1d87b7c4ef0)
Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/recipetool/create_go.py | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/scripts/lib/recipetool/create_go.py b/scripts/lib/recipetool/create_go.py index 21dcb41271..668a24b8dd 100644 --- a/scripts/lib/recipetool/create_go.py +++ b/scripts/lib/recipetool/create_go.py | |||
| @@ -504,7 +504,7 @@ class GoRecipeHandler(RecipeHandler): | |||
| 504 | 504 | ||
| 505 | return inline_fcn, commit | 505 | return inline_fcn, commit |
| 506 | 506 | ||
| 507 | def __go_handle_dependencies(self, go_mod, localfilesdir, extravalues, d): | 507 | def __go_handle_dependencies(self, go_mod, srctree, localfilesdir, extravalues, d): |
| 508 | 508 | ||
| 509 | src_uris = [] | 509 | src_uris = [] |
| 510 | src_revs = [] | 510 | src_revs = [] |
| @@ -525,6 +525,27 @@ class GoRecipeHandler(RecipeHandler): | |||
| 525 | 525 | ||
| 526 | return src_rev | 526 | return src_rev |
| 527 | 527 | ||
| 528 | # we first go over replacement list, because we are essentialy | ||
| 529 | # interested only in the replaced path | ||
| 530 | if go_mod['Replace']: | ||
| 531 | for replacement in go_mod['Replace']: | ||
| 532 | oldpath = replacement['Old']['Path'] | ||
| 533 | path = replacement['New']['Path'] | ||
| 534 | version = '' | ||
| 535 | if 'Version' in replacement['New']: | ||
| 536 | version = replacement['New']['Version'] | ||
| 537 | |||
| 538 | if os.path.exists(os.path.join(srctree, path)): | ||
| 539 | # the module refers to the local path, remove it from requirement list | ||
| 540 | # because it's a local module | ||
| 541 | go_mod['Require'][:] = [v for v in go_mod['Require'] if v.get('Path') != oldpath] | ||
| 542 | else: | ||
| 543 | # Replace the path and the version, so we don't iterate replacement list anymore | ||
| 544 | for require in go_mod['Require']: | ||
| 545 | if require['Path'] == oldpath: | ||
| 546 | require.update({'Path': path, 'Version': version}) | ||
| 547 | break | ||
| 548 | |||
| 528 | for require in go_mod['Require']: | 549 | for require in go_mod['Require']: |
| 529 | path = require['Path'] | 550 | path = require['Path'] |
| 530 | version = require['Version'] | 551 | version = require['Version'] |
| @@ -534,17 +555,6 @@ class GoRecipeHandler(RecipeHandler): | |||
| 534 | src_uris.append(inline_fcn) | 555 | src_uris.append(inline_fcn) |
| 535 | src_revs.append(generate_src_rev(path, version, commithash)) | 556 | src_revs.append(generate_src_rev(path, version, commithash)) |
| 536 | 557 | ||
| 537 | if go_mod['Replace']: | ||
| 538 | for replacement in go_mod['Replace']: | ||
| 539 | oldpath = replacement['Old']['Path'] | ||
| 540 | path = replacement['New']['Path'] | ||
| 541 | version = replacement['New']['Version'] | ||
| 542 | |||
| 543 | inline_fcn, commithash = self.__generate_srcuri_inline_fcn( | ||
| 544 | path, version, oldpath) | ||
| 545 | src_uris.append(inline_fcn) | ||
| 546 | src_revs.append(generate_src_rev(path, version, commithash)) | ||
| 547 | |||
| 548 | pn, _ = determine_from_url(go_mod['Module']['Path']) | 558 | pn, _ = determine_from_url(go_mod['Module']['Path']) |
| 549 | go_mods_basename = "%s-modules.inc" % pn | 559 | go_mods_basename = "%s-modules.inc" % pn |
| 550 | 560 | ||
| @@ -693,7 +703,7 @@ class GoRecipeHandler(RecipeHandler): | |||
| 693 | 703 | ||
| 694 | self.__rewrite_src_uri(lines_before, ["file://modules.txt"]) | 704 | self.__rewrite_src_uri(lines_before, ["file://modules.txt"]) |
| 695 | 705 | ||
| 696 | self.__go_handle_dependencies(go_mod, localfilesdir, extravalues, d) | 706 | self.__go_handle_dependencies(go_mod, srctree, localfilesdir, extravalues, d) |
| 697 | lines_before.append("require ${BPN}-modules.inc") | 707 | lines_before.append("require ${BPN}-modules.inc") |
| 698 | 708 | ||
| 699 | # Do generic license handling | 709 | # Do generic license handling |
