Skip to content

Commit

Permalink
mkosi-initrd: honor x-initrd.attach options in crypttab
Browse files Browse the repository at this point in the history
  • Loading branch information
aafeijoo-suse authored and behrmann committed Oct 28, 2024
1 parent bb9c419 commit 9985e7e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mkosi/initrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,23 @@ def main() -> None:

cmdline += ["--sandbox-tree", sandbox_tree]

# Generate crypttab with all the x-initrd.attach entries
if Path("/etc/crypttab").exists():
crypttab = [
line
for line in Path("/etc/crypttab").read_text().splitlines()
if (
len(entry := line.split()) >= 4
and not entry[0].startswith("#")
and "x-initrd.attach" in entry[3]
)
]
if crypttab:
with (Path(staging_dir) / "crypttab").open("w") as f:
f.write("# Automatically generated by mkosi-initrd\n")
f.write("\n".join(crypttab))
cmdline += ["--extra-tree", f"{staging_dir}/crypttab:/etc/crypttab"]

# Prefer dnf as dnf5 has not yet officially replaced it and there's a much bigger chance that there
# will be a populated dnf cache directory.
run(
Expand Down

0 comments on commit 9985e7e

Please sign in to comment.