phase2: add support for overriding feeds host v26
authorPetr Štetiar <ynezz@true.cz>
Sun, 11 Jan 2026 08:43:43 +0000 (09:43 +0100)
committerPetr Štetiar <ynezz@true.cz>
Mon, 12 Jan 2026 21:28:00 +0000 (22:28 +0100)
Port the feeds_host_override functionality from phase1 to phase2,
allowing phase2 builds to use alternate feed hosts.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
phase2/config.ini.example
phase2/master.cfg

index eda9763530ed30a6df6f10b20d9b449b9220f094..fcb6f06aba602bc817c0cdc283469b00f9e9ce7e 100644 (file)
@@ -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
index 0a5bd7e1ebeaae778eb63e65b58c0b37e8840b90..939d688257779854b18fdfe76c7c476139c033cc 100644 (file)
@@ -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",