From b1a6d274a8cf9b2248ac708f3cd35e0d04540717 Mon Sep 17 00:00:00 2001 From: Bruce Ashfield Date: Thu, 19 Mar 2026 15:55:42 +0000 Subject: 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 --- classes/go-mod-discovery.bbclass | 13 ++++++++++++- 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}" # Usage: GO_MOD_DISCOVERY_SKIP_VERIFY = "1" in local.conf or recipe GO_MOD_DISCOVERY_SKIP_VERIFY ?= "" +# Modules to exclude from git:// generation (space-separated prefixes) +# Excluded modules must be fetched via gomod:// in the recipe's SRC_URI +# Usage: GO_MOD_VCS_EXCLUDE = "github.com/vtolstov/go-ioctl" +GO_MOD_VCS_EXCLUDE ?= "" + # Empty default for TAGS if not set by recipe (avoids undefined variable errors) TAGS ?= "" @@ -396,12 +401,18 @@ Or run 'bitbake ${PN} -c show_upgrade_commands' to see manual options." SKIP_VERIFY_FLAG="--skip-verify" fi + EXCLUDE_FLAGS="" + for mod in ${GO_MOD_VCS_EXCLUDE}; do + EXCLUDE_FLAGS="${EXCLUDE_FLAGS} --exclude-module ${mod}" + done + python3 "${FETCHER_SCRIPT}" \ --discovered-modules "${GO_MOD_DISCOVERY_MODULES_JSON}" \ --git-repo "${GO_MOD_DISCOVERY_GIT_REPO}" \ --git-ref "${GO_MOD_DISCOVERY_GIT_REF}" \ --recipedir "${GO_MOD_DISCOVERY_RECIPEDIR}" \ - ${SKIP_VERIFY_FLAG} + ${SKIP_VERIFY_FLAG} \ + ${EXCLUDE_FLAGS} if [ $? -eq 0 ]; then 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: debug_limit=debug_limit, skip_verify=args.skip_verify, verify_jobs=args.verify_jobs, + exclude_modules=args.exclude_module, ) if success: @@ -3869,7 +3870,7 @@ def discover_modules(source_dir: Path, gomodcache: Optional[str] = None) -> List def generate_recipe(modules: List[Dict], source_dir: Path, output_dir: Optional[Path], git_repo: str, git_ref: str, validate_only: bool = False, debug_limit: Optional[int] = None, skip_verify: bool = False, - verify_jobs: int = 10) -> bool: + verify_jobs: int = 10, exclude_modules: Optional[List[str]] = None) -> bool: """ Phase 2: Recipe Generation @@ -3897,6 +3898,17 @@ def generate_recipe(modules: List[Dict], source_dir: Path, output_dir: Optional[ unresolved_commits: List[Tuple[str, str, str, str, str]] = [] + # Filter out excluded modules (e.g., deleted upstream repos that must use gomod://) + if exclude_modules: + before_count = len(modules) + excluded_prefixes = [e.strip() for e in exclude_modules] + modules = [m for m in modules if not any( + m.get('module_path', '').startswith(prefix) for prefix in excluded_prefixes + )] + excluded_count = before_count - len(modules) + if excluded_count: + print(f"\n⚙️ Excluded {excluded_count} modules matching: {', '.join(excluded_prefixes)}") + total_modules = len(modules) if debug_limit is not None: print(f"\n⚙️ Debug limit active: validating first {debug_limit} modules (total list size {total_modules})") @@ -4517,6 +4529,13 @@ Examples: help="Remove a previously pinned repository override (module or module@version)" ) + parser.add_argument( + "--exclude-module", + metavar="PREFIX", + action="append", + help="Exclude modules matching PREFIX from git:// generation (use gomod:// in recipe instead)" + ) + parser.add_argument( "--version", action="version", -- cgit v1.2.3-54-g00ecf