### Install mkosi and copy RPMs Source: https://mkosi.systemd.io/building-rpms-from-source.html This script installs mkosi, then copies any RPMs matching the pattern '*mkosi*.rpm' from the package directory to the output directory. ```shell #!/bin/sh set -e mkosi-install mkosi cp "$PACKAGEDIR"/*mkosi*.rpm "$OUTPUTDIR" ``` -------------------------------- ### Commandline Arguments Formatting Source: https://mkosi.systemd.io/CODING_STYLE.html Example of how to format commandline arguments to ensure proper splitting by ruff. ```python cmd = [ "--option", "foo", ] # fmt: skip ``` ```python cmd = [ "--option", "foo", ] ``` -------------------------------- ### mkosi.prepare script for RPM build Source: https://mkosi.systemd.io/building-rpms-from-source.html This script handles the preparation phase for building RPMs, including resolving and installing build dependencies. ```sh #!/bin/sh set -e if [ "$1" = "final" ]; then exit 0 fi mkosi-chroot \ env --chdir=mkosi \ rpmspec \ --query \ --buildrequires \ --define "_topdir /var/tmp" \ --define "_sourcedir $PWD/mkosi/rpm" \ rpm/mkosi.spec | \ sort --unique | \ tee /tmp/buildrequires | \ xargs --delimiter '\n' mkosi-install until mkosi-chroot \ env --chdir=mkosi \ rpmbuild \ -bd \ --noprep \ --build-in-place \ --define "_topdir /var/tmp" \ --define "_sourcedir $PWD/mkosi/rpm" \ --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \ rpm/mkosi.spec do EXIT_STATUS=$? if [ $EXIT_STATUS -ne 11 ]; then exit $EXIT_STATUS fi mkosi-chroot \ rpm \ --query \ --package \ --requires \ /var/tmp/SRPMS/mkosi-*.buildreqs.nosrc.rpm | \ grep --invert-match '^rpmlib(' | \ sort --unique >/tmp/dynamic-buildrequires sort /tmp/buildrequires /tmp/dynamic-buildrequires | \ uniq --unique | \ tee --append /tmp/buildrequires | \ xargs --delimiter '\n' mkosi-install done ``` -------------------------------- ### mkosi.conf example for adding rpm-build package Source: https://mkosi.systemd.io/building-rpms-from-source.html This configuration snippet demonstrates how to add the 'rpm-build' package to the mkosi image's content using mkosi.conf. This ensures that the necessary tools for building RPMs are available within the image. ```ini [Content] Packages=rpm-build ``` -------------------------------- ### mkosi.local.conf example for BuildSources Source: https://mkosi.systemd.io/building-rpms-from-source.html This configuration snippet shows how to use the BuildSources setting in mkosi.local.conf to mount local repositories containing upstream sources and RPM spec files into the mkosi build environment. It specifies mounting the mkosi upstream repository and the Fedora RPM spec directory. ```ini [Build] BuildSources=../mkosi:mkosi ../fedora/mkosi:mkosi/rpm BuildSourcesEphemeral=yes ``` -------------------------------- ### Initrd output configuration Source: https://mkosi.systemd.io/sysext.html Configuration to package the base image as an initrd. ```ini [Output] Format=cpio Output=initrd [Content] MakeInitrd=yes BaseTrees=%O/base ``` -------------------------------- ### Using the custom initrd with mkosi Source: https://mkosi.systemd.io/initrd.html Command to invoke mkosi and pass a custom initrd image using the --initrd option. ```bash mkosi --initrd= ... ``` -------------------------------- ### Initrd Configuration Source: https://mkosi.systemd.io/initrd.html Configuration for building an initrd image using mkosi, specifying the output format, and including necessary packages. ```mkosi [Output] Format=cpio [Content] MakeInitrd=yes Packages=systemd udev kmod ``` -------------------------------- ### Base mkosi.conf configuration Source: https://mkosi.systemd.io/sysext.html Shared settings for mkosi, defining output and cache directories. ```ini [Output] OutputDirectory=mkosi.output CacheDirectory=mkosi.cache ``` -------------------------------- ### Base image mkosi.conf Source: https://mkosi.systemd.io/sysext.html Configuration for the base image, specifying directory output format and packages. ```ini [Output] Format=directory [Content] CleanPackageMetadata=no Packages=systemd udev ``` -------------------------------- ### Testing new distribution implementation Source: https://mkosi.systemd.io/distribution-policy.html Command to test the implementation of a new distribution. ```bash mkosi -d --tools-tree -t disk -f vm ``` -------------------------------- ### mkosi.build.chroot script for RPM build Source: https://mkosi.systemd.io/building-rpms-from-source.html This script is executed inside the chroot environment to build the RPM package. ```sh #!/bin/sh set -e env --chdir=mkosi \ rpmbuild \ -bb \ --noprep \ --build-in-place \ $([ "$WITH_TESTS" = "0" ] && echo --nocheck) \ --define "_topdir /var/tmp" \ --define "_sourcedir $PWD/mkosi/rpm" \ --define "_rpmdir $PACKAGEDIR" \ ${BUILDDIR:+--define} \ ${BUILDDIR:+"_vpath_builddir $BUILDDIR"} \ --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \ --define "_binary_payload w.ufdio" \ --define "debug_package %{nil}" \ --define "__brp_strip %{nil}" \ --define "__brp_compress %{nil}" \ --define "__brp_mangle_shebangs %{nil}" \ --define "__brp_strip_comment_note %{nil}" \ --define "__brp_strip_static_archive %{nil}" \ rpm/mkosi.spec ``` -------------------------------- ### System extension mkosi.conf Source: https://mkosi.systemd.io/sysext.html Configuration for the system extension image, depending on the base image and specifying overlay format. ```ini [Config] Dependencies=base [Output] Format=sysext Overlay=yes [Content] BaseTrees=%O/base Packages=btrfs-progs ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.