summaryrefslogtreecommitdiffstats
path: root/scripts/lib/recipetool/create_go.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/recipetool/create_go.py')
-rw-r--r--scripts/lib/recipetool/create_go.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/scripts/lib/recipetool/create_go.py b/scripts/lib/recipetool/create_go.py
index 035ab9f7c1..c560831442 100644
--- a/scripts/lib/recipetool/create_go.py
+++ b/scripts/lib/recipetool/create_go.py
@@ -506,6 +506,7 @@ class GoRecipeHandler(RecipeHandler):
506 506
507 def __go_handle_dependencies(self, go_mod, srctree, localfilesdir, extravalues, d): 507 def __go_handle_dependencies(self, go_mod, srctree, localfilesdir, extravalues, d):
508 508
509 import re
509 src_uris = [] 510 src_uris = []
510 src_revs = [] 511 src_revs = []
511 512
@@ -555,7 +556,9 @@ class GoRecipeHandler(RecipeHandler):
555 src_uris.append(inline_fcn) 556 src_uris.append(inline_fcn)
556 src_revs.append(generate_src_rev(path, version, commithash)) 557 src_revs.append(generate_src_rev(path, version, commithash))
557 558
558 pn, _ = determine_from_url(go_mod['Module']['Path']) 559 # strip version part from module URL /vXX
560 baseurl = re.sub(r'/v(\d+)$', '', go_mod['Module']['Path'])
561 pn, _ = determine_from_url(baseurl)
559 go_mods_basename = "%s-modules.inc" % pn 562 go_mods_basename = "%s-modules.inc" % pn
560 563
561 go_mods_filename = os.path.join(localfilesdir, go_mods_basename) 564 go_mods_filename = os.path.join(localfilesdir, go_mods_basename)
@@ -636,7 +639,9 @@ class GoRecipeHandler(RecipeHandler):
636 lic_files_chksum.append( 639 lic_files_chksum.append(
637 'file://src/${GO_IMPORT}/vendor/%s;md5=%s' % (licvalue[1], licvalue[2])) 640 'file://src/${GO_IMPORT}/vendor/%s;md5=%s' % (licvalue[1], licvalue[2]))
638 641
639 pn, _ = determine_from_url(go_mod['Module']['Path']) 642 # strip version part from module URL /vXX
643 baseurl = re.sub(r'/v(\d+)$', '', go_mod['Module']['Path'])
644 pn, _ = determine_from_url(baseurl)
640 licenses_basename = "%s-licenses.inc" % pn 645 licenses_basename = "%s-licenses.inc" % pn
641 646
642 licenses_filename = os.path.join(localfilesdir, licenses_basename) 647 licenses_filename = os.path.join(localfilesdir, licenses_basename)
@@ -682,6 +687,13 @@ class GoRecipeHandler(RecipeHandler):
682 687
683 localfilesdir = tempfile.mkdtemp(prefix='recipetool-go-') 688 localfilesdir = tempfile.mkdtemp(prefix='recipetool-go-')
684 extravalues.setdefault('extrafiles', {}) 689 extravalues.setdefault('extrafiles', {})
690
691 # Use an explicit name determined from the module name because it
692 # might differ from the actual URL for replaced modules
693 # strip version part from module URL /vXX
694 baseurl = re.sub(r'/v(\d+)$', '', go_mod['Module']['Path'])
695 pn, _ = determine_from_url(baseurl)
696
685 # go.mod files with version < 1.17 may not include all indirect 697 # go.mod files with version < 1.17 may not include all indirect
686 # dependencies. Thus, we have to upgrade the go version. 698 # dependencies. Thus, we have to upgrade the go version.
687 if go_version_major == 1 and go_version_minor < 17: 699 if go_version_major == 1 and go_version_minor < 17:
@@ -699,18 +711,18 @@ class GoRecipeHandler(RecipeHandler):
699 # Write additional $BPN-modules.inc file 711 # Write additional $BPN-modules.inc file
700 self.__go_mod_vendor(go_mod, srctree, localfilesdir, extravalues, d) 712 self.__go_mod_vendor(go_mod, srctree, localfilesdir, extravalues, d)
701 lines_before.append("LICENSE += \" & ${GO_MOD_LICENSES}\"") 713 lines_before.append("LICENSE += \" & ${GO_MOD_LICENSES}\"")
702 lines_before.append("require ${BPN}-licenses.inc") 714 lines_before.append("require %s-licenses.inc" % (pn))
703 715
704 self.__rewrite_src_uri(lines_before, ["file://modules.txt"]) 716 self.__rewrite_src_uri(lines_before, ["file://modules.txt"])
705 717
706 self.__go_handle_dependencies(go_mod, srctree, localfilesdir, extravalues, d) 718 self.__go_handle_dependencies(go_mod, srctree, localfilesdir, extravalues, d)
707 lines_before.append("require ${BPN}-modules.inc") 719 lines_before.append("require %s-modules.inc" % (pn))
708 720
709 # Do generic license handling 721 # Do generic license handling
710 handle_license_vars(srctree, lines_before, handled, extravalues, d) 722 handle_license_vars(srctree, lines_before, handled, extravalues, d)
711 self.__rewrite_lic_uri(lines_before) 723 self.__rewrite_lic_uri(lines_before)
712 724
713 lines_before.append("GO_IMPORT = \"{}\"".format(go_import)) 725 lines_before.append("GO_IMPORT = \"{}\"".format(baseurl))
714 lines_before.append("SRCREV_FORMAT = \"${BPN}\"") 726 lines_before.append("SRCREV_FORMAT = \"${BPN}\"")
715 727
716 def __update_lines_before(self, updated, newlines, lines_before): 728 def __update_lines_before(self, updated, newlines, lines_before):