Skip to content

Commit b7fbab7

Browse files
committed
WIP provide a --local-repo flag
Set all local repos to priority 1, to avoid getting e.g. ocaml5 from Alma. FIXME: this curently assumes the "local repos" are plain dirs, and we run createrepo_c on them. This allows to use the output of "builddep" as a cache without any other intermediate step, but that feels awkward for the general case. Maybe we should drop it? Anyway the "builddep" operation may change...
1 parent 012408b commit b7fbab7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/xcp_ng_dev/cli.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ def add_common_args(parser):
5454
group.add_argument('--disablerepo',
5555
help='disable repositories. Same syntax as yum\'s --disablerepo parameter. '
5656
'If both --enablerepo and --disablerepo are set, --disablerepo will be applied first')
57+
group.add_argument('--local-repo', action='append', default=[],
58+
help="Directory where the build-dependency RPMs will be taken from.")
5759
group.add_argument('--no-update', action='store_true',
5860
help='do not run "yum update" on container start, use it as it was at build time')
5961

@@ -160,6 +162,24 @@ def buildparser():
160162

161163
return parser
162164

165+
def _setup_repo(repo_dir, name, docker_args):
166+
subprocess.check_call(["createrepo_c", "--compatibility", repo_dir])
167+
outer_path = os.path.abspath(repo_dir)
168+
inner_path = f"/home/builder/local-repos/{name}"
169+
docker_args += ["-v", f"{outer_path}:{inner_path}:ro" ]
170+
with open(os.path.join(repo_dir, "builddep.repo"), "wt") as repofd:
171+
repofd.write(f"""
172+
[{name}]
173+
name=Local repository - {name} from {outer_path}
174+
baseurl=file:///home/builder/local-repos/{name}/
175+
enabled=1
176+
repo_gpgcheck=0
177+
gpgcheck=0
178+
priority=1
179+
""")
180+
# need rw for --disablerepo=* --enablerepo=builddeb <sigh>
181+
docker_args += ["-v", f"{outer_path}/builddep.repo:/etc/yum.repos.d/{name}.repo:rw"]
182+
163183
def container(args):
164184
docker_args = [RUNNER, "run", "-i", "-t"]
165185

@@ -222,6 +242,10 @@ def container(args):
222242
if args.debug:
223243
docker_args += ["-e", "SCRIPT_DEBUG=1"]
224244

245+
for repo in args.local_repo:
246+
# FIXME: ensure name is unique
247+
_setup_repo(repo, os.path.basename(repo), docker_args)
248+
225249
# action-specific
226250
match args.action:
227251
case 'build':

0 commit comments

Comments
 (0)