diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-04-25 16:04:49 +0200 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2023-05-01 15:39:50 +0200 |
commit | d052cc88932926f964bcf227c1c5032c5400cd4a (patch) | |
tree | ffff1487d6835c6359cf25334fd75ee589391540 | |
parent | meson: Search for find program (diff) | |
download | systemd-d052cc88932926f964bcf227c1c5032c5400cd4a.tar.xz systemd-d052cc88932926f964bcf227c1c5032c5400cd4a.zip |
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/<profile>/mkosi.conf.d and put all the preset specific configuration
in there.
53 files changed, 596 insertions, 315 deletions
diff --git a/.github/workflows/mkosi.yml b/.github/workflows/mkosi.yml index c38a6e75b0..173caea489 100644 --- a/.github/workflows/mkosi.yml +++ b/.github/workflows/mkosi.yml @@ -73,7 +73,7 @@ jobs: steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: systemd/mkosi@54f80aa8f687ed4d1759f0a7329c64c3f0ff70ad + - uses: systemd/mkosi@3008c7e9383669b7fb6f6afe556c6fd28f28f8f4 - name: Configure run: | 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/20-centos.conf b/mkosi.conf.d/10-centos.conf index 4181f03414..4181f03414 100644 --- a/mkosi.conf.d/20-centos.conf +++ b/mkosi.conf.d/10-centos.conf 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/21-centos-8/mkosi.reposdir/powertools.repo b/mkosi.conf.d/11-centos-8/mkosi.reposdir/powertools.repo index 1462257c08..1462257c08 100644 --- a/mkosi.conf.d/21-centos-8/mkosi.reposdir/powertools.repo +++ b/mkosi.conf.d/11-centos-8/mkosi.reposdir/powertools.repo 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-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.extra/root/.gdbinit b/mkosi.extra/root/.gdbinit deleted file mode 100644 index 1a2163e3a5..0000000000 --- a/mkosi.extra/root/.gdbinit +++ /dev/null @@ -1,3 +0,0 @@ -set debuginfod enabled off -set build-id-verbose 0 -set substitute-path ../src /root/src diff --git a/mkosi.extra/usr/lib/systemd/system-preset/00-mkosi.preset b/mkosi.extra/usr/lib/systemd/system-preset/00-mkosi.preset deleted file mode 100644 index e21493123c..0000000000 --- a/mkosi.extra/usr/lib/systemd/system-preset/00-mkosi.preset +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later -disable ssh.service -disable sshd.service -disable dnsmasq.service -disable isc-dhcp-server.service -disable isc-dhcp-server6.service diff --git a/mkosi.prepare b/mkosi.prepare deleted file mode 100755 index 7e00df0152..0000000000 --- a/mkosi.prepare +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: LGPL-2.1-or-later -set -e - -if [ "$(grep '^ID=' /etc/os-release)" = "ID=\"centos\"" ] && [ "$(grep '^VERSION=' /etc/os-release)" = "VERSION=\"8\"" ]; then - alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 - alternatives --set python3 /usr/bin/python3.9 -fi - -# Make sure the necessary test users are available in the build image. We do this here because the build -# script does not run as root. -if [ "$1" = "build" ]; then - for id in 1 2 3; do - getent group $id >/dev/null || echo "g testgroup$id $id -" | systemd-sysusers - - done -fi diff --git a/mkosi.build b/mkosi.presets/00-base/mkosi.build index 7ad3371ee7..e19251157d 100755 --- a/mkosi.build +++ b/mkosi.presets/00-base/mkosi.build @@ -162,31 +162,3 @@ if [ "$WITH_TESTS" = 1 ] ; then fi meson install -C "$BUILDDIR" --quiet --no-rebuild --only-changed - -if [ -d mkosi.kernel/ ]; then - SRCDIR="$SRCDIR/mkosi.kernel" - BUILDDIR="$BUILDDIR/mkosi.kernel" - cd "$SRCDIR" - mkdir -p "$BUILDDIR" - - # Ensure fast incremental builds by fixating these values which usually change for each build. - export KBUILD_BUILD_TIMESTAMP="Fri Jun 5 15:58:00 CEST 2015" - export KBUILD_BUILD_HOST="mkosi" - - scripts/kconfig/merge_config.sh -O "$BUILDDIR" \ - ../mkosi.kernel.config \ - tools/testing/selftests/bpf/config.x86_64 \ - tools/testing/selftests/bpf/config - - # Make sure systemd-boot boots this kernel and not the distro provided one by overriding the version. - make O="$BUILDDIR" VERSION=99 -j "$(nproc)" - - KERNEL_RELEASE=$(make O="$BUILDDIR" VERSION=99 -s kernelrelease) - mkdir -p "$DESTDIR/usr/lib/modules/$KERNEL_RELEASE" - make O="$BUILDDIR" VERSION=99 INSTALL_MOD_PATH="$DESTDIR/usr" modules_install - make O="$BUILDDIR" VERSION=99 INSTALL_PATH="$DESTDIR/usr/lib/modules/$KERNEL_RELEASE" install - mkdir -p "$DESTDIR/usr/lib/kernel/selftests" - make -C tools/testing/selftests -j "$(nproc)" O="$BUILDDIR" VERSION=99 KSFT_INSTALL_PATH="$DESTDIR/usr/lib/kernel/selftests" SKIP_TARGETS="" install - - ln -sf /usr/lib/kernel/selftests/bpf/bpftool "$DESTDIR/usr/bin/bpftool" -fi diff --git a/mkosi.presets/00-base/mkosi.conf b/mkosi.presets/00-base/mkosi.conf new file mode 100644 index 0000000000..a65d427067 --- /dev/null +++ b/mkosi.presets/00-base/mkosi.conf @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Output] +Format=directory + +[Content] +Bootable=no +BuildSources=../.. +CleanPackageMetadata=no +Packages= + kmod + less + systemd + udev + +BuildPackages= + acl + diffutils + gawk + binutils + clang + gettext + git + gperf + grep + lld + llvm + make + meson + pkgconf + rsync + sed + tar + zstd diff --git a/mkosi.presets/00-base/mkosi.conf.d/10-arch.conf b/mkosi.presets/00-base/mkosi.conf.d/10-arch.conf new file mode 100644 index 0000000000..473d199718 --- /dev/null +++ b/mkosi.presets/00-base/mkosi.conf.d/10-arch.conf @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=arch + +[Content] +Packages= + gnutls + libbpf + libfido2 + libmicrohttpd + libnftnl + libpwquality + libxkbcommon + openssl + qrencode + systemd-sysvcompat + tpm2-tss + +BuildPackages= + bpf + docbook-xsl + glib2 + libxslt + linux-api-headers + perl + python + python-jinja + python-lxml + python-pefile + python-pyelftools diff --git a/mkosi.conf.d/20-centos-fedora.conf b/mkosi.presets/00-base/mkosi.conf.d/10-centos-fedora.conf index d78b924304..090daf60db 100644 --- a/mkosi.conf.d/20-centos-fedora.conf +++ b/mkosi.presets/00-base/mkosi.conf.d/10-centos-fedora.conf @@ -5,67 +5,40 @@ Distribution=centos fedora [Content] Packages= - alsa-lib audit-libs - cryptsetup - dhcp-server - dnf - fuse - glib2 - glibc-minimal-langpack - glibc.i686 + cryptsetup-libs gnutls - iproute - iproute-tc - kernel-core libasan libbpf - libcap-ng - libcap-ng-utils libfido2 libgcrypt libmicrohttpd - libmnl + libnftnl libubsan libxcrypt libxkbcommon - netcat - numactl-libs - openssh-server - p11-kit - pam - passwd - polkit - popt - procps-ng - quota + openssl-libs + qrencode-libs tpm2-tss util-linux - vim-common BuildPackages= /usr/bin/pkg-config bpftool docbook-xsl - dwarves - glibc-devel.i686 - glibc-static - glibc-static.i686 + findutils 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) @@ -74,7 +47,7 @@ BuildPackages= pkgconfig(libidn2) pkgconfig(libkmod) pkgconfig(libmicrohttpd) - pkgconfig(libmnl) + pkgconfig(libnftnl) pkgconfig(libpcre2-8) pkgconfig(libqrencode) pkgconfig(libseccomp) @@ -83,12 +56,12 @@ BuildPackages= pkgconfig(mount) pkgconfig(numa) pkgconfig(openssl) + 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 + rpm diff --git a/mkosi.conf.d/20-debian-ubuntu/mkosi.conf b/mkosi.presets/00-base/mkosi.conf.d/10-debian-ubuntu.conf index 584536ef6b..f5c3afbef4 100644 --- a/mkosi.conf.d/20-debian-ubuntu/mkosi.conf +++ b/mkosi.presets/00-base/mkosi.conf.d/10-debian-ubuntu.conf @@ -5,69 +5,39 @@ 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 + libnftnl11 libp11-kit0 libpam0g - libpopt0 libpwquality1 libqrencode4 + libssl3 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 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 @@ -75,12 +45,10 @@ BuildPackages= libiptc-dev libkmod-dev libmicrohttpd-dev - libmnl-dev libmount-dev - libnuma-dev + libnftnl-dev libp11-kit-dev libpam0g-dev - libpopt-dev libpwquality-dev libqrencode-dev libseccomp-dev @@ -89,9 +57,10 @@ BuildPackages= libxen-dev libxkbcommon-dev libzstd-dev - pahole - python3-docutils + python3 python3-jinja2 python3-lxml + python3-pefile python3-pyelftools + python3-pytest xsltproc diff --git a/mkosi.conf.d/20-debian.conf b/mkosi.presets/00-base/mkosi.conf.d/10-debian.conf index c251ab6542..020b02b61c 100644 --- a/mkosi.conf.d/20-debian.conf +++ b/mkosi.presets/00-base/mkosi.conf.d/10-debian.conf @@ -3,13 +3,9 @@ [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.presets/00-base/mkosi.conf.d/10-fedora.conf index 1574420487..035715979c 100644 --- a/mkosi.conf.d/20-fedora.conf +++ b/mkosi.presets/00-base/mkosi.conf.d/10-fedora.conf @@ -3,22 +3,13 @@ [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) + python3 python3dist(jinja2) python3dist(lxml) + python3dist(pefile) python3dist(pyelftools) + python3dist(pytest) diff --git a/mkosi.conf.d/20-opensuse.conf b/mkosi.presets/00-base/mkosi.conf.d/10-opensuse.conf index caf84ba0ab..b8bce7148e 100644 --- a/mkosi.conf.d/20-opensuse.conf +++ b/mkosi.presets/00-base/mkosi.conf.d/10-opensuse.conf @@ -3,23 +3,13 @@ [Match] Distribution=opensuse -[Distribution] -Release=tumbleweed - [Content] +# We install gawk, gzip, grep, xz here explicitly so that the busybox versions don't get installed instead. Packages= - btrfs-progs - dbus-1 - f2fs-tools - fuse - gcc # Provides libasan/libubsan - glibc-32bit - glibc-locale-base - kernel-default - libasound2 + gawk + grep + gzip libbpf1 - libcap-ng-utils - libcap-ng0 libcrypt1 libcryptsetup12 libdw1 @@ -28,48 +18,34 @@ Packages= libgcrypt20 libglib-2_0-0 libkmod2 - liblz4-1 - libmnl0 libmount1 - libnuma1 + libnftnl11 + libopenssl3 libp11-kit0 - libpopt0 libqrencode4 libseccomp2 libxkbcommon0 - openssh-server + libzstd1 pam - python3-pefile - python3-psutil - python3-pytest shadow tpm2-0-tss - vim + xz 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 @@ -79,34 +55,27 @@ BuildPackages= libgcrypt-devel libgnutls-devel libkmod-devel - liblz4-devel libmicrohttpd-devel - libmnl-devel libmount-devel - libnuma-devel + libnftnl-devel libpwquality-devel libseccomp-devel libselinux-devel libxkbcommon-devel libxslt-tools + libzstd-devel openssl-devel pam-devel pciutils-devel - pcre-devel - popt-devel - python3-docutils + python3 python3-Jinja2 python3-lxml + python3-pefile python3-pyelftools + python3-pytest 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.presets/00-base/mkosi.conf.d/10-ubuntu.conf index 036c1734b2..717809fd03 100644 --- a/mkosi.conf.d/20-ubuntu.conf +++ b/mkosi.presets/00-base/mkosi.conf.d/10-ubuntu.conf @@ -3,14 +3,9 @@ [Match] Distribution=ubuntu -[Distribution] -Release=jammy -Repositories=universe - [Content] Packages= libbpf0 - linux-virtual BuildPackages= linux-tools-common diff --git a/mkosi.conf.d/21-centos-8/mkosi.conf b/mkosi.presets/00-base/mkosi.conf.d/11-centos-8.conf index d610212b61..ef001c92c9 100644 --- a/mkosi.conf.d/21-centos-8/mkosi.conf +++ b/mkosi.presets/00-base/mkosi.conf.d/11-centos-8.conf @@ -5,15 +5,12 @@ 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. + platform-python python3.9dist(jinja2) python3.9dist(lxml) + python3.9dist(pefile) python3.9dist(pyelftools) + python3.9dist(pytest) + python39 diff --git a/mkosi.presets/00-base/mkosi.conf.d/11-centos-9.conf b/mkosi.presets/00-base/mkosi.conf.d/11-centos-9.conf new file mode 100644 index 0000000000..61c1d27f44 --- /dev/null +++ b/mkosi.presets/00-base/mkosi.conf.d/11-centos-9.conf @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=centos +Release=9 + +[Content] +BuildPackages= + pkgconfig(libgcrypt) + platform-python + python3dist(jinja2) + python3dist(lxml) + python3dist(pefile) + python3dist(pyelftools) + python3dist(pytest) diff --git a/mkosi.presets/00-base/mkosi.extra/usr/lib/systemd/system-preset/00-mkosi.preset b/mkosi.presets/00-base/mkosi.extra/usr/lib/systemd/system-preset/00-mkosi.preset new file mode 100644 index 0000000000..64baf3ba6e --- /dev/null +++ b/mkosi.presets/00-base/mkosi.extra/usr/lib/systemd/system-preset/00-mkosi.preset @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +# mkosi adds its own ssh units via the --ssh switch so disable the default ones. +disable ssh.service +disable sshd.service + +# These are started manually in integration tests so don't start them by default. +disable dnsmasq.service +disable isc-dhcp-server.service +disable isc-dhcp-server6.service + +# Pulled in via dracut-network by kexec-tools on Fedora. +disable NetworkManager.service + +# Make sure dbus-broker is started by default on Debian/Ubuntu. +enable dbus-broker.service + +# systemd-networkd is disabled by default on Fedora so make sure it is enabled. +enable systemd-networkd.service diff --git a/mkosi.presets/00-base/mkosi.extra/usr/lib/systemd/system-preset/99-mkosi.preset b/mkosi.presets/00-base/mkosi.extra/usr/lib/systemd/system-preset/99-mkosi.preset new file mode 100644 index 0000000000..710ee7c6f9 --- /dev/null +++ b/mkosi.presets/00-base/mkosi.extra/usr/lib/systemd/system-preset/99-mkosi.preset @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +# Make sure that services are disabled by default (primarily for Debian/Ubuntu). +disable * diff --git a/mkosi.conf.d/20-debian-ubuntu/mkosi.extra/usr/lib/tmpfiles.d/locale.conf b/mkosi.presets/00-base/mkosi.extra/usr/lib/tmpfiles.d/locale.conf index e1a8e8171a..e1a8e8171a 100644 --- a/mkosi.conf.d/20-debian-ubuntu/mkosi.extra/usr/lib/tmpfiles.d/locale.conf +++ b/mkosi.presets/00-base/mkosi.extra/usr/lib/tmpfiles.d/locale.conf diff --git a/mkosi.presets/00-base/mkosi.prepare b/mkosi.presets/00-base/mkosi.prepare new file mode 100755 index 0000000000..269ba3e153 --- /dev/null +++ b/mkosi.presets/00-base/mkosi.prepare @@ -0,0 +1,18 @@ +#!/bin/sh +# SPDX-License-Identifier: LGPL-2.1-or-later +set -e + +if [ "$1" = "build" ]; then + . /etc/os-release + + if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then + alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 + alternatives --set python3 /usr/bin/python3.9 + fi + + # Make sure the necessary test users are available in the build image. We do this here because the build + # script does not run as root. + for id in 1 2 3; do + getent group $id >/dev/null || echo "g testgroup$id $id -" | systemd-sysusers - + done +fi diff --git a/mkosi.presets/10-initrd.conf b/mkosi.presets/10-initrd.conf new file mode 100644 index 0000000000..4201770f2e --- /dev/null +++ b/mkosi.presets/10-initrd.conf @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Output] +Format=cpio +# TODO: Switch to zstd once we stop building CentOS Stream 8. +CompressOutput=xz + +[Content] +BaseTrees=mkosi.output/base +MakeInitrd=yes + +# Arch Linux doesn't split their gcc-libs package so we manually remove unneeded stuff here to make sure it +# doesn't end up in the initrd. +RemoveFiles= + /usr/lib/libgfortran.so* + /usr/lib/libgo.so* + /usr/lib/libgomp.so* + /usr/lib/libgphobos.so* + /usr/lib/libobjc.so* + /usr/lib/libstdc++.so* diff --git a/mkosi.presets/20-final/mkosi.build b/mkosi.presets/20-final/mkosi.build new file mode 100755 index 0000000000..ed355abd20 --- /dev/null +++ b/mkosi.presets/20-final/mkosi.build @@ -0,0 +1,32 @@ +#!/bin/sh +# SPDX-License-Identifier: LGPL-2.1-or-later +set -e + +if [ -d "$SRCDIR"/mkosi.kernel/ ]; then + SRCDIR="$SRCDIR/mkosi.kernel" + BUILDDIR="$BUILDDIR/mkosi.kernel" + cd "$SRCDIR" + mkdir -p "$BUILDDIR" + + # Ensure fast incremental builds by fixating these values which usually change for each build. + export KBUILD_BUILD_TIMESTAMP="Fri Jun 5 15:58:00 CEST 2015" + export KBUILD_BUILD_HOST="mkosi" + + scripts/kconfig/merge_config.sh -O "$BUILDDIR" \ + ../mkosi.kernel.config \ + tools/testing/selftests/bpf/config.x86_64 \ + tools/testing/selftests/bpf/config + + # Make sure systemd-boot boots this kernel and not the distro provided one by overriding the version. + make O="$BUILDDIR" VERSION=99 -j "$(nproc)" + + KERNEL_RELEASE=$(make O="$BUILDDIR" VERSION=99 -s kernelrelease) + mkdir -p "$DESTDIR/usr/lib/modules/$KERNEL_RELEASE" + make O="$BUILDDIR" VERSION=99 INSTALL_MOD_PATH="$DESTDIR/usr" modules_install + make O="$BUILDDIR" VERSION=99 INSTALL_PATH="$DESTDIR/usr/lib/modules/$KERNEL_RELEASE" install + mkdir -p "$DESTDIR/usr/lib/kernel/selftests" + make -C tools/testing/selftests -j "$(nproc)" O="$BUILDDIR" VERSION=99 KSFT_INSTALL_PATH="$DESTDIR/usr/lib/kernel/selftests" SKIP_TARGETS="" install + + mkdir -p "$DESTDIR"/usr/bin + ln -sf /usr/lib/kernel/selftests/bpf/bpftool "$DESTDIR/usr/bin/bpftool" +fi diff --git a/mkosi.presets/20-final/mkosi.conf b/mkosi.presets/20-final/mkosi.conf new file mode 100644 index 0000000000..d15a17a161 --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Content] +BaseTrees=../../mkosi.output/base +ExtraTrees=../../src:/root/src +Initrds=../../mkosi.output/initrd.cpio.xz +Packages= + acl + bash-completion + coreutils + diffutils + dnsmasq + dosfstools + e2fsprogs + findutils + gcc # Sanitizer libraries + gdb + grep + kbd + kexec-tools + less + mtools + nano + nftables + openssl + qrencode + sed + strace + tree + util-linux + valgrind + wireguard-tools + xfsprogs + zsh + +[Validation] +Password= +Autologin=yes diff --git a/mkosi.presets/20-final/mkosi.conf.d/10-arch.conf b/mkosi.presets/20-final/mkosi.conf.d/10-arch.conf new file mode 100644 index 0000000000..b0bbcf0c6a --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/10-arch.conf @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=arch + +[Content] +Packages= + btrfs-progs + compsize + dhcp + f2fs-tools + glib2 + iproute + linux + man-db + openbsd-netcat + openssh + polkit + python-pefile + python-psutil + python-pytest + python3 + quota-tools + shadow + vim diff --git a/mkosi.presets/20-final/mkosi.conf.d/10-centos-fedora.conf b/mkosi.presets/20-final/mkosi.conf.d/10-centos-fedora.conf new file mode 100644 index 0000000000..d89f827839 --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/10-centos-fedora.conf @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=centos fedora + +[Content] +Packages= + cryptsetup + dhcp-server + dnf + glib2 + iproute + iproute-tc + kernel-core + libcap-ng-utils + netcat + openssh-server + p11-kit + pam + passwd + polkit + procps-ng + quota + vim-common diff --git a/mkosi.presets/20-final/mkosi.conf.d/10-debian-ubuntu.conf b/mkosi.presets/20-final/mkosi.conf.d/10-debian-ubuntu.conf new file mode 100644 index 0000000000..804aa67228 --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/10-debian-ubuntu.conf @@ -0,0 +1,27 @@ +# 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 + iproute2 + isc-dhcp-server + libcap-ng-utils + netcat-openbsd + openssh-server + passwd + policykit-1 + procps + python3 + python3-pefile + python3-psutil + python3-pytest + quota + xxd diff --git a/mkosi.presets/20-final/mkosi.conf.d/10-debian.conf b/mkosi.presets/20-final/mkosi.conf.d/10-debian.conf new file mode 100644 index 0000000000..3eb7a5453e --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/10-debian.conf @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=debian + +[Content] +Packages= + linux-image-cloud-amd64 diff --git a/mkosi.presets/20-final/mkosi.conf.d/10-fedora.conf b/mkosi.presets/20-final/mkosi.conf.d/10-fedora.conf new file mode 100644 index 0000000000..5ae623e47d --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/10-fedora.conf @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=fedora + +[Content] +Packages= + btrfs-progs + compsize + f2fs-tools + python3 + python3dist(pefile) + python3dist(psutil) + python3dist(pytest) diff --git a/mkosi.presets/20-final/mkosi.conf.d/10-opensuse.conf b/mkosi.presets/20-final/mkosi.conf.d/10-opensuse.conf new file mode 100644 index 0000000000..f948dd6a37 --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/10-opensuse.conf @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=opensuse + +[Content] +Packages= + btrfs-progs + cryptsetup + dbus-broker + f2fs-tools + glibc-locale-base + kernel-default + libcap-ng-utils + openssh-server + python3 + python3-pefile + python3-psutil + python3-pytest + quota + shadow + vim diff --git a/mkosi.presets/20-final/mkosi.conf.d/10-ubuntu.conf b/mkosi.presets/20-final/mkosi.conf.d/10-ubuntu.conf new file mode 100644 index 0000000000..eb88ca7644 --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/10-ubuntu.conf @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=ubuntu + +[Content] +Packages= + linux-virtual diff --git a/mkosi.presets/20-final/mkosi.conf.d/11-centos-8.conf b/mkosi.presets/20-final/mkosi.conf.d/11-centos-8.conf new file mode 100644 index 0000000000..2fa476454d --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/11-centos-8.conf @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=centos +Release=8 + +[Content] +Packages= + platform-python + 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) + python39 diff --git a/mkosi.conf.d/21-centos-9.conf b/mkosi.presets/20-final/mkosi.conf.d/11-centos-9.conf index 0febf2c2ee..d6ab3ee1c3 100644 --- a/mkosi.conf.d/21-centos-9.conf +++ b/mkosi.presets/20-final/mkosi.conf.d/11-centos-9.conf @@ -6,13 +6,8 @@ Release=9 [Content] Packages= + platform-python 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) diff --git a/mkosi.presets/20-final/mkosi.conf.d/20-kernel-arch.conf b/mkosi.presets/20-final/mkosi.conf.d/20-kernel-arch.conf new file mode 100644 index 0000000000..6ac0b58495 --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/20-kernel-arch.conf @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +PathExists=mkosi.kernel/ +Distribution=arch + +[Content] +Packages= + alsa-lib + fuse2 + libcap + libcap-ng + libelf + libmnl + numactl + popt + +BuildPackages= + pahole + python-docutils diff --git a/mkosi.presets/20-final/mkosi.conf.d/20-kernel-centos-fedora.conf b/mkosi.presets/20-final/mkosi.conf.d/20-kernel-centos-fedora.conf new file mode 100644 index 0000000000..c42f9916ee --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/20-kernel-centos-fedora.conf @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +PathExists=mkosi.kernel/ +Distribution=centos fedora + +[Content] +Packages= + alsa-lib + elfutils-libelf + fuse + glibc.i686 + libcap + libcap-ng + libcap-ng-utils + libmnl + numactl-libs + popt + +BuildPackages= + dwarves + glibc-devel.i686 + glibc-static + glibc-static.i686 + pkgconfig(alsa) + pkgconfig(fuse) + pkgconfig(libcap-ng) + pkgconfig(libcap) + pkgconfig(libelf) + pkgconfig(libmnl) + pkgconfig(numa) + pkgconfig(openssl) + pkgconfig(popt) + python3-docutils diff --git a/mkosi.presets/20-final/mkosi.conf.d/20-kernel-debian-ubuntu.conf b/mkosi.presets/20-final/mkosi.conf.d/20-kernel-debian-ubuntu.conf new file mode 100644 index 0000000000..00338fa4d1 --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/20-kernel-debian-ubuntu.conf @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +PathExists=mkosi.kernel/ +Distribution=debian ubuntu + +[Content] +Packages= + fuse + libasound2 + libc6-i386 + libcap-ng0 + libcap2 + libelf1 + libmnl0 + libnuma1 + libpopt0 + +BuildPackages= + gcc-multilib + libasound-dev + libc6-dev + libc6-dev-i686 + libcap-ng-dev + libcap-dev + libelf-dev + libfuse-dev + libmnl-dev + libnuma-dev + libpopt-dev + pahole + python3-docutils diff --git a/mkosi.presets/20-final/mkosi.conf.d/20-kernel-fedora.conf b/mkosi.presets/20-final/mkosi.conf.d/20-kernel-fedora.conf new file mode 100644 index 0000000000..ea94c14346 --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/20-kernel-fedora.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +PathExists=mkosi.kernel/ +Distribution=fedora + +[Content] +BuildPackages= + libcap-static diff --git a/mkosi.presets/20-final/mkosi.conf.d/20-kernel-opensuse.conf b/mkosi.presets/20-final/mkosi.conf.d/20-kernel-opensuse.conf new file mode 100644 index 0000000000..aec631f1af --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/20-kernel-opensuse.conf @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +PathExists=mkosi.kernel/ +Distribution=opensuse + +[Content] +Packages= + fuse + glibc-32bit + libasound2 + libcap-ng0 + libcap2 + libelf1 + libmnl0 + libnuma1 + libpopt0 + +BuildPackages= + alsa-devel + dwarves + fuse-devel + gcc-32bit + glibc-devel-32bit + glibc-devel-static-32bit + glibc-static + libcap-devel + libcap-ng-dev + libelf-devel + liblz4-dev + libmnl-dev + libnuma-devel + pcre-devel + popt-devel + python3-docutils diff --git a/mkosi.presets/20-final/mkosi.conf.d/20-kernel.conf b/mkosi.presets/20-final/mkosi.conf.d/20-kernel.conf new file mode 100644 index 0000000000..5505b41a86 --- /dev/null +++ b/mkosi.presets/20-final/mkosi.conf.d/20-kernel.conf @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +PathExists=mkosi.kernel/ + +[Content] +BuildSources=./ +BuildPackages= + bc + binutils + bison + clang + flex + gcc + lld + llvm + make + make + rsync + tar diff --git a/mkosi.extra/etc/issue b/mkosi.presets/20-final/mkosi.extra/etc/issue index 6aa6fc0ec0..6aa6fc0ec0 100644 --- a/mkosi.extra/etc/issue +++ b/mkosi.presets/20-final/mkosi.extra/etc/issue diff --git a/mkosi.extra/usr/lib/systemd/mkosi-check-and-shutdown.sh b/mkosi.presets/20-final/mkosi.extra/usr/lib/systemd/mkosi-check-and-shutdown.sh index b86d2d3e69..b86d2d3e69 100755 --- a/mkosi.extra/usr/lib/systemd/mkosi-check-and-shutdown.sh +++ b/mkosi.presets/20-final/mkosi.extra/usr/lib/systemd/mkosi-check-and-shutdown.sh diff --git a/mkosi.extra/usr/lib/systemd/system/mkosi-check-and-shutdown.service b/mkosi.presets/20-final/mkosi.extra/usr/lib/systemd/system/mkosi-check-and-shutdown.service index 6539325108..6539325108 100644 --- a/mkosi.extra/usr/lib/systemd/system/mkosi-check-and-shutdown.service +++ b/mkosi.presets/20-final/mkosi.extra/usr/lib/systemd/system/mkosi-check-and-shutdown.service diff --git a/mkosi.kernel.config b/mkosi.presets/20-final/mkosi.kernel.config index ab3ffe2fea..ab3ffe2fea 100644 --- a/mkosi.kernel.config +++ b/mkosi.presets/20-final/mkosi.kernel.config diff --git a/mkosi.postinst b/mkosi.presets/20-final/mkosi.postinst index 82c23cf87a..4339d7fd22 100755 --- a/mkosi.postinst +++ b/mkosi.presets/20-final/mkosi.postinst @@ -73,3 +73,10 @@ fi # Let tmpfiles.d/systemd-resolve.conf handle the symlink rm -f /etc/resolv.conf + +. /etc/os-release + +if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then + alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 + alternatives --set python3 /usr/bin/python3.9 +fi |