diff options
| author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-02-09 05:03:51 +0000 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-02-09 05:07:01 +0000 |
| commit | ed5b33932e5f9ad8dc530a53fddfc865fc60d60c (patch) | |
| tree | b62080019a7238962e802bcad7d4a299d2c1537f /classes | |
| parent | 1553125eb4f5f8ac549bac6843138d94faa44e7b (diff) | |
| download | meta-virtualization-ed5b33932e5f9ad8dc530a53fddfc865fc60d60c.tar.gz | |
go-mod-vcs: fix do_rm_work permission failure on module cache
go build creates read-only files in the module cache during
do_compile. The previous do_fix_go_mod_permissions task ran before
do_compile, so it could not catch these files, causing do_rm_work
to fail with permission errors.
Replace the standalone task with a do_compile postfunc that fixes
module cache permissions after compilation finishes. This covers
all go-mod-vcs recipes regardless of how they invoke go build.
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'classes')
| -rw-r--r-- | classes/go-mod-vcs.bbclass | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/classes/go-mod-vcs.bbclass b/classes/go-mod-vcs.bbclass index 549fa9f5..c08894d5 100644 --- a/classes/go-mod-vcs.bbclass +++ b/classes/go-mod-vcs.bbclass | |||
| @@ -1140,29 +1140,21 @@ python do_sync_go_files() { | |||
| 1140 | addtask sync_go_files after do_create_module_cache before do_compile | 1140 | addtask sync_go_files after do_create_module_cache before do_compile |
| 1141 | 1141 | ||
| 1142 | 1142 | ||
| 1143 | do_fix_go_mod_permissions() { | 1143 | go_mod_fix_module_cache_permissions() { |
| 1144 | # Go module cache is intentionally read-only for integrity, but this breaks | 1144 | # Go creates read-only files in the module cache by design. |
| 1145 | # BitBake's rm -rf cleanup (sstate_eventhandler_reachablestamps). | 1145 | # Fix permissions after do_compile so do_rm_work can clean up. |
| 1146 | # Make all files writable so workdir can be cleaned properly. | ||
| 1147 | # | ||
| 1148 | # Check multiple possible locations where Go module cache might exist | ||
| 1149 | for modpath in "${S}/pkg/mod" "${S}/src/import/pkg/mod"; do | 1146 | for modpath in "${S}/pkg/mod" "${S}/src/import/pkg/mod"; do |
| 1150 | if [ -d "$modpath" ]; then | 1147 | if [ -d "$modpath" ]; then |
| 1151 | chmod -R u+w "$modpath" 2>/dev/null || true | 1148 | chmod -R u+w "$modpath" 2>/dev/null || true |
| 1152 | bbnote "Fixed permissions on Go module cache: $modpath" | ||
| 1153 | fi | 1149 | fi |
| 1154 | done | 1150 | done |
| 1155 | # Also check sources subdirectory (for recipes with WORKDIR/sources layout) | ||
| 1156 | if [ -d "${WORKDIR}/sources" ]; then | 1151 | if [ -d "${WORKDIR}/sources" ]; then |
| 1157 | find "${WORKDIR}/sources" -type d -name "mod" -path "*/pkg/mod" 2>/dev/null | while read modpath; do | 1152 | find "${WORKDIR}/sources" -type d -name "mod" -path "*/pkg/mod" 2>/dev/null | while read modpath; do |
| 1158 | chmod -R u+w "$modpath" 2>/dev/null || true | 1153 | chmod -R u+w "$modpath" 2>/dev/null || true |
| 1159 | bbnote "Fixed permissions on Go module cache: $modpath" | ||
| 1160 | done | 1154 | done |
| 1161 | fi | 1155 | fi |
| 1162 | } | 1156 | } |
| 1163 | 1157 | do_compile[postfuncs] += "go_mod_fix_module_cache_permissions" | |
| 1164 | # Run after sync_go_files (which is the last Go module setup task) and before compile | ||
| 1165 | addtask fix_go_mod_permissions after do_sync_go_files before do_compile | ||
| 1166 | 1158 | ||
| 1167 | 1159 | ||
| 1168 | python do_go_mod_recommend() { | 1160 | python do_go_mod_recommend() { |
