parse_config,
summary,
)
+from mkosi.distributions import Distribution
from mkosi.installer import clean_package_manager_metadata, package_manager_scripts
from mkosi.kmod import gen_required_kernel_modules, process_kernel_modules
from mkosi.log import ARG_DEBUG, complete_step, die, log_step
# Some distributions install EFI binaries directly to /boot/efi. Let's redirect them to /efi
# instead.
rmtree(state.root / "boot/efi")
+ (state.root / "boot").mkdir(exist_ok=True)
(state.root / "boot/efi").symlink_to("../efi")
if state.config.packages:
die(f"Removing packages is not supported for {state.config.distribution}")
+def check_root_populated(state: MkosiState) -> None:
+ """Check that the root was populated by looking for a os-release file."""
+ osrelease = state.root / "usr/lib/os-release"
+ if not osrelease.exists():
+ die(f"{osrelease} not found.",
+ hint="The root must be populated by the distribution, or from base trees, skeleton trees, and prepare scripts.")
+
+
def configure_os_release(state: MkosiState) -> None:
"""Write IMAGE_ID and IMAGE_VERSION to /usr/lib/os-release in the image."""
if not state.config.image_id and not state.config.image_version:
if symlink.exists():
return symlink.resolve()
+ if state.config.distribution == Distribution.none:
+ die(f"Building a default initrd is not supported with distribution {state.config.distribution}")
+
# Default values are assigned via the parser so we go via the argument parser to construct
# the config for the initrd.
save_cache(state)
reuse_cache(state)
+ check_root_populated(state)
run_build_scripts(state)
if state.config.output_format == OutputFormat.none:
detected = detect_distribution()[0]
if not detected:
- die("Distribution of your host can't be detected or isn't a supported target. Please set Distribution= in your config.")
+ logging.info("Distribution of your host can't be detected or isn't a supported target. Defaulting to Distribution=none.")
+ return Distribution.none
return detected
class Distribution(StrEnum):
+ none = enum.auto()
fedora = enum.auto()
debian = enum.auto()
ubuntu = enum.auto()
--- /dev/null
+# SPDX-License-Identifier: LGPL-2.1+
+
+from collections.abc import Sequence
+
+from mkosi.distributions import DistributionInstaller
+from mkosi.log import die
+from mkosi.state import MkosiState
+
+
+class Installer(DistributionInstaller):
+ @classmethod
+ def setup(cls, state: MkosiState) -> None:
+ pass
+
+ @classmethod
+ def install(cls, state: MkosiState) -> None:
+ pass
+
+ @classmethod
+ def install_packages(cls, state: MkosiState, packages: Sequence[str]) -> None:
+ if packages:
+ die("Installing packages is not supported with distribution 'none'")
+
+ @classmethod
+ def remove_packages(cls, state: MkosiState, packages: Sequence[str]) -> None:
+ if packages:
+ die("Removing packages is not supported with distribution 'none'")
: The distribution to install in the image. Takes one of the following
arguments: `fedora`, `debian`, `ubuntu`, `arch`, `opensuse`, `mageia`,
- `centos`, `rhel-ubi`, `openmandriva`, `rocky`, `alma`. If not
- specified, defaults to the distribution of the host.
+ `centos`, `rhel-ubi`, `openmandriva`, `rocky`, `alma`, `none`.
+ If not specified, defaults to the distribution of the host.
`Release=`, `--release=`, `-r`
guarantee that it will work at all and the core maintainers will
generally not fix gentoo specific issues**)
+* *None* (**Requires the user to provide a pre-built rootfs**)
+
In theory, any distribution may be used on the host for building images
containing any other distribution, as long as the necessary tools are
available.
Any distribution that packages `dnf` may be used to build images for any of the rpm-based distributions.
Any distro that packages `pacman` may be used to build *Arch Linux* images.
Any distribution that packages `zypper` may be used to build *openSUSE* images.
+Other distributions and build automation tools for embedded Linux systems such as Buildroot, OpenEmbedded and Yocto Project may be used by selecting the `none` distribution, and populating the rootfs via a combination of base trees, skeleton trees, and prepare scripts.
Currently, *Fedora Linux* packages all relevant tools as of Fedora 28.