diff options
-rw-r--r-- | meta/classes-recipe/go-mod-update-modules.bbclass | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/meta/classes-recipe/go-mod-update-modules.bbclass b/meta/classes-recipe/go-mod-update-modules.bbclass index 5fccd0bb0d..0083588a25 100644 --- a/meta/classes-recipe/go-mod-update-modules.bbclass +++ b/meta/classes-recipe/go-mod-update-modules.bbclass | |||
@@ -15,7 +15,7 @@ do_update_modules[network] = "1" | |||
15 | python do_update_modules() { | 15 | python do_update_modules() { |
16 | import subprocess, tempfile, json, re, urllib.parse | 16 | import subprocess, tempfile, json, re, urllib.parse |
17 | from oe.license import tidy_licenses | 17 | from oe.license import tidy_licenses |
18 | from oe.license_finder import find_licenses | 18 | from oe.license_finder import find_licenses_up |
19 | 19 | ||
20 | def unescape_path(path): | 20 | def unescape_path(path): |
21 | """Unescape capital letters using exclamation points.""" | 21 | """Unescape capital letters using exclamation points.""" |
@@ -47,12 +47,10 @@ python do_update_modules() { | |||
47 | """ | 47 | """ |
48 | 48 | ||
49 | env = dict(os.environ, GOMODCACHE=mod_cache_dir) | 49 | env = dict(os.environ, GOMODCACHE=mod_cache_dir) |
50 | |||
51 | source = d.expand("${UNPACKDIR}/${GO_SRCURI_DESTSUFFIX}") | 50 | source = d.expand("${UNPACKDIR}/${GO_SRCURI_DESTSUFFIX}") |
52 | output = subprocess.check_output(("go", "mod", "edit", "-json"), cwd=source, env=env, text=True) | 51 | go_install = d.getVar("GO_INSTALL").split() |
53 | go_mod = json.loads(output) | 52 | output = subprocess.check_output(("go", "list", "-json=Dir,Module", "-deps", *go_install), |
54 | 53 | cwd=source, env=env, text=True) | |
55 | output = subprocess.check_output(("go", "list", "-json=Dir,Module", "-deps", f"{go_mod['Module']['Path']}/..."), cwd=source, env=env, text=True) | ||
56 | 54 | ||
57 | # | 55 | # |
58 | # Licenses | 56 | # Licenses |
@@ -66,26 +64,22 @@ python do_update_modules() { | |||
66 | # Very frustrating that the json parser in python can't repeatedly | 64 | # Very frustrating that the json parser in python can't repeatedly |
67 | # parse from a stream. | 65 | # parse from a stream. |
68 | pkgs = json.loads('[' + output.replace('}\n{', '},\n{') + ']') | 66 | pkgs = json.loads('[' + output.replace('}\n{', '},\n{') + ']') |
67 | |||
69 | # Collect licenses for the dependencies. | 68 | # Collect licenses for the dependencies. |
70 | licenses = set() | ||
71 | lic_files_chksum = [] | ||
72 | lic_files = {} | 69 | lic_files = {} |
73 | |||
74 | for pkg in pkgs: | 70 | for pkg in pkgs: |
75 | mod = pkg.get('Module', None) | 71 | pkg_dir = pkg['Dir'] |
76 | if not mod or mod.get('Main', False): | 72 | if not pkg_dir.startswith(mod_cache_dir): |
77 | continue | ||
78 | |||
79 | mod_dir = mod['Dir'] | ||
80 | |||
81 | if not mod_dir.startswith(mod_cache_dir): | ||
82 | continue | 73 | continue |
83 | 74 | ||
75 | mod_dir = pkg['Module']['Dir'] | ||
84 | path = os.path.relpath(mod_dir, mod_cache_dir) | 76 | path = os.path.relpath(mod_dir, mod_cache_dir) |
85 | 77 | ||
86 | for license_name, license_file, license_md5 in find_licenses(mod['Dir'], d, first_only=True, extra_hashes=extra_hashes): | 78 | for name, file, md5 in find_licenses_up(pkg_dir, mod_dir, d, first_only=True, extra_hashes=extra_hashes): |
87 | lic_files[os.path.join(path, license_file)] = (license_name, license_md5) | 79 | lic_files[os.path.join(path, file)] = (name, md5) |
88 | 80 | ||
81 | licenses = set() | ||
82 | lic_files_chksum = [] | ||
89 | for lic_file in lic_files: | 83 | for lic_file in lic_files: |
90 | license_name, license_md5 = lic_files[lic_file] | 84 | license_name, license_md5 = lic_files[lic_file] |
91 | if license_name == "Unknown": | 85 | if license_name == "Unknown": |