Skip to content

Commit 6f444e0

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 18e9063 commit 6f444e0

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
@@ -53,6 +53,8 @@ def add_common_args(parser):
5353
group.add_argument('--disablerepo',
5454
help='disable repositories. Same syntax as yum\'s --disablerepo parameter. '
5555
'If both --enablerepo and --disablerepo are set, --disablerepo will be applied first')
56+
group.add_argument('--local-repo', action='append', default=[],
57+
help="Directory where the build-dependency RPMs will be taken from.")
5658
group.add_argument('--no-update', action='store_true',
5759
help='do not run "yum update" on container start, use it as it was at build time')
5860

@@ -159,6 +161,24 @@ def buildparser():
159161

160162
return parser
161163

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

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

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

0 commit comments

Comments
 (0)