from mkosi.kmod import gen_required_kernel_modules, process_kernel_modules
from mkosi.log import ARG_DEBUG, complete_step, die, log_notice, log_step
from mkosi.manifest import Manifest
-from mkosi.mounts import finalize_source_mounts, mount_overlay
+from mkosi.mounts import finalize_crypto_mounts, finalize_source_mounts, mount_overlay
from mkosi.pager import page
from mkosi.partition import Partition, finalize_root, finalize_roothash
from mkosi.qemu import KernelType, copy_ephemeral, run_qemu, run_ssh, start_journal_remote
fork_and_wait,
run,
)
-from mkosi.sandbox import Mount, chroot_cmd, finalize_crypto_mounts, finalize_passwd_mounts
+from mkosi.sandbox import Mount, chroot_cmd, finalize_passwd_mounts
from mkosi.tree import copy_tree, move_tree, rmtree
from mkosi.types import PathString
from mkosi.user import CLONE_NEWNS, INVOKING_USER, become_root, unshare
for script in context.config.sync_scripts:
mounts = [
*sources,
- *finalize_crypto_mounts(context.config.tools()),
+ *finalize_crypto_mounts(context.config),
Mount(script, "/work/sync", ro=True),
Mount(json, "/work/config.json", ro=True),
]
tools_tree_repositories: list[str]
tools_tree_package_manager_trees: list[ConfigTree]
tools_tree_packages: list[str]
+ tools_tree_certificates: bool
runtime_trees: list[ConfigTree]
runtime_size: Optional[int]
runtime_scratch: ConfigFeature
parse=config_make_list_parser(delimiter=","),
help="Add additional packages to the default tools tree",
),
+ ConfigSetting(
+ dest="tools_tree_certificates",
+ metavar="BOOL",
+ section="Host",
+ parse=config_parse_boolean,
+ help="Use certificates from the tools tree",
+ default=True,
+ ),
ConfigSetting(
dest="runtime_trees",
long="--runtime-tree",
Tools Tree Repositories: {line_join_list(config.tools_tree_repositories)}
Tools Tree Package Manager Trees: {line_join_list(config.tools_tree_package_manager_trees)}
Tools Tree Packages: {line_join_list(config.tools_tree_packages)}
+ Tools Tree Certificates: {yes_no(config.tools_tree_certificates)}
Runtime Trees: {line_join_list(config.runtime_trees)}
Runtime Size: {format_bytes_or_none(config.runtime_size)}
Runtime Scratch: {config.runtime_scratch}
from mkosi.installer.rpm import RpmRepository, find_rpm_gpgkey, setup_rpm
from mkosi.installer.zypper import Zypper
from mkosi.log import die
+from mkosi.mounts import finalize_crypto_mounts
from mkosi.run import find_binary, run
-from mkosi.sandbox import Mount, finalize_crypto_mounts
+from mkosi.sandbox import Mount
from mkosi.util import listify, sort_packages
],
sandbox=context.sandbox(
network=True,
- mounts=[Mount(d, d), *finalize_crypto_mounts(context.config.tools())],
+ mounts=[Mount(d, d), *finalize_crypto_mounts(context.config)],
),
)
xml = (Path(d) / "repomd.xml").read_text()
from mkosi.config import Config, ConfigFeature, OutputFormat
from mkosi.context import Context
+from mkosi.mounts import finalize_crypto_mounts
from mkosi.run import find_binary
-from mkosi.sandbox import Mount, finalize_crypto_mounts
+from mkosi.sandbox import Mount
from mkosi.tree import copy_tree, rmtree
from mkosi.types import PathString
from mkosi.util import startswith
@classmethod
def mounts(cls, context: Context) -> list[Mount]:
mounts = [
- *finalize_crypto_mounts(tools=context.config.tools()),
+ *finalize_crypto_mounts(context.config),
Mount(context.packages, "/work/packages"),
]
def find_rpm_gpgkey(context: Context, key: str) -> Optional[str]:
- if gpgpath := next((context.config.tools() / "usr/share/distribution-gpg-keys").rglob(key), None):
- return ('/' / gpgpath.relative_to(context.config.tools())).as_uri()
+ root = context.config.tools() if context.config.tools_tree_certificates else Path("/")
+
+ if gpgpath := next((root / "usr/share/distribution-gpg-keys").rglob(key), None):
+ return (Path("/") / gpgpath.relative_to(root)).as_uri()
if gpgpath := next(Path(context.pkgmngr / "etc/pki/rpm-gpg").rglob(key), None):
- return ('/' / gpgpath.relative_to(context.pkgmngr)).as_uri()
+ return (Path("/") / gpgpath.relative_to(context.pkgmngr)).as_uri()
return None
)
yield [Mount(src, target) for src, target in sorted(sources, key=lambda s: s[1])]
+
+
+def finalize_crypto_mounts(config: Config) -> list[Mount]:
+ root = config.tools() if config.tools_tree_certificates else Path("/")
+
+ mounts = [
+ (root / subdir, Path("/") / subdir)
+ for subdir in (
+ Path("usr/share/keyrings"),
+ Path("usr/share/distribution-gpg-keys"),
+ Path("etc/pki"),
+ Path("etc/ssl"),
+ Path("etc/ca-certificates"),
+ Path("etc/pacman.d/gnupg"),
+ Path("var/lib/ca-certificates"),
+ )
+ if (root / subdir).exists()
+ ]
+
+ return [
+ Mount(src, target, ro=True)
+ for src, target
+ in sorted(set(mounts), key=lambda s: s[1])
+ ]
separated list of package specifications. This option may be used
multiple times in which case the specified package lists are combined.
+`ToolsTreeCertificates=`, `--tools-tree-certificates=`
+
+: Specify whether to use certificates and keys from the tools tree. If
+ enabled, `/usr/share/keyrings`, `/usr/share/distribution-gpg-keys`,
+ `/etc/pki`, `/etc/ssl`, `/etc/ca-certificates`, `/etc/pacman.d/gnupg`
+ and `/var/lib/ca-certificates` from the tools tree are used.
+ Otherwise, these directories are picked up from the host.
+
`RuntimeTrees=`, `--runtime-tree=`
: Takes a colon separated pair of paths. The first path refers to a
]
-def finalize_crypto_mounts(tools: Path = Path("/")) -> list[Mount]:
- mounts = [
- (tools / subdir, Path("/") / subdir)
- for subdir in (
- Path("etc/pki"),
- Path("etc/ssl"),
- Path("etc/ca-certificates"),
- Path("etc/pacman.d/gnupg"),
- Path("var/lib/ca-certificates"),
- )
- if (tools / subdir).exists()
- ]
-
- return [
- Mount(src, target, ro=True)
- for src, target
- in sorted(set(mounts), key=lambda s: s[1])
- ]
-
-
def finalize_mounts(mounts: Sequence[Mount]) -> list[PathString]:
mounts = list(set(mounts))
],
"Timezone": null,
"ToolsTree": null,
+ "ToolsTreeCertificates": true,
"ToolsTreeDistribution": null,
"ToolsTreeMirror": null,
"ToolsTreePackageManagerTrees": [
sync_scripts = [Path("/sync")],
timezone = None,
tools_tree = None,
+ tools_tree_certificates = True,
tools_tree_distribution = None,
tools_tree_mirror = None,
tools_tree_package_manager_trees = [ConfigTree(Path("/a/b/c"), Path("/"))],