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
2 changes: 2 additions & 0 deletions image/compose.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def _bootable_disk_image_impl(ctx: AnalysisContext) -> list[Provider]:
system = declare_repart(
ctx,
tools = tools,
systemd_arch = ARCHITECTURES[ctx.attrs.arch].systemd,
basename = basename,
definitions = system_definitions,
disk = False,
Expand Down Expand Up @@ -334,6 +335,7 @@ def _bootable_disk_image_impl(ctx: AnalysisContext) -> list[Provider]:
disk = declare_repart(
ctx,
tools = tools,
systemd_arch = ARCHITECTURES[ctx.attrs.arch].systemd,
basename = basename,
definitions = boot_definitions,
identifier = "disk",
Expand Down
6 changes: 6 additions & 0 deletions image_format/disk.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ load(
"resolve_signing_key",
"signing_key_spec",
)
load("//platforms:architecture.bzl", "ARCHITECTURES", "architecture")

Partition = dict[str, typing.Any]

Expand Down Expand Up @@ -283,6 +284,7 @@ def declare_repart(
*,
tools: ImageToolsInfo,
image: ImageInfo,
systemd_arch: str,
definitions: list[str],
disk: bool = True,
split: bool = False,
Expand Down Expand Up @@ -377,6 +379,7 @@ def declare_repart(
written.append(WrittenPartitionInfo(definition = definition, manifest = listing))

spec = {
"architecture": systemd_arch,
"basename": basename,
"definitions": definition_specs,
"identity": "{}[{}]".format(ctx.label, identifier or "repart"),
Expand Down Expand Up @@ -481,6 +484,7 @@ def _repart_impl(ctx: AnalysisContext) -> list[Provider]:
result = declare_repart(
ctx,
tools = ctx.attrs._tools[ImageToolsInfo],
systemd_arch = ARCHITECTURES[ctx.attrs._arch].systemd,
basename = ctx.attrs.basename,
definitions = ctx.attrs.definitions,
disk = ctx.attrs.disk,
Expand Down Expand Up @@ -540,6 +544,8 @@ _repart = rule(
doc = "split repart targets whose partitions should be copied into the result",
),
"split": attrs.bool(default = False, doc = "also emit independent artifacts for new partitions"),
# `_arch` is the architecture the image runs on. repart picks the partition types for it.
"_arch": attrs.string(default = architecture.configured()),
}
| IMAGE_TOOLS_ATTR,
)
Expand Down
4 changes: 4 additions & 0 deletions image_format/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class ImportedPartitionSpec(TypedDict):

class Spec(finalize.ImageSpec):
out: str | None
# The systemd spelling of the architecture the image runs on. repart picks the partition types of
# root and usr partitions for it.
architecture: str
# What the artifacts of this invocation are named after, extension aside.
basename: str
# Stable target identity the seed derives from, unless one is given outright.
Expand Down Expand Up @@ -360,6 +363,7 @@ def main(argv: list[str] | None = None) -> None:
str(seed),
"--definitions",
str(repart_definitions),
f"--architecture={spec['architecture']}",
]
if splits:
cmd.append("--split=yes")
Expand Down
2 changes: 2 additions & 0 deletions image_format/sysext.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def declare_image_sysext(
exe = tools.sysext,
image = image,
spec = {
# repart has no partition type for any architecture, so an `_any` DDI gets the build host's types.
"architecture": None if systemd_arch == "_any" else systemd_arch,
"base": layers,
"identity": str(ctx.label),
"manifest": manifest.as_output(),
Expand Down
5 changes: 5 additions & 0 deletions image_format/sysext.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class Spec(finalize.ImageSpec):
# Where to write the DDI's verity root hash: the identity a host reports
# for the merged extension, published so consumers can join on it.
root_hash_out: str
# The systemd spelling of the architecture the extension merges on. repart picks the partition
# types for it. With None, repart uses the build host's types.
architecture: str | None


_SEED_NAMESPACE = uuid.UUID("b388a973-3ffa-44aa-90b7-afcc4573ea9f")
Expand Down Expand Up @@ -139,6 +142,8 @@ def main(argv: list[str] | None = None) -> None:
"--seed",
str(seed),
]
if spec["architecture"] is not None:
cmd.append(f"--architecture={spec['architecture']}")
# The built-in sysext definitions always include the signature partition, and repart
# refuses to fill it without a key, so an unsigned DDI must drop it instead.
if spec["signing"]:
Expand Down
Loading