diff options
| author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2025-12-07 03:56:40 +0000 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2025-12-08 20:57:44 -0500 |
| commit | 5760ab3c502fef3363b8aa76c71707e8ff1f5470 (patch) | |
| tree | 72f50ef82602051daa51a854712918cba47a3c20 /classes/go-mod-vcs.bbclass | |
| parent | 38e9d728a3b4631db5af80afd8db6054d3454c91 (diff) | |
| download | meta-virtualization-5760ab3c502fef3363b8aa76c71707e8ff1f5470.tar.gz | |
go-mod: make extracted files writeable
Make extracted files writable so BitBake can clean them later
Go's module cache is read-only by design, but this breaks rm -rf
and our subsquent task runs will fail.
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'classes/go-mod-vcs.bbclass')
| -rw-r--r-- | classes/go-mod-vcs.bbclass | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/classes/go-mod-vcs.bbclass b/classes/go-mod-vcs.bbclass index f7c8b27a..65211445 100644 --- a/classes/go-mod-vcs.bbclass +++ b/classes/go-mod-vcs.bbclass | |||
| @@ -671,6 +671,19 @@ python do_create_module_cache() { | |||
| 671 | try: | 671 | try: |
| 672 | with zipfile.ZipFile(zip_path, 'r') as zip_ref: | 672 | with zipfile.ZipFile(zip_path, 'r') as zip_ref: |
| 673 | zip_ref.extractall(extract_dir) | 673 | zip_ref.extractall(extract_dir) |
| 674 | # Make extracted files writable so BitBake can clean them later | ||
| 675 | # Go's module cache is read-only by design, but this breaks rm -rf | ||
| 676 | escaped_modpath = escape_module_path(module_path) | ||
| 677 | extracted_mod_dir = extract_dir / escaped_modpath / f"@{version}" | ||
| 678 | if extracted_mod_dir.exists(): | ||
| 679 | for root, dirs, files in os.walk(extracted_mod_dir): | ||
| 680 | for dir_name in dirs: | ||
| 681 | dir_path = Path(root) / dir_name | ||
| 682 | dir_path.chmod(dir_path.stat().st_mode | stat.S_IWUSR) | ||
| 683 | for file_name in files: | ||
| 684 | file_path = Path(root) / file_name | ||
| 685 | file_path.chmod(file_path.stat().st_mode | stat.S_IWUSR) | ||
| 686 | extracted_mod_dir.chmod(extracted_mod_dir.stat().st_mode | stat.S_IWUSR) | ||
| 674 | bb.debug(1, f"Extracted {module_path}@{version} to {extract_dir}") | 687 | bb.debug(1, f"Extracted {module_path}@{version} to {extract_dir}") |
| 675 | except Exception as e: | 688 | except Exception as e: |
| 676 | bb.error(f"Failed to extract {module_path}@{version}: {e}") | 689 | bb.error(f"Failed to extract {module_path}@{version}: {e}") |
