Skip to content

Commit

Permalink
[antlir2][rpm] allow prebuilt repodata
Browse files Browse the repository at this point in the history
Summary:
Sometimes, building `repodata` is actually quite slow and bloats the critical
path by potentially minutes.

This diff allows the `repo` rule to accept a prebuilt repodata directory.

Test Plan: testhard

Reviewed By: justintrudell

Differential Revision: D67404535

fbshipit-source-id: 3ef5b4f2856d00ef97e04e83f731c28eea6ae70b
  • Loading branch information
vmagro authored and facebook-github-bot committed Dec 19, 2024
1 parent a427b6e commit 2fec024
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions antlir/antlir2/package_managers/dnf/rules/repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,23 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:

# First build a repodata directory that just contains repodata (this would
# be suitable as a baseurl for dnf)
plain_repodata = ctx.actions.declare_output("repodata", dir = True)
ctx.actions.run(
cmd_args(
ctx.attrs.makerepo[RunInfo],
cmd_args(repo_id, format = "--repo-id={}"),
cmd_args(xml_dir, format = "--xml-dir={}"),
cmd_args(ctx.attrs.module_md, format = "--module-md={}") if ctx.attrs.module_md else cmd_args(),
cmd_args(plain_repodata.as_output(), format = "--out={}"),
"--compress={}".format(ctx.attrs.compress),
"--expected-rpm-count={}".format(len(ctx.attrs.rpms)),
optional_args,
),
category = "repodata",
)
if not ctx.attrs.repodata:
plain_repodata = ctx.actions.declare_output("repodata", dir = True)
ctx.actions.run(
cmd_args(
ctx.attrs.makerepo[RunInfo],
cmd_args(repo_id, format = "--repo-id={}"),
cmd_args(xml_dir, format = "--xml-dir={}"),
cmd_args(ctx.attrs.module_md, format = "--module-md={}") if ctx.attrs.module_md else cmd_args(),
cmd_args(plain_repodata.as_output(), format = "--out={}"),
"--compress={}".format(ctx.attrs.compress),
"--expected-rpm-count={}".format(len(ctx.attrs.rpms)),
optional_args,
),
category = "repodata",
)
else:
plain_repodata = ctx.attrs.repodata

if is_facebook:
# Pre-build .solv(x) files so that dnf installation is substantially faster
Expand Down Expand Up @@ -113,6 +116,11 @@ repo_attrs = {
"makecache": attrs.default_only(attrs.exec_dep(default = "antlir//antlir/antlir2/package_managers/dnf/rules/makecache:makecache")),
"makerepo": attrs.default_only(attrs.exec_dep(default = "antlir//antlir/antlir2/package_managers/dnf/rules/makerepo:makerepo")),
"module_md": attrs.option(attrs.source(), default = None),
"repodata": attrs.option(
attrs.source(allow_directory = True),
default = None,
doc = "Pre-built repodata, if available",
),
"rpms": attrs.list(
attrs.dep(providers = [RpmInfo]),
doc = "All RPMs that should be included in this repo",
Expand Down

0 comments on commit 2fec024

Please sign in to comment.