Skip to content

Commit

Permalink
WIP: install trusted.gpg.d into chroot
Browse files Browse the repository at this point in the history
  • Loading branch information
zeha committed Jan 22, 2025
1 parent 4e4ba36 commit 4aad1bf
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions usr/lib/grml-live/minifai
Original file line number Diff line number Diff line change
Expand Up @@ -542,24 +542,43 @@ def read_vars_for_classes(conf_dir: Path, classes: list[str]) -> dict:
return env


def install_base(chroot_dir: Path, debian_suite: str, mirror_url: str):
def install_base(conf_dir: Path, chroot_dir: Path, classes, debian_suite: str, mirror_url: str):
"""Install Debian base system from given mirror"""
print(f'I: Installing Debian base system for suite "{debian_suite}" using mmdebstrap')

mmdebstrap_extra_opts = []

# Work around APT bug: http://bugs.debian.org/1092164
included_packages = ["netbase"]

# Allow using https:// mirror, if given.
if mirror_url.startswith("https"):
included_packages.append("ca-certificates")

trusted_gpg_d_dir = conf_dir / "files" / "etc" / "apt" / "trusted.gpg.d"
if trusted_gpg_d_dir.exists():
print("I: Installing trusted.gpg.d into chroot")
chroot_trusted_gpg_d_dir = chroot_dir / "etc" / "apt" / "trusted.gpg.d"
chroot_trusted_gpg_d_dir.mkdir(parents=True)
mmdebstrap_extra_opts += [f"--keyring={chroot_trusted_gpg_d_dir}"]
for filename in trusted_gpg_d_dir.glob("*"):
filename = filename.name
print(f"I: Checking to install {filename!r} into chroot")
for class_name in classes:
to_copy = trusted_gpg_d_dir / filename / class_name
if to_copy.exists():
dest = chroot_trusted_gpg_d_dir / filename
print(f"I: Installing {to_copy} into chroot as {dest}")
shutil.copyfile(to_copy, dest, follow_symlinks=False)

args = [
"mmdebstrap",
"--format=directory",
"--variant=required",
"--verbose",
"--skip=check/empty", # grml-live pre-creates directories in chroot, skip emtpyness check.
f"--include={','.join(included_packages)}",
] + mmdebstrap_extra_opts + [
debian_suite,
chroot_dir,
mirror_url,
Expand Down Expand Up @@ -643,7 +662,7 @@ def main(program_name: str, argv: list[str]) -> int:

try:
if args.action == "dirinstall":
install_base(chroot_dir, args.debian_suite, args.mirror_url)
install_base(conf_dir, chroot_dir, classes, args.debian_suite, args.mirror_url)
rc = _run_tasks(conf_dir, chroot_dir, classes, args.grml_live_config, args.action)
elif args.action == "softupdate":
rc = _run_tasks(conf_dir, chroot_dir, classes, args.grml_live_config, args.action)
Expand Down

0 comments on commit 4aad1bf

Please sign in to comment.