Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 31 additions & 33 deletions phase1/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -996,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,
)
Expand All @@ -1039,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,
)
)
Expand Down
1 change: 1 addition & 0 deletions phase2/config.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions phase2/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -134,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"

Expand All @@ -151,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)
Expand Down Expand Up @@ -319,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
Expand Down Expand Up @@ -546,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",
Expand All @@ -560,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",
Expand Down
Loading