Skip to content
Open
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
14 changes: 13 additions & 1 deletion bazeldnf/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bazeldnf_toolchain = module_extension(
)

_ALIAS_TEMPLATE = """\
load("@bazeldnf//bazeldnf:alias_macros.bzl", aliases="default")
load("{macro_file}", aliases="{macro_name}")

aliases(
name = "{name}",
Expand Down Expand Up @@ -124,10 +124,13 @@ def _alias_repository_impl(repository_ctx):
),
)

macro_file, macro_name = repository_ctx.attr.alias_macro.split("%", 1)
for name, metadata in repository_ctx.attr.packages_metadata.items():
repository_ctx.file(
"%s/BUILD.bazel" % name,
_ALIAS_TEMPLATE.format(
macro_file = macro_file,
macro_name = macro_name,
name = name,
data = metadata,
),
Expand All @@ -154,6 +157,7 @@ _alias_repository = repository_rule(
"nobest": attr.bool(default = False),
"cache_dir": attr.string(),
"architectures": attr.string_list(),
"alias_macro": attr.string(),
},
)

Expand All @@ -180,6 +184,7 @@ def _handle_lock_file(config, module_ctx, registered_rpms = {}):
"repository_prefix": config.rpm_repository_prefix,
"nobest": config.nobest,
"architectures": _get_architectures(config.architecture, config.architectures),
"alias_macro": config.alias_macro,
}

module_ctx.watch(config.lock_file)
Expand Down Expand Up @@ -414,6 +419,13 @@ The lock file content is as:
with the first one having the highest priority.
`noarch` is implicitly added at the end (if not present on the list).""",
),
"alias_macro": attr.string(
default = "@bazeldnf//bazeldnf:alias_macros.bzl%default",
doc = """Implementation of a macro generating aliases in the generated proxy repository.

Specify it in format: <.bzl file label>%<macro name>
Explore the default implementation and the meaning of args in `bazeldnf/alias_macros.bzl`.""",
),
},
)

Expand Down
Loading