From 78343984a6699d6dcaf5e561c6e72887fee5bf3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Sat, 10 Jan 2026 20:30:01 +0100 Subject: [PATCH 1/3] phase1: apply feeds_host_override to main repository URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When feeds_host_override is configured, also apply it to the main OpenWrt repository URL (repo_url). This fixes git fetch 503 errors when git.openwrt.org is overloaded by redirecting to GitHub mirror. git fetch -f -t https://git.openwrt.org/openwrt/openwrt.git main --progress error: RPC failed; HTTP 503 curl 22 The requested URL returned error: 503 fatal: the remote end hung up unexpectedly Signed-off-by: Petr Štetiar --- phase1/master.cfg | 15 +++++++++++++++ phase2/master.cfg | 2 ++ 2 files changed, 17 insertions(+) diff --git a/phase1/master.cfg b/phase1/master.cfg index 9967eaf..c045120 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -109,6 +109,9 @@ def ini_parse_branch(section): pb_port = inip1.get("port") or 9989 feeds_host_override = inip1.get("feeds_host_override", "").strip() +if feeds_host_override: + repo_url = re.sub(r"git\.openwrt\.org/openwrt", feeds_host_override, repo_url) + # This is the dictionary that the buildmaster pays attention to. We also use # a shorter alias to save typing. c = BuildmasterConfig = {} @@ -920,6 +923,18 @@ def prepareFactory(target): ) ) + # keep existing checkouts aligned to the configured repo_url if it changes via feeds_host_override + factory.addStep( + ShellCommand( + name="setorigin", + description="Syncing Git origin URL", + descriptionDone="Git origin URL synced", + command=["sh", "-c", 'test ! -d .git || git remote set-url origin "$REPO_URL"'], + env={"REPO_URL": repo_url}, + haltOnFailure=True, + ) + ) + # workaround for https://github.com/openwrt/buildbot/issues/5 factory.addStep( Git( diff --git a/phase2/master.cfg b/phase2/master.cfg index 7af1b30..0a5bd7e 100644 --- a/phase2/master.cfg +++ b/phase2/master.cfg @@ -69,6 +69,8 @@ if ini.has_option("phase2", "port"): if ini.has_option("phase2", "persistent"): persistent = ini.getboolean("phase2", "persistent") +feeds_host_override = ini.get("phase2", "feeds_host_override", fallback="").strip() + c['workers'] = [] for section in ini.sections(): From 4bace77250fc67c776f0cd3aa2d6ce4b5ce021bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Sun, 11 Jan 2026 07:48:41 +0100 Subject: [PATCH 2/3] phase1: simplify feeds host override with SDK cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Write to feeds.conf instead of modifying feeds.conf.default in place as the `feeds update` checks feeds.conf first, so no backup/restore dance is needed. Fixes: 057e8adc9d49 ("phase1: add support for overriding feeds host") Signed-off-by: Petr Štetiar --- phase1/master.cfg | 49 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/phase1/master.cfg b/phase1/master.cfg index c045120..6f2b406 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -1011,32 +1011,15 @@ def prepareFactory(target): ) ) - factory.addStep( - ShellCommand( - name="feeds-backup", - description="Backing up feeds.conf.default", - descriptionDone="feeds.conf.default backed up", - command=["cp", "-p", "feeds.conf.default", "feeds.conf.default.bak"], - doStepIf=IsFeedsHostOverrideEnabled, - haltOnFailure=True, - ) - ) - factory.addStep( ShellCommand( name="feeds-override", - description="Overriding feeds host", - descriptionDone="Feeds host overridden", - command=[ - "sed", - "-i", - "-E", - Interpolate( - "s;git.openwrt.org/(feed|project);%(kw:host)s;", - host=GetFeedsHostOverride, - ), - "feeds.conf.default", - ], + description="Creating feeds.conf with host override", + descriptionDone="feeds.conf with override created", + command=Interpolate( + "sed -E 's;git.openwrt.org/(feed|project);%(kw:host)s;' feeds.conf.default > feeds.conf", + host=GetFeedsHostOverride, + ), doStepIf=IsFeedsHostOverrideEnabled, haltOnFailure=True, ) @@ -1054,24 +1037,24 @@ def prepareFactory(target): ) ) + # feed factory.addStep( ShellCommand( - name="feeds-restore", - description="Restoring feeds.conf.default", - descriptionDone="feeds.conf.default restored", - command="test -f feeds.conf.default.bak && mv -f feeds.conf.default.bak feeds.conf.default || true", - doStepIf=IsFeedsHostOverrideEnabled, + name="installfeeds", + description="Installing feeds", + command=["./scripts/feeds", "install", "-a"], + env=MakeEnv(tryccache=True), haltOnFailure=True, ) ) - # feed factory.addStep( ShellCommand( - name="installfeeds", - description="Installing feeds", - command=["./scripts/feeds", "install", "-a"], - env=MakeEnv(tryccache=True), + name="feeds-cleanup", + description="Removing feeds.conf override", + descriptionDone="feeds.conf override removed", + command=["rm", "-f", "feeds.conf"], + doStepIf=IsFeedsHostOverrideEnabled, haltOnFailure=True, ) ) From f2c82f2232b2ebdf1e643b38b406e41923181a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Sun, 11 Jan 2026 09:43:43 +0100 Subject: [PATCH 3/3] phase2: add support for overriding feeds host MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Port the feeds_host_override functionality from phase1 to phase2, allowing phase2 builds to use alternate feed hosts. Signed-off-by: Petr Štetiar --- phase2/config.ini.example | 1 + phase2/master.cfg | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/phase2/config.ini.example b/phase2/config.ini.example index eda9763..fcb6f06 100644 --- a/phase2/config.ini.example +++ b/phase2/config.ini.example @@ -10,6 +10,7 @@ status_user = example status_password = example port = 9990 persistent = false +feeds_host_override = git_ssh = true git_ssh_key = -----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEAuCJwo6OmrRDxcGfsMgBhq0vdzp2ZIdqnedFH8u6tVYLt9WDU diff --git a/phase2/master.cfg b/phase2/master.cfg index 0a5bd7e..939d688 100644 --- a/phase2/master.cfg +++ b/phase2/master.cfg @@ -136,6 +136,9 @@ repo_branch = "main" if ini.has_option("repo", "branch"): repo_branch = ini.get("repo", "branch") +if feeds_host_override: + repo_url = re.sub(r"git\.openwrt\.org/openwrt", feeds_host_override, repo_url) + usign_key = None usign_comment = "untrusted comment: " + repo_branch.replace("-", " ").title() + " key" @@ -153,6 +156,7 @@ archnames = [ ] if not os.path.isdir(work_dir+'/source.git'): subprocess.call(["git", "clone", "--depth=1", "--branch="+repo_branch, repo_url, work_dir+'/source.git']) else: + subprocess.call(["git", "remote", "set-url", "origin", repo_url], cwd = work_dir+'/source.git') subprocess.call(["git", "pull"], cwd = work_dir+'/source.git') os.makedirs(work_dir+'/source.git/tmp', exist_ok=True) @@ -321,6 +325,13 @@ def IsSignEnabled(step): IsUsignEnabled(step) or IsApkSigningEnabled(step) or IsGpgSigningEnabled(step) ) +def IsFeedsHostOverrideEnabled(step): + return bool(feeds_host_override) + +@util.renderer +def GetFeedsHostOverride(props): + return feeds_host_override + @defer.inlineCallbacks def getNewestCompleteTime(bldr): """Returns the complete_at of the latest completed and not SKIPPED @@ -548,6 +559,18 @@ for arch in arches: command = ["./ccache.sh"], haltOnFailure = True)) + factory.addStep(ShellCommand( + name = "feeds-override", + description = "Creating feeds.conf with host override", + descriptionDone = "feeds.conf with override created", + workdir = "build/sdk", + command = Interpolate( + "sed -E 's;git.openwrt.org/(feed|project);%(kw:host)s;' feeds.conf.default > feeds.conf", + host=GetFeedsHostOverride, + ), + doStepIf = IsFeedsHostOverrideEnabled, + haltOnFailure = True)) + factory.addStep(ShellCommand( name = "updatefeeds", description = "Updating feeds", @@ -562,6 +585,15 @@ for arch in arches: command = ["./scripts/feeds", "install", "-a"], haltOnFailure = True)) + factory.addStep(ShellCommand( + name = "feeds-cleanup", + description = "Removing feeds.conf override", + descriptionDone = "feeds.conf override removed", + workdir = "build/sdk", + command = ["rm", "-f", "feeds.conf"], + doStepIf = IsFeedsHostOverrideEnabled, + haltOnFailure = True)) + factory.addStep(ShellCommand( name = "logclear", description = "Clearing failure logs",