From d052cc88932926f964bcf227c1c5032c5400cd4a Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 25 Apr 2023 16:04:49 +0200 Subject: mkosi: Switch to use mkosi presets with prebuilt initrds Instead of building the initrds for the mkosi images with dracut, let's switch to using mkosi presets to build the initrd with mkosi as well. This commit splits up our single image build into three separate mkosi presets: 1. The "base" preset. This image contains systemd and all its runtime dependencies. The sole purpose of this image is to serve as a base image for the initrd and the final image. It's also responsible for building systemd from source with the build script. The results are installed into the base image. Note that we install the systemd and udev packages into this image as well to prevent package managers from overriding the systemd we built from source with the distro packaged systemd if it's pulled in as a dependency by another package from the initrd or final profiles. 2. The "initrd" preset. This image provides the initrd. It's trivial and does nothing more than packaging the base image up as a zstd compressed initramfs and adds /init and /etc/initrd-release symlinks to the image. 3. The "final" preset. This image builds on top of the base image and adds a kernel and extra packages that are useful for testing and debugging. We also split out the optional kernel build into a separate set of config files that are only included if a kernel to build is actually provided. Note that this commit doesn't really change anything about how mkosi is used. The commands remain the same, except that mkosi will now build all the presets in order. "mkosi summary" will show the summary of all the presets. "mkosi qemu, boot, shell" will always boot the final preset. With "-f", all presets will be built and the final one is booted. "-i" makes a cache of each preset. The only thing to keep in mind is that specifying config via the mkosi CLI will apply to each of the presets. e.g. any extra packages added with "-p" will be installed in both the initrd and the final image. To apply local configuration to a single preset, create a file 00-local.conf in mkosi.presets//mkosi.conf.d and put all the preset specific configuration in there. --- mkosi.conf.d/05-qemu-mem.conf | 11 ++ mkosi.conf.d/10-centos.conf | 8 ++ mkosi.conf.d/10-debian.conf | 7 ++ mkosi.conf.d/10-fedora.conf | 7 ++ mkosi.conf.d/10-opensuse.conf | 7 ++ mkosi.conf.d/10-systemd.conf | 62 +----------- mkosi.conf.d/10-ubuntu.conf | 8 ++ mkosi.conf.d/11-centos-8/mkosi.conf | 5 + .../11-centos-8/mkosi.reposdir/powertools.repo | 10 ++ mkosi.conf.d/20-arch.conf | 51 ---------- mkosi.conf.d/20-centos-fedora.conf | 94 ----------------- mkosi.conf.d/20-centos.conf | 8 -- mkosi.conf.d/20-debian-ubuntu/mkosi.conf | 97 ------------------ .../usr/lib/systemd/system-preset/99-ignore.preset | 1 - .../mkosi.extra/usr/lib/tmpfiles.d/locale.conf | 1 - mkosi.conf.d/20-debian.conf | 15 --- mkosi.conf.d/20-fedora.conf | 24 ----- mkosi.conf.d/20-opensuse.conf | 112 --------------------- mkosi.conf.d/20-ubuntu.conf | 17 ---- mkosi.conf.d/21-centos-8/mkosi.conf | 19 ---- .../21-centos-8/mkosi.reposdir/powertools.repo | 10 -- mkosi.conf.d/21-centos-9.conf | 18 ---- 22 files changed, 67 insertions(+), 525 deletions(-) create mode 100644 mkosi.conf.d/05-qemu-mem.conf create mode 100644 mkosi.conf.d/10-centos.conf create mode 100644 mkosi.conf.d/10-debian.conf create mode 100644 mkosi.conf.d/10-fedora.conf create mode 100644 mkosi.conf.d/10-opensuse.conf create mode 100644 mkosi.conf.d/10-ubuntu.conf create mode 100644 mkosi.conf.d/11-centos-8/mkosi.conf create mode 100644 mkosi.conf.d/11-centos-8/mkosi.reposdir/powertools.repo delete mode 100644 mkosi.conf.d/20-arch.conf delete mode 100644 mkosi.conf.d/20-centos-fedora.conf delete mode 100644 mkosi.conf.d/20-centos.conf delete mode 100644 mkosi.conf.d/20-debian-ubuntu/mkosi.conf delete mode 100644 mkosi.conf.d/20-debian-ubuntu/mkosi.extra/usr/lib/systemd/system-preset/99-ignore.preset delete mode 100644 mkosi.conf.d/20-debian-ubuntu/mkosi.extra/usr/lib/tmpfiles.d/locale.conf delete mode 100644 mkosi.conf.d/20-debian.conf delete mode 100644 mkosi.conf.d/20-fedora.conf delete mode 100644 mkosi.conf.d/20-opensuse.conf delete mode 100644 mkosi.conf.d/20-ubuntu.conf delete mode 100644 mkosi.conf.d/21-centos-8/mkosi.conf delete mode 100644 mkosi.conf.d/21-centos-8/mkosi.reposdir/powertools.repo delete mode 100644 mkosi.conf.d/21-centos-9.conf (limited to 'mkosi.conf.d') diff --git a/mkosi.conf.d/05-qemu-mem.conf b/mkosi.conf.d/05-qemu-mem.conf new file mode 100644 index 0000000000..58de5fcf56 --- /dev/null +++ b/mkosi.conf.d/05-qemu-mem.conf @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +# Arch and CentOS 8 Stream initrds are rather big so we need to give QEMU more memory so the kernel can load +# them without OOMing. + +[Match] +Distribution=arch centos +Release=rolling 8 + +[Host] +QemuMem=3G diff --git a/mkosi.conf.d/10-centos.conf b/mkosi.conf.d/10-centos.conf new file mode 100644 index 0000000000..4181f03414 --- /dev/null +++ b/mkosi.conf.d/10-centos.conf @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=centos + +[Distribution] +Release=9 +Repositories=epel diff --git a/mkosi.conf.d/10-debian.conf b/mkosi.conf.d/10-debian.conf new file mode 100644 index 0000000000..0eeaf07400 --- /dev/null +++ b/mkosi.conf.d/10-debian.conf @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=debian + +[Distribution] +Release=testing diff --git a/mkosi.conf.d/10-fedora.conf b/mkosi.conf.d/10-fedora.conf new file mode 100644 index 0000000000..4511dcdf87 --- /dev/null +++ b/mkosi.conf.d/10-fedora.conf @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=fedora + +[Distribution] +Release=38 diff --git a/mkosi.conf.d/10-opensuse.conf b/mkosi.conf.d/10-opensuse.conf new file mode 100644 index 0000000000..98a7b4ef5c --- /dev/null +++ b/mkosi.conf.d/10-opensuse.conf @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=opensuse + +[Distribution] +Release=tumbleweed diff --git a/mkosi.conf.d/10-systemd.conf b/mkosi.conf.d/10-systemd.conf index 2b02eba0d6..ad709829ba 100644 --- a/mkosi.conf.d/10-systemd.conf +++ b/mkosi.conf.d/10-systemd.conf @@ -10,60 +10,6 @@ OutputDirectory=mkosi.output [Content] BuildDirectory=mkosi.builddir CacheDirectory=mkosi.cache -ExtraTrees=src:/root/src -Packages= - acl - bash-completion - coreutils - diffutils - dnsmasq - dosfstools - dracut - e2fsprogs - findutils - gcc # For sanitizer libraries - gdb - grep - kbd - kexec-tools - kmod - less - mtools - nano - nftables - openssl - python3 - qrencode - sed - strace - systemd - tree - udev - util-linux - valgrind - wireguard-tools - xfsprogs - zsh - -BuildPackages= - bc - binutils - bison - clang - flex - gcc - gettext - git - gperf - lld - llvm - make - meson - pkgconf - rpm - rsync - tar - zstd [Host] Acl=yes @@ -77,7 +23,7 @@ KernelCommandLineExtra=systemd.crash_shell systemd.mask=auditd # Tell the kernel to only log warning and up to the console. loglevel=4 - -[Validation] -Password= -Autologin=yes + # Disable the kernel's ratelimiting on userspace logging to kmsg. + printk.devkmsg=on + # Tell networkd to manage the ethernet interface. + ip=enp0s1:any diff --git a/mkosi.conf.d/10-ubuntu.conf b/mkosi.conf.d/10-ubuntu.conf new file mode 100644 index 0000000000..d6ea6d1708 --- /dev/null +++ b/mkosi.conf.d/10-ubuntu.conf @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=ubuntu + +[Distribution] +Release=jammy +Repositories=universe diff --git a/mkosi.conf.d/11-centos-8/mkosi.conf b/mkosi.conf.d/11-centos-8/mkosi.conf new file mode 100644 index 0000000000..cde54e9e6e --- /dev/null +++ b/mkosi.conf.d/11-centos-8/mkosi.conf @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=centos +Release=8 diff --git a/mkosi.conf.d/11-centos-8/mkosi.reposdir/powertools.repo b/mkosi.conf.d/11-centos-8/mkosi.reposdir/powertools.repo new file mode 100644 index 0000000000..1462257c08 --- /dev/null +++ b/mkosi.conf.d/11-centos-8/mkosi.reposdir/powertools.repo @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[powertools-hotfixes] +name=powertools-hotfixes +mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=PowerTools +gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official +gpgcheck=1 +enabled=1 +module_hotfixes=1 +skip_if_unavailable=1 diff --git a/mkosi.conf.d/20-arch.conf b/mkosi.conf.d/20-arch.conf deleted file mode 100644 index 6dcbb9f6ab..0000000000 --- a/mkosi.conf.d/20-arch.conf +++ /dev/null @@ -1,51 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later -# -# Copyright © 2016 Zeal Jagannatha - -[Match] -Distribution=arch - -[Content] -Packages= - alsa-lib - base - btrfs-progs - compsize - dhcp - f2fs-tools - fuse2 - gnutls - iproute - libbpf - libcap-ng - libfido2 - libmicrohttpd - libmnl - libpwquality - libxkbcommon - linux - man-db - numactl - openbsd-netcat - openssh - polkit - popt - python-pefile - python-psutil - python-pytest - quota-tools - shadow - tpm2-tss - vim - -BuildPackages= - bpf - docbook-xsl - libxslt - linux-api-headers - pahole - perl - python-docutils - python-jinja - python-lxml - python-pyelftools diff --git a/mkosi.conf.d/20-centos-fedora.conf b/mkosi.conf.d/20-centos-fedora.conf deleted file mode 100644 index d78b924304..0000000000 --- a/mkosi.conf.d/20-centos-fedora.conf +++ /dev/null @@ -1,94 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=centos fedora - -[Content] -Packages= - alsa-lib - audit-libs - cryptsetup - dhcp-server - dnf - fuse - glib2 - glibc-minimal-langpack - glibc.i686 - gnutls - iproute - iproute-tc - kernel-core - libasan - libbpf - libcap-ng - libcap-ng-utils - libfido2 - libgcrypt - libmicrohttpd - libmnl - libubsan - libxcrypt - libxkbcommon - netcat - numactl-libs - openssh-server - p11-kit - pam - passwd - polkit - popt - procps-ng - quota - tpm2-tss - util-linux - vim-common - -BuildPackages= - /usr/bin/pkg-config - bpftool - docbook-xsl - dwarves - glibc-devel.i686 - glibc-static - glibc-static.i686 - libxslt - pam-devel - perl-interpreter - pkgconfig(alsa) - pkgconfig(audit) - pkgconfig(blkid) - pkgconfig(bzip2) - pkgconfig(dbus-1) - pkgconfig(fdisk) - pkgconfig(fuse) - pkgconfig(glib-2.0) - pkgconfig(gnutls) - pkgconfig(libacl) - pkgconfig(libbpf) - pkgconfig(libcap-ng) - pkgconfig(libcap) - pkgconfig(libcryptsetup) - pkgconfig(libcurl) - pkgconfig(libdw) - pkgconfig(libfido2) - pkgconfig(libidn2) - pkgconfig(libkmod) - pkgconfig(libmicrohttpd) - pkgconfig(libmnl) - pkgconfig(libpcre2-8) - pkgconfig(libqrencode) - pkgconfig(libseccomp) - pkgconfig(libselinux) - pkgconfig(libzstd) - pkgconfig(mount) - pkgconfig(numa) - pkgconfig(openssl) - pkgconfig(p11-kit-1) - pkgconfig(popt) - pkgconfig(pwquality) - pkgconfig(tss2-esys) - pkgconfig(tss2-mu) - pkgconfig(tss2-rc) - pkgconfig(valgrind) - pkgconfig(xkbcommon) - python3-docutils diff --git a/mkosi.conf.d/20-centos.conf b/mkosi.conf.d/20-centos.conf deleted file mode 100644 index 4181f03414..0000000000 --- a/mkosi.conf.d/20-centos.conf +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=centos - -[Distribution] -Release=9 -Repositories=epel diff --git a/mkosi.conf.d/20-debian-ubuntu/mkosi.conf b/mkosi.conf.d/20-debian-ubuntu/mkosi.conf deleted file mode 100644 index 584536ef6b..0000000000 --- a/mkosi.conf.d/20-debian-ubuntu/mkosi.conf +++ /dev/null @@ -1,97 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=debian ubuntu - -[Content] -Packages= - btrfs-progs - cryptsetup-bin - dbus-broker - default-dbus-session-bus - f2fs-tools - fdisk - fuse - gcc # Provides libasan/libubsan - iproute2 - isc-dhcp-server - libasound2 - libc6-i386 - libcap-ng-utils - libcap-ng0 - libfdisk1 - libfido2-1 - libglib2.0-0 - libgnutls30 - libidn2-0 - libmicrohttpd12 - libmnl0 - libnuma1 - libp11-kit0 - libpam0g - libpopt0 - libpwquality1 - libqrencode4 - libtss2-dev # Use the -dev package to avoid churn in updating version numbers - netcat-openbsd - openssh-server - passwd - policykit-1 - procps - python3-pefile - python3-psutil - python3-pytest - quota - systemd-sysv - tzdata - xxd - -BuildPackages= - docbook-xsl - dpkg-dev - g++ - gcc-multilib - libacl1-dev - libasound-dev - libaudit-dev - libblkid-dev - libbpf-dev - libbz2-dev - libc6-dev - libc6-dev-i386 - libcap-dev - libcap-ng-dev - libcryptsetup-dev - libcurl4-openssl-dev - libdbus-1-dev - libdw-dev - libfdisk-dev - libfido2-dev - libfuse-dev - libgcrypt20-dev - libglib2.0-dev - libgnutls28-dev - libidn2-dev - libiptc-dev - libkmod-dev - libmicrohttpd-dev - libmnl-dev - libmount-dev - libnuma-dev - libp11-kit-dev - libpam0g-dev - libpopt-dev - libpwquality-dev - libqrencode-dev - libseccomp-dev - libsmartcols-dev - libssl-dev - libxen-dev - libxkbcommon-dev - libzstd-dev - pahole - python3-docutils - python3-jinja2 - python3-lxml - python3-pyelftools - xsltproc diff --git a/mkosi.conf.d/20-debian-ubuntu/mkosi.extra/usr/lib/systemd/system-preset/99-ignore.preset b/mkosi.conf.d/20-debian-ubuntu/mkosi.extra/usr/lib/systemd/system-preset/99-ignore.preset deleted file mode 100644 index 43f25533d1..0000000000 --- a/mkosi.conf.d/20-debian-ubuntu/mkosi.extra/usr/lib/systemd/system-preset/99-ignore.preset +++ /dev/null @@ -1 +0,0 @@ -ignore * diff --git a/mkosi.conf.d/20-debian-ubuntu/mkosi.extra/usr/lib/tmpfiles.d/locale.conf b/mkosi.conf.d/20-debian-ubuntu/mkosi.extra/usr/lib/tmpfiles.d/locale.conf deleted file mode 100644 index e1a8e8171a..0000000000 --- a/mkosi.conf.d/20-debian-ubuntu/mkosi.extra/usr/lib/tmpfiles.d/locale.conf +++ /dev/null @@ -1 +0,0 @@ -L /etc/default/locale - - - - ../locale.conf diff --git a/mkosi.conf.d/20-debian.conf b/mkosi.conf.d/20-debian.conf deleted file mode 100644 index c251ab6542..0000000000 --- a/mkosi.conf.d/20-debian.conf +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=debian - -[Distribution] -Release=testing - -[Content] -Packages= - libbpf1 - linux-image-cloud-amd64 - -BuildPackages= - bpftool diff --git a/mkosi.conf.d/20-fedora.conf b/mkosi.conf.d/20-fedora.conf deleted file mode 100644 index 1574420487..0000000000 --- a/mkosi.conf.d/20-fedora.conf +++ /dev/null @@ -1,24 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=fedora - -[Distribution] -Release=38 - -[Content] -Packages= - btrfs-progs - compsize - f2fs-tools - python3dist(pefile) - python3dist(psutil) - python3dist(pytest) - -BuildPackages= - libcap-static - pkgconfig(libgcrypt) - pkgconfig(xencontrol) - python3dist(jinja2) - python3dist(lxml) - python3dist(pyelftools) diff --git a/mkosi.conf.d/20-opensuse.conf b/mkosi.conf.d/20-opensuse.conf deleted file mode 100644 index caf84ba0ab..0000000000 --- a/mkosi.conf.d/20-opensuse.conf +++ /dev/null @@ -1,112 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=opensuse - -[Distribution] -Release=tumbleweed - -[Content] -Packages= - btrfs-progs - dbus-1 - f2fs-tools - fuse - gcc # Provides libasan/libubsan - glibc-32bit - glibc-locale-base - kernel-default - libasound2 - libbpf1 - libcap-ng-utils - libcap-ng0 - libcrypt1 - libcryptsetup12 - libdw1 - libelf1 - libfido2 - libgcrypt20 - libglib-2_0-0 - libkmod2 - liblz4-1 - libmnl0 - libmount1 - libnuma1 - libp11-kit0 - libpopt0 - libqrencode4 - libseccomp2 - libxkbcommon0 - openssh-server - pam - python3-pefile - python3-psutil - python3-pytest - shadow - tpm2-0-tss - vim - -BuildPackages= - alsa-devel - audit-devel - bpftool - dbus-1-devel - docbook-xsl-stylesheets - dwarves - fdupes - fuse-devel - gcc-32bit - gcc-c++ - glib2-devel - glibc-devel-32bit - glibc-devel-static-32bit - glibc-locale - glibc-static - intltool - libacl-devel - libapparmor-devel - libblkid-devel - libbpf-devel - libbz2-devel - libcap-devel - libcap-ng-devel - libcryptsetup-devel - libcurl-devel - libdw-devel - libelf-devel - libfdisk-devel - libfido2-devel - libgcrypt-devel - libgnutls-devel - libkmod-devel - liblz4-devel - libmicrohttpd-devel - libmnl-devel - libmount-devel - libnuma-devel - libpwquality-devel - libseccomp-devel - libselinux-devel - libxkbcommon-devel - libxslt-tools - openssl-devel - pam-devel - pciutils-devel - pcre-devel - popt-devel - python3-docutils - python3-Jinja2 - python3-lxml - python3-pyelftools - qrencode-devel - shadow - system-group-obsolete - system-user-bin - system-user-daemon - system-user-nobody - system-user-root - systemd-sysvinit - timezone - tpm2-0-tss-devel - xen-devel - zlib-devel diff --git a/mkosi.conf.d/20-ubuntu.conf b/mkosi.conf.d/20-ubuntu.conf deleted file mode 100644 index 036c1734b2..0000000000 --- a/mkosi.conf.d/20-ubuntu.conf +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=ubuntu - -[Distribution] -Release=jammy -Repositories=universe - -[Content] -Packages= - libbpf0 - linux-virtual - -BuildPackages= - linux-tools-common - linux-tools-generic diff --git a/mkosi.conf.d/21-centos-8/mkosi.conf b/mkosi.conf.d/21-centos-8/mkosi.conf deleted file mode 100644 index d610212b61..0000000000 --- a/mkosi.conf.d/21-centos-8/mkosi.conf +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=centos -Release=8 - -[Content] -Packages= - python39 - python3.9dist(pefile) - python3.9dist(pluggy) # python39-pluggy is a pytest dependency that's not installed for some reason. - python3.9dist(psutil) - python3.9dist(pytest) - -BuildPackages= - libgcrypt-devel # CentOS Stream 8 libgcrypt-devel doesn't ship a pkg-config file. - python3.9dist(jinja2) - python3.9dist(lxml) - python3.9dist(pyelftools) diff --git a/mkosi.conf.d/21-centos-8/mkosi.reposdir/powertools.repo b/mkosi.conf.d/21-centos-8/mkosi.reposdir/powertools.repo deleted file mode 100644 index 1462257c08..0000000000 --- a/mkosi.conf.d/21-centos-8/mkosi.reposdir/powertools.repo +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[powertools-hotfixes] -name=powertools-hotfixes -mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=PowerTools -gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official -gpgcheck=1 -enabled=1 -module_hotfixes=1 -skip_if_unavailable=1 diff --git a/mkosi.conf.d/21-centos-9.conf b/mkosi.conf.d/21-centos-9.conf deleted file mode 100644 index 0febf2c2ee..0000000000 --- a/mkosi.conf.d/21-centos-9.conf +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=centos -Release=9 - -[Content] -Packages= - python3dist(pefile) - python3dist(pluggy) # python39-pluggy is a pytest dependency that's not installed for some reason. - python3dist(psutil) - python3dist(pytest) - -BuildPackages= - pkgconfig(libgcrypt) - python3dist(jinja2) - python3dist(lxml) - python3dist(pyelftools) -- cgit v1.2.1