summaryrefslogtreecommitdiffstats
path: root/meta/classes/go-vendor.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/go-vendor.bbclass')
-rw-r--r--meta/classes/go-vendor.bbclass18
1 files changed, 17 insertions, 1 deletions
diff --git a/meta/classes/go-vendor.bbclass b/meta/classes/go-vendor.bbclass
index 2426bddfba..b965428dd1 100644
--- a/meta/classes/go-vendor.bbclass
+++ b/meta/classes/go-vendor.bbclass
@@ -169,6 +169,7 @@ python do_go_vendor() {
169 fetched_paths.remove('.') 169 fetched_paths.remove('.')
170 170
171 vendored_paths = set() 171 vendored_paths = set()
172 replaced_paths = dict()
172 with open(modules_txt_src) as f: 173 with open(modules_txt_src) as f:
173 for line in f: 174 for line in f:
174 if not line.startswith("#"): 175 if not line.startswith("#"):
@@ -182,6 +183,15 @@ python do_go_vendor() {
182 vendored_paths.add(topdir) 183 vendored_paths.add(topdir)
183 184
184 topdir = os.path.dirname(topdir) 185 topdir = os.path.dirname(topdir)
186 else:
187 replaced_module = line.split("=>")
188 if len(replaced_module) > 1:
189 # This module has been replaced, use a local path
190 # we parse the line that has a pattern "# module-name [module-version] => local-path
191 actual_path = replaced_module[1].strip()
192 vendored_name = replaced_module[0].split()[1]
193 bb.debug(1, "added vendored name %s for actual path %s" % (vendored_name, actual_path))
194 replaced_paths[vendored_name] = actual_path
185 195
186 for path in fetched_paths: 196 for path in fetched_paths:
187 if path not in vendored_paths: 197 if path not in vendored_paths:
@@ -189,7 +199,13 @@ python do_go_vendor() {
189 if os.path.exists(realpath): 199 if os.path.exists(realpath):
190 shutil.rmtree(realpath) 200 shutil.rmtree(realpath)
191 201
192 # Create a symlink the the actual directory 202 for vendored_name, replaced_path in replaced_paths.items():
203 symlink_target = os.path.join(source_dir, *['src', go_import, replaced_path])
204 symlink_name = os.path.join(vendor_dir, vendored_name)
205 bb.debug(1, "vendored name %s, symlink name %s" % (vendored_name, symlink_name))
206 os.symlink(symlink_target, symlink_name)
207
208 # Create a symlink to the actual directory
193 os.symlink(vendor_dir, linkname) 209 os.symlink(vendor_dir, linkname)
194} 210}
195 211