diff options
| author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-03-19 15:55:42 +0000 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-03-19 15:56:06 +0000 |
| commit | b1a6d274a8cf9b2248ac708f3cd35e0d04540717 (patch) | |
| tree | 64d3bd02894d714387618ae7fee2a01e929f783b | |
| parent | 6f733ac63f82cf6fdd58e2c36342495b1810c2d1 (diff) | |
| download | meta-virtualization-b1a6d274a8cf9b2248ac708f3cd35e0d04540717.tar.gz | |
go-mod-discovery/oe-go-mod-fetcher: add GO_MOD_VCS_EXCLUDE for deleted repos
Some upstream Go module repositories get deleted from GitHub (e.g.,
github.com/vtolstov/go-ioctl). While the Go module proxy still serves
cached archives, VCS mode cannot git clone a deleted repo. This causes
both do_fetch failures and generator verification failures.
Add GO_MOD_VCS_EXCLUDE recipe variable (space-separated module path
prefixes) and corresponding --exclude-module CLI flag. Excluded modules
are filtered out before verification and SRC_URI generation. Recipes
must provide a gomod:// SRC_URI entry for excluded modules as fallback.
Usage in recipe:
SRC_URI += "gomod://example.com/deleted-repo;version=v1.0.0;sha256sum=..."
GO_MOD_VCS_EXCLUDE = "example.com/deleted-repo"
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
| -rw-r--r-- | classes/go-mod-discovery.bbclass | 13 | ||||
| -rwxr-xr-x | scripts/oe-go-mod-fetcher.py | 21 |
2 files changed, 32 insertions, 2 deletions
diff --git a/classes/go-mod-discovery.bbclass b/classes/go-mod-discovery.bbclass index d41d70a5..39cc38da 100644 --- a/classes/go-mod-discovery.bbclass +++ b/classes/go-mod-discovery.bbclass | |||
| @@ -122,6 +122,11 @@ GO_MOD_DISCOVERY_RECIPEDIR ?= "${FILE_DIRNAME}" | |||
| 122 | # Usage: GO_MOD_DISCOVERY_SKIP_VERIFY = "1" in local.conf or recipe | 122 | # Usage: GO_MOD_DISCOVERY_SKIP_VERIFY = "1" in local.conf or recipe |
| 123 | GO_MOD_DISCOVERY_SKIP_VERIFY ?= "" | 123 | GO_MOD_DISCOVERY_SKIP_VERIFY ?= "" |
| 124 | 124 | ||
| 125 | # Modules to exclude from git:// generation (space-separated prefixes) | ||
| 126 | # Excluded modules must be fetched via gomod:// in the recipe's SRC_URI | ||
| 127 | # Usage: GO_MOD_VCS_EXCLUDE = "github.com/vtolstov/go-ioctl" | ||
| 128 | GO_MOD_VCS_EXCLUDE ?= "" | ||
| 129 | |||
| 125 | # Empty default for TAGS if not set by recipe (avoids undefined variable errors) | 130 | # Empty default for TAGS if not set by recipe (avoids undefined variable errors) |
| 126 | TAGS ?= "" | 131 | TAGS ?= "" |
| 127 | 132 | ||
| @@ -396,12 +401,18 @@ Or run 'bitbake ${PN} -c show_upgrade_commands' to see manual options." | |||
| 396 | SKIP_VERIFY_FLAG="--skip-verify" | 401 | SKIP_VERIFY_FLAG="--skip-verify" |
| 397 | fi | 402 | fi |
| 398 | 403 | ||
| 404 | EXCLUDE_FLAGS="" | ||
| 405 | for mod in ${GO_MOD_VCS_EXCLUDE}; do | ||
| 406 | EXCLUDE_FLAGS="${EXCLUDE_FLAGS} --exclude-module ${mod}" | ||
| 407 | done | ||
| 408 | |||
| 399 | python3 "${FETCHER_SCRIPT}" \ | 409 | python3 "${FETCHER_SCRIPT}" \ |
| 400 | --discovered-modules "${GO_MOD_DISCOVERY_MODULES_JSON}" \ | 410 | --discovered-modules "${GO_MOD_DISCOVERY_MODULES_JSON}" \ |
| 401 | --git-repo "${GO_MOD_DISCOVERY_GIT_REPO}" \ | 411 | --git-repo "${GO_MOD_DISCOVERY_GIT_REPO}" \ |
| 402 | --git-ref "${GO_MOD_DISCOVERY_GIT_REF}" \ | 412 | --git-ref "${GO_MOD_DISCOVERY_GIT_REF}" \ |
| 403 | --recipedir "${GO_MOD_DISCOVERY_RECIPEDIR}" \ | 413 | --recipedir "${GO_MOD_DISCOVERY_RECIPEDIR}" \ |
| 404 | ${SKIP_VERIFY_FLAG} | 414 | ${SKIP_VERIFY_FLAG} \ |
| 415 | ${EXCLUDE_FLAGS} | ||
| 405 | 416 | ||
| 406 | if [ $? -eq 0 ]; then | 417 | if [ $? -eq 0 ]; then |
| 407 | echo "" | 418 | echo "" |
diff --git a/scripts/oe-go-mod-fetcher.py b/scripts/oe-go-mod-fetcher.py index 5c866928..af8cbb03 100755 --- a/scripts/oe-go-mod-fetcher.py +++ b/scripts/oe-go-mod-fetcher.py | |||
| @@ -2079,6 +2079,7 @@ def _execute(args: argparse.Namespace) -> int: | |||
| 2079 | debug_limit=debug_limit, | 2079 | debug_limit=debug_limit, |
| 2080 | skip_verify=args.skip_verify, | 2080 | skip_verify=args.skip_verify, |
| 2081 | verify_jobs=args.verify_jobs, | 2081 | verify_jobs=args.verify_jobs, |
| 2082 | exclude_modules=args.exclude_module, | ||
| 2082 | ) | 2083 | ) |
| 2083 | 2084 | ||
| 2084 | if success: | 2085 | if success: |
| @@ -3869,7 +3870,7 @@ def discover_modules(source_dir: Path, gomodcache: Optional[str] = None) -> List | |||
| 3869 | def generate_recipe(modules: List[Dict], source_dir: Path, output_dir: Optional[Path], | 3870 | def generate_recipe(modules: List[Dict], source_dir: Path, output_dir: Optional[Path], |
| 3870 | git_repo: str, git_ref: str, validate_only: bool = False, | 3871 | git_repo: str, git_ref: str, validate_only: bool = False, |
| 3871 | debug_limit: Optional[int] = None, skip_verify: bool = False, | 3872 | debug_limit: Optional[int] = None, skip_verify: bool = False, |
| 3872 | verify_jobs: int = 10) -> bool: | 3873 | verify_jobs: int = 10, exclude_modules: Optional[List[str]] = None) -> bool: |
| 3873 | """ | 3874 | """ |
| 3874 | Phase 2: Recipe Generation | 3875 | Phase 2: Recipe Generation |
| 3875 | 3876 | ||
| @@ -3897,6 +3898,17 @@ def generate_recipe(modules: List[Dict], source_dir: Path, output_dir: Optional[ | |||
| 3897 | 3898 | ||
| 3898 | unresolved_commits: List[Tuple[str, str, str, str, str]] = [] | 3899 | unresolved_commits: List[Tuple[str, str, str, str, str]] = [] |
| 3899 | 3900 | ||
| 3901 | # Filter out excluded modules (e.g., deleted upstream repos that must use gomod://) | ||
| 3902 | if exclude_modules: | ||
| 3903 | before_count = len(modules) | ||
| 3904 | excluded_prefixes = [e.strip() for e in exclude_modules] | ||
| 3905 | modules = [m for m in modules if not any( | ||
| 3906 | m.get('module_path', '').startswith(prefix) for prefix in excluded_prefixes | ||
| 3907 | )] | ||
| 3908 | excluded_count = before_count - len(modules) | ||
| 3909 | if excluded_count: | ||
| 3910 | print(f"\n⚙️ Excluded {excluded_count} modules matching: {', '.join(excluded_prefixes)}") | ||
| 3911 | |||
| 3900 | total_modules = len(modules) | 3912 | total_modules = len(modules) |
| 3901 | if debug_limit is not None: | 3913 | if debug_limit is not None: |
| 3902 | print(f"\n⚙️ Debug limit active: validating first {debug_limit} modules (total list size {total_modules})") | 3914 | print(f"\n⚙️ Debug limit active: validating first {debug_limit} modules (total list size {total_modules})") |
| @@ -4518,6 +4530,13 @@ Examples: | |||
| 4518 | ) | 4530 | ) |
| 4519 | 4531 | ||
| 4520 | parser.add_argument( | 4532 | parser.add_argument( |
| 4533 | "--exclude-module", | ||
| 4534 | metavar="PREFIX", | ||
| 4535 | action="append", | ||
| 4536 | help="Exclude modules matching PREFIX from git:// generation (use gomod:// in recipe instead)" | ||
| 4537 | ) | ||
| 4538 | |||
| 4539 | parser.add_argument( | ||
| 4521 | "--version", | 4540 | "--version", |
| 4522 | action="version", | 4541 | action="version", |
| 4523 | version=f"%(prog)s {VERSION}" | 4542 | version=f"%(prog)s {VERSION}" |
