summaryrefslogtreecommitdiffstats
path: root/classes/go-mod-discovery.bbclass
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2025-12-05 19:33:04 +0000
committerBruce Ashfield <bruce.ashfield@gmail.com>2025-12-08 20:57:44 -0500
commitdf651f904ee91b3cf9face353af8219223442e6b (patch)
tree6a3b0eceeef219168afe291b65b38d98e5d7b11d /classes/go-mod-discovery.bbclass
parentae9fa39e6f52e71052ba37c54a7e0b3aea2e7ee3 (diff)
downloadmeta-virtualization-df651f904ee91b3cf9face353af8219223442e6b.tar.gz
discover: manage go.* files
The discovery repository can be in an incosistent state after a build. By restoring the go.* files, we ensure a stable start point. Add automatic removal of go.sum files from git-fetched dependencies in vcs_cache during do_create_module_cache. This prevents checksum mismatch errors caused by stale go.sum files in dependencies having different checksums than the git-sourced modules. Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'classes/go-mod-discovery.bbclass')
-rw-r--r--classes/go-mod-discovery.bbclass15
1 files changed, 15 insertions, 0 deletions
diff --git a/classes/go-mod-discovery.bbclass b/classes/go-mod-discovery.bbclass
index 05265c20..d57a7d38 100644
--- a/classes/go-mod-discovery.bbclass
+++ b/classes/go-mod-discovery.bbclass
@@ -184,9 +184,20 @@ Hint: Set GO_MOD_DISCOVERY_SRCDIR to the directory containing go.mod"
184 echo "LDFLAGS: ${GO_MOD_DISCOVERY_LDFLAGS}" 184 echo "LDFLAGS: ${GO_MOD_DISCOVERY_LDFLAGS}"
185 echo "" 185 echo ""
186 186
187 # Restore original go.sum from git if it was modified by do_create_module_cache
188 # The build task rewrites go.sum with git-based checksums, but discovery needs
189 # the original proxy-based checksums to download from proxy.golang.org
190 if git -C "${GO_MOD_DISCOVERY_SRCDIR}" diff --quiet go.sum 2>/dev/null; then
191 echo "go.sum is clean"
192 else
193 echo "Restoring original go.sum from git (was modified by previous build)..."
194 git -C "${GO_MOD_DISCOVERY_SRCDIR}" checkout go.sum
195 fi
196
187 # Use native go binary 197 # Use native go binary
188 GO_NATIVE="${STAGING_DIR_NATIVE}${bindir_native}/go" 198 GO_NATIVE="${STAGING_DIR_NATIVE}${bindir_native}/go"
189 199
200 echo ""
190 echo "Running: go build (to discover all modules)..." 201 echo "Running: go build (to discover all modules)..."
191 202
192 BUILD_CMD="${GO_NATIVE} build -v -trimpath" 203 BUILD_CMD="${GO_NATIVE} build -v -trimpath"
@@ -341,9 +352,13 @@ Add to your recipe: GO_MOD_DISCOVERY_GIT_REPO = \"https://github.com/...\"
341Or run 'bitbake ${PN} -c show_upgrade_commands' to see manual options." 352Or run 'bitbake ${PN} -c show_upgrade_commands' to see manual options."
342 fi 353 fi
343 354
355 # CRITICAL: Change to source directory so oe-go-mod-fetcher.py can find go.mod/go.sum
356 cd "${GO_MOD_DISCOVERY_SRCDIR}"
357
344 echo "======================================================================" 358 echo "======================================================================"
345 echo "GENERATING RECIPE FILES: ${PN} ${PV}" 359 echo "GENERATING RECIPE FILES: ${PN} ${PV}"
346 echo "======================================================================" 360 echo "======================================================================"
361 echo "Source dir: ${GO_MOD_DISCOVERY_SRCDIR}"
347 echo "Modules JSON: ${GO_MOD_DISCOVERY_MODULES_JSON}" 362 echo "Modules JSON: ${GO_MOD_DISCOVERY_MODULES_JSON}"
348 echo "Git repo: ${GO_MOD_DISCOVERY_GIT_REPO}" 363 echo "Git repo: ${GO_MOD_DISCOVERY_GIT_REPO}"
349 echo "Git ref: ${GO_MOD_DISCOVERY_GIT_REF}" 364 echo "Git ref: ${GO_MOD_DISCOVERY_GIT_REF}"