From 9e8cfe5daacce9e74a1f063b1048d71f7843f90e Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 12 Jul 2024 16:09:21 +0200 Subject: [PATCH 01/15] mkosi: Update to latest --- .github/workflows/mkosi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mkosi.yml b/.github/workflows/mkosi.yml index d68d26fa554..48ed15d9adc 100644 --- a/.github/workflows/mkosi.yml +++ b/.github/workflows/mkosi.yml @@ -99,7 +99,7 @@ jobs: steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - - uses: systemd/mkosi@4681dd733a925cd048d0301af26221bce0c95eed + - uses: systemd/mkosi@7e975957a6af65c2e70428b6cda0c163ca7e1adc # Freeing up disk space with rm -rf can take multiple minutes. Since we don't need the extra free space # immediately, we remove the files in the background. However, we first move them to a different location From 72a8f508e54188c64687633f96021c185a79938c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 14 Jul 2024 17:50:23 +0200 Subject: [PATCH 02/15] mkosi: update fedora commit reference * a3524fc837 Use a more precise Recommends for libkxbcommon * 980ede8c0f Drop machined revert * d569018a92 Rebuilt for the bin-sbin merge * 8881fa94ee Version 256.2 * 1cc4f83002 Link systemd-executor statically * 0319e62d9c Update dracut workaround * c96f54de22 Fix ELN build * 3f68c5d802 Only exclude dracut conflicts on non-fedora on upstream builds * 7db154308b Conditionalize dracut Conflicts more --- mkosi.conf.d/10-fedora/mkosi.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkosi.conf.d/10-fedora/mkosi.conf b/mkosi.conf.d/10-fedora/mkosi.conf index b9f310d3c17..ff716e27df9 100644 --- a/mkosi.conf.d/10-fedora/mkosi.conf +++ b/mkosi.conf.d/10-fedora/mkosi.conf @@ -10,7 +10,7 @@ Release=rawhide Environment= GIT_URL=https://src.fedoraproject.org/rpms/systemd.git GIT_BRANCH=rawhide - GIT_COMMIT=f9fe17dbdee7242ccd4fd2858128c8952890bdb8 + GIT_COMMIT=a3524fc837f5e7b68f86b3e0a9d470a94a04c4c8 Packages= compsize From 7205fc7dc31eb2be3075ee6ba23ebe84324aa5cb Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 12 Jul 2024 15:33:49 +0200 Subject: [PATCH 03/15] mkosi: Introduce build image We want the exitrd image to be built with the latest systemd as well. As the exitrd image is built as part of mkosi.images, and all subimages are built before the main image, this implies the packages must be built as a subimage in mkosi.images/ as well. So we introduce the build image and move all logic related to building distribution packages there. This also has the nice side effect of slimming down the main image as the build dependencies are not installed into the main image anymore. It also makes sure the packages are built in a "clean" chroot without any of the other packages which we install in the main image available. --- mkosi.conf | 41 +++++++---- mkosi.conf.d/10-arch/mkosi.conf | 12 ---- mkosi.conf.d/10-arch/mkosi.prepare | 42 ++++++----- mkosi.conf.d/10-centos-fedora/mkosi.conf | 7 +- mkosi.conf.d/10-centos-fedora/mkosi.prepare | 66 +++--------------- mkosi.conf.d/10-centos/mkosi.conf | 5 -- mkosi.conf.d/10-debian-ubuntu/mkosi.conf | 17 +---- mkosi.conf.d/10-debian-ubuntu/mkosi.postinst | 29 -------- mkosi.conf.d/10-debian-ubuntu/mkosi.prepare | 18 +++-- mkosi.conf.d/10-fedora/mkosi.conf | 5 -- mkosi.conf.d/10-opensuse/mkosi.conf | 24 +------ mkosi.conf.d/10-opensuse/mkosi.prepare | 69 ++++--------------- mkosi.conf.d/20-build.conf | 9 +++ mkosi.conf.d/20-none.conf | 4 +- mkosi.conf.d/20-sanitizers.conf | 4 ++ mkosi.images/build/mkosi.conf | 11 +++ .../mkosi.conf.d/arch}/mkosi.build.chroot | 8 +-- .../build/mkosi.conf.d/arch/mkosi.conf | 16 +++++ .../build/mkosi.conf.d/arch/mkosi.prepare | 21 ++++++ .../centos-fedora}/mkosi.build.chroot | 10 +-- .../mkosi.conf.d/centos-fedora/mkosi.conf | 14 ++++ .../mkosi.conf.d/centos-fedora/mkosi.prepare | 63 +++++++++++++++++ .../build/mkosi.conf.d/centos/mkosi.conf | 14 ++++ .../debian-ubuntu}/mkosi.build.chroot | 12 ++-- .../mkosi.conf.d/debian-ubuntu/mkosi.conf | 18 +++++ .../mkosi.conf.d/debian-ubuntu/mkosi.prepare | 18 +++++ .../build/mkosi.conf.d/fedora/mkosi.conf | 10 +++ .../mkosi.conf.d/opensuse}/mkosi.build.chroot | 12 ++-- .../build/mkosi.conf.d/opensuse/mkosi.conf | 16 +++++ .../build/mkosi.conf.d/opensuse/mkosi.prepare | 62 +++++++++++++++++ mkosi.sync => mkosi.images/build/mkosi.sync | 5 ++ mkosi.images/exitrd/mkosi.conf | 3 + mkosi.images/exitrd/mkosi.conf.d/10-arch.conf | 2 +- .../exitrd/mkosi.conf.d/10-centos-fedora.conf | 2 +- .../exitrd/mkosi.conf.d/10-debian.conf | 2 +- .../exitrd/mkosi.conf.d/10-opensuse.conf | 3 + .../exitrd/mkosi.conf.d/10-ubuntu.conf | 2 +- .../exitrd/mkosi.conf.d/20-build.conf | 9 +++ mkosi.images/minimal-base/mkosi.conf | 3 + .../minimal-base/mkosi.conf.d/10-arch.conf | 3 + .../mkosi.conf.d/10-centos-fedora.conf | 3 + ...tu-opensuse.conf => 10-debian-ubuntu.conf} | 4 ++ .../mkosi.conf.d/10-opensuse.conf | 4 ++ .../minimal-base/mkosi.conf.d/20-build.conf | 9 +++ mkosi.initrd/mkosi.conf | 4 +- mkosi.sanitizers/mkosi.conf | 5 ++ mkosi.sanitizers/mkosi.conf.d/arch.conf | 9 +++ .../mkosi.conf.d/debian-ubuntu.conf | 11 +++ mkosi.sanitizers/mkosi.conf.d/opensuse.conf | 10 +++ .../mkosi.postinst | 32 +++++---- tools/update-distro-hash.py | 5 +- 51 files changed, 487 insertions(+), 300 deletions(-) delete mode 100755 mkosi.conf.d/10-debian-ubuntu/mkosi.postinst create mode 100644 mkosi.conf.d/20-build.conf create mode 100644 mkosi.images/build/mkosi.conf rename {mkosi.conf.d/10-arch => mkosi.images/build/mkosi.conf.d/arch}/mkosi.build.chroot (95%) create mode 100644 mkosi.images/build/mkosi.conf.d/arch/mkosi.conf create mode 100755 mkosi.images/build/mkosi.conf.d/arch/mkosi.prepare rename {mkosi.conf.d/10-centos-fedora => mkosi.images/build/mkosi.conf.d/centos-fedora}/mkosi.build.chroot (95%) create mode 100644 mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.conf create mode 100755 mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.prepare create mode 100644 mkosi.images/build/mkosi.conf.d/centos/mkosi.conf rename {mkosi.conf.d/10-debian-ubuntu => mkosi.images/build/mkosi.conf.d/debian-ubuntu}/mkosi.build.chroot (96%) create mode 100644 mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.conf create mode 100755 mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.prepare create mode 100644 mkosi.images/build/mkosi.conf.d/fedora/mkosi.conf rename {mkosi.conf.d/10-opensuse => mkosi.images/build/mkosi.conf.d/opensuse}/mkosi.build.chroot (94%) create mode 100644 mkosi.images/build/mkosi.conf.d/opensuse/mkosi.conf create mode 100755 mkosi.images/build/mkosi.conf.d/opensuse/mkosi.prepare rename mkosi.sync => mkosi.images/build/mkosi.sync (88%) create mode 100644 mkosi.images/exitrd/mkosi.conf.d/20-build.conf rename mkosi.images/minimal-base/mkosi.conf.d/{10-debian-ubuntu-opensuse.conf => 10-debian-ubuntu.conf} (76%) create mode 100644 mkosi.images/minimal-base/mkosi.conf.d/20-build.conf create mode 100644 mkosi.sanitizers/mkosi.conf create mode 100644 mkosi.sanitizers/mkosi.conf.d/arch.conf create mode 100644 mkosi.sanitizers/mkosi.conf.d/debian-ubuntu.conf create mode 100644 mkosi.sanitizers/mkosi.conf.d/opensuse.conf rename mkosi.sanitizers.chroot => mkosi.sanitizers/mkosi.postinst (66%) diff --git a/mkosi.conf b/mkosi.conf index b47b30c98b9..5654af0956c 100644 --- a/mkosi.conf +++ b/mkosi.conf @@ -3,6 +3,24 @@ [Config] MinimumVersion=23~devel InitrdInclude=mkosi.initrd/ +Dependencies= + exitrd + minimal-base + minimal-0 + minimal-1 + +PassEnvironment= + NO_BUILD + NO_SYNC + WIPE + SANITIZERS + CFLAGS + LDFLAGS + LLVM + MESON_VERBOSE + MESON_OPTIONS + SYSEXT + WITH_DEBUG [Output] RepartDirectories=mkosi.repart @@ -14,11 +32,18 @@ CacheDirectory=build/mkosi.cache BuildSourcesEphemeral=yes Autologin=yes -PostInstallationScripts=mkosi.sanitizers.chroot ExtraTrees= mkosi.crt:/usr/lib/verity.d/mkosi.crt # sysext verification key mkosi.leak-sanitizer-suppressions:/usr/lib/systemd/leak-sanitizer-suppressions mkosi.coredump-journal-storage.conf:/usr/lib/systemd/coredump.conf.d/10-coredump-journal-storage.conf + %O/minimal-0.root-%a.raw:/usr/share/minimal_0.raw + %O/minimal-0.root-%a-verity.raw:/usr/share/minimal_0.verity + %O/minimal-0.root-%a-verity-sig.raw:/usr/share/minimal_0.verity.sig + %O/minimal-1.root-%a.raw:/usr/share/minimal_1.raw + %O/minimal-1.root-%a-verity.raw:/usr/share/minimal_1.verity + %O/minimal-1.root-%a-verity-sig.raw:/usr/share/minimal_1.verity.sig + %O/minimal-base:/usr/share/TEST-13-NSPAWN-container-template + %O/exitrd:/exitrd Environment= SYSTEMD_REPART_OVERRIDE_FSTYPE_ROOT=%F @@ -57,16 +82,6 @@ KernelCommandLine=systemd.crash_shell KernelModulesInitrdExclude=.* KernelModulesInitrdInclude=default -ExtraTrees= - %O/minimal-0.root-%a.raw:/usr/share/minimal_0.raw - %O/minimal-0.root-%a-verity.raw:/usr/share/minimal_0.verity - %O/minimal-0.root-%a-verity-sig.raw:/usr/share/minimal_0.verity.sig - %O/minimal-1.root-%a.raw:/usr/share/minimal_1.raw - %O/minimal-1.root-%a-verity.raw:/usr/share/minimal_1.verity - %O/minimal-1.root-%a-verity-sig.raw:/usr/share/minimal_1.verity.sig - %O/minimal-base:/usr/share/TEST-13-NSPAWN-container-template - %O/exitrd:/exitrd - InitrdPackages= btrfs-progs findutils @@ -79,7 +94,6 @@ Packages= bash-completion bpftrace btrfs-progs - clang coreutils curl diffutils @@ -97,8 +111,6 @@ Packages= kmod knot less - lld - llvm lvm2 man mdadm @@ -117,7 +129,6 @@ Packages= sed socat strace - systemd tar tmux tree diff --git a/mkosi.conf.d/10-arch/mkosi.conf b/mkosi.conf.d/10-arch/mkosi.conf index d9f75c65d33..e7288cc19df 100644 --- a/mkosi.conf.d/10-arch/mkosi.conf +++ b/mkosi.conf.d/10-arch/mkosi.conf @@ -4,11 +4,6 @@ Distribution=arch [Content] -Environment= - GIT_URL=https://gitlab.archlinux.org/archlinux/packaging/packages/systemd.git - GIT_BRANCH=main - GIT_COMMIT=d74b24c7c6077740c35a876445febe6d26bf013c - VolatilePackages= systemd systemd-libs @@ -20,18 +15,14 @@ VolatilePackages= Packages= bind bpf - compiler-rt compsize cryptsetup dbus-broker dbus-broker-units - debugedit dhcp f2fs-tools - fakeroot git gnutls - gnutls iproute iputils linux @@ -43,7 +34,6 @@ Packages= openssl pacman perf - pkgconf polkit procps-ng psmisc @@ -57,11 +47,9 @@ Packages= stress-ng tgt tpm2-tools - tpm2-tss vim InitrdPackages= - compiler-rt tpm2-tools InitrdVolatilePackages= diff --git a/mkosi.conf.d/10-arch/mkosi.prepare b/mkosi.conf.d/10-arch/mkosi.prepare index fd78e81114e..aac7b3d76f9 100755 --- a/mkosi.conf.d/10-arch/mkosi.prepare +++ b/mkosi.conf.d/10-arch/mkosi.prepare @@ -2,28 +2,32 @@ # SPDX-License-Identifier: LGPL-2.1-or-later set -e -if [ "$1" = "build" ] || ((NO_BUILD)); then +if [[ "$1" == "build" ]]; then exit 0 fi -# shellcheck source=/dev/null -. "$BUILDROOT/usr/lib/os-release" +DEPS="" -if [ ! -f "pkg/$ID/PKGBUILD" ]; then - echo "PKGBUILD not found at pkg/$ID/PKGBUILD, run mkosi once with -ff to make sure the PKGBUILD is cloned" >&2 - exit 1 -fi +while read -r PACKAGE; do + DEPS="$DEPS $( + pacman --sync --info "$PACKAGE" | + sed '1,/^$/d' | # Only keep result from first repository (delete everything after first blank line). + sed --quiet 's/^Depends On *: //p' # Filter out everything except "Depends On:" line and fetch dependencies from it. + )" -# We get depends and optdepends from .SRCINFO as getting them from the PKGBUILD is rather complex. -sed --expression 's/^[ \t]*//' "pkg/$ID/.SRCINFO" | - grep --regexp '^depends =' --regexp '^optdepends =' | - sed --expression 's/^depends = //' --expression 's/^optdepends = //' --expression 's/:.*//' --expression 's/=.*//' | - xargs --delimiter '\n' mkosi-install + DEPS="$DEPS $( + pacman --sync --info "$PACKAGE" | + sed '1,/^$/d' | # Only keep result from first repository (delete everything after first blank line). + sed --quiet '/Optional Deps/,/Conflicts With/{/Conflicts With/!p}' | # Get every line from "Optional Deps" (inclusive) until "Conflicts With" (exclusive). + sed 's/Optional Deps *: //' | # Drop "Optional Deps :" from first line. + sed 's/ *\(.*\):.*/\1/' | # Drop descriptions (everything after first colon for all lines). + tr '\n' ' ' # Transform newlines to whitespace. + )" +done < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG") -# We get makedepends from the PKGBUILD as .SRCINFO can't encode conditional dependencies depending on -# whether some environment variable is set or not. -# shellcheck source=/dev/null -_systemd_UPSTREAM=1 . "pkg/$ID/PKGBUILD" - -# shellcheck disable=SC2154 -mkosi-install "${makedepends[@]}" +echo "$DEPS" | + xargs | # Remove extra whitespace. + tr ' ' '\n' | + grep --invert-match --regexp systemd --regexp None | # systemd packages will be installed later on. + sort --unique | + xargs --delimiter '\n' --no-run-if-empty mkosi-install diff --git a/mkosi.conf.d/10-centos-fedora/mkosi.conf b/mkosi.conf.d/10-centos-fedora/mkosi.conf index 4c6109a5445..d046eb218b5 100644 --- a/mkosi.conf.d/10-centos-fedora/mkosi.conf +++ b/mkosi.conf.d/10-centos-fedora/mkosi.conf @@ -11,6 +11,7 @@ VolatilePackages= systemd-container systemd-devel systemd-journal-remote + systemd-libs systemd-networkd systemd-networkd-defaults systemd-oomd-defaults @@ -23,7 +24,6 @@ VolatilePackages= Packages= bind-utils bpftool - compiler-rt cryptsetup device-mapper-event device-mapper-multipath @@ -33,7 +33,6 @@ Packages= git-core glibc-langpack-de glibc-langpack-en - gnutls gnutls-utils integritysetup iproute @@ -41,9 +40,7 @@ Packages= iputils iscsi-initiator-utils kernel-core - libasan libcap-ng-utils - libubsan man-db nmap-ncat openssh-clients @@ -57,8 +54,6 @@ Packages= python3-pexpect quota rpm - rpm-build - rpmautospec sbsigntools softhsm squashfs-tools diff --git a/mkosi.conf.d/10-centos-fedora/mkosi.prepare b/mkosi.conf.d/10-centos-fedora/mkosi.prepare index 1b86073ef54..2a890bcada8 100755 --- a/mkosi.conf.d/10-centos-fedora/mkosi.prepare +++ b/mkosi.conf.d/10-centos-fedora/mkosi.prepare @@ -2,64 +2,18 @@ # SPDX-License-Identifier: LGPL-2.1-or-later set -e -if [ "$1" = "build" ] || ((NO_BUILD)); then +if [[ "$1" == "build" ]]; then exit 0 fi -# shellcheck source=/dev/null -. "$BUILDROOT/usr/lib/os-release" +mapfile -t PACKAGES < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG") -if [ ! -f "pkg/$ID/systemd.spec" ]; then - echo "spec not found at pkg/$ID/systemd.spec, run mkosi with -ff to make sure the spec is cloned" >&2 - exit 1 -fi - -for DEPS in --requires --buildrequires; do - mkosi-chroot \ - rpmspec \ - --with upstream \ - --query \ - "$DEPS" \ - --define "_topdir /var/tmp" \ - --define "_sourcedir pkg/$ID" \ - "pkg/$ID/systemd.spec" | - grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev --regexp grubby --regexp sdubby | - sort --unique | - tee /tmp/buildrequires | - xargs --delimiter '\n' mkosi-install -done - -# rpmbuild -br tries to build a source package which means all source files have to exist which isn't the -# case when using --build-in-place so we get rid of the source file that doesn't exist to make it happy. -# TODO: Use -bd instead of -br and get rid of this once we don't need to build on CentOS Stream 9 anymore. -sed '/Source0/d' --in-place "pkg/$ID/systemd.spec" - -until mkosi-chroot \ - rpmbuild \ - -br \ - --build-in-place \ - --with upstream \ - --define "_topdir /var/tmp" \ - --define "_sourcedir pkg/$ID" \ - --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \ - "pkg/$ID/systemd.spec" -do - EXIT_STATUS=$? - if [ $EXIT_STATUS -ne 11 ]; then - exit $EXIT_STATUS - fi - - mkosi-chroot \ - rpm \ - --query \ - --package \ - --requires \ - /var/tmp/SRPMS/systemd-*.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 +for DEPS in --requires --recommends --suggests; do + # We need --latest-limit=1 to only consider the newest version of the packages. + # --latest-limit=1 is per . so we have to pass --arch= explicitly to make sure i686 packages + # are not considerd on x86-64. + dnf repoquery --arch="$DISTRIBUTION_ARCHITECTURE" --latest-limit=1 --quiet "$DEPS" "${PACKAGES[@]}" | + grep --invert-match --regexp systemd --regexp udev --regexp /bin/sh --regexp grubby --regexp sdubby --regexp libcurl-minimal | + sort --unique | + xargs --delimiter '\n' --no-run-if-empty mkosi-install done diff --git a/mkosi.conf.d/10-centos/mkosi.conf b/mkosi.conf.d/10-centos/mkosi.conf index 66aa0611d68..f9ea9a6596e 100644 --- a/mkosi.conf.d/10-centos/mkosi.conf +++ b/mkosi.conf.d/10-centos/mkosi.conf @@ -20,10 +20,5 @@ Environment= # mkfs.ext4 enabled it by default, so we disable it explicitly. SYSTEMD_REPART_MKFS_OPTIONS_EXT4="-O ^orphan_file" - GIT_URL=https://git.centos.org/rpms/systemd.git - GIT_BRANCH=c9s-sig-hyperscale - GIT_COMMIT=8cf2aed0181920611421384f7374720db269d6c7 - Packages= kernel-modules # For squashfs - rpmautospec-rpm-macros diff --git a/mkosi.conf.d/10-debian-ubuntu/mkosi.conf b/mkosi.conf.d/10-debian-ubuntu/mkosi.conf index 07bf95cee70..41f1972e1f5 100644 --- a/mkosi.conf.d/10-debian-ubuntu/mkosi.conf +++ b/mkosi.conf.d/10-debian-ubuntu/mkosi.conf @@ -8,12 +8,6 @@ Distribution=|ubuntu PackageManagerTrees=mkosi-pinning.pref:/etc/apt/preferences.d/mkosi-pinning.pref [Content] -Environment= - GIT_URL=https://salsa.debian.org/systemd-team/systemd.git - GIT_SUBDIR=debian - GIT_BRANCH=debian/master - GIT_COMMIT=abf24e775c67cf054f474526dd5d9d952a00228b - VolatilePackages= libnss-myhostname libnss-mymachines @@ -21,6 +15,8 @@ VolatilePackages= libnss-systemd libpam-systemd libsystemd-dev + libsystemd-shared + libsystemd0 libudev-dev systemd systemd-container @@ -40,17 +36,12 @@ VolatilePackages= udev Packages= - ^libasan[0-9]+$ - ^libtss2-esys-[0-9.]+-0$ - ^libtss2-mu-[0-9.]+-0$ - ^libubsan[0-9]+$ apt bind9-dnsutils cryptsetup-bin dbus-broker dbus-user-session dmsetup - dpkg-dev f2fs-tools fdisk git-core @@ -59,9 +50,6 @@ Packages= iputils-ping isc-dhcp-server libcap-ng-utils - libclang-rt-dev - libtss2-rc0 - libtss2-tcti-device0 locales man-db multipath-tools @@ -85,7 +73,6 @@ Packages= xxd InitrdPackages= - libclang-rt-dev tpm2-tools InitrdVolatilePackages= diff --git a/mkosi.conf.d/10-debian-ubuntu/mkosi.postinst b/mkosi.conf.d/10-debian-ubuntu/mkosi.postinst deleted file mode 100755 index 314f235f5fe..00000000000 --- a/mkosi.conf.d/10-debian-ubuntu/mkosi.postinst +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: LGPL-2.1-or-later -set -e - -# By default Suggests are not installed (and often Recommends are disabled too), which means we will miss -# the dlopen optional dependencies, but the tests need them, so parse them from the package metadata and -# install them. This is not an issue when building locally, as the build and runtime images are the same, -# so they would get installed as build dependencies anyway. - -if [ "$1" = "build" ] || ! ((NO_BUILD)); then - exit 0 -fi - -# Query the Recommends and Suggests of all systemd packages, by matching on the version -systemd_version="$(dpkg-query --showformat '${Version}' --show systemd)" -mapfile -t systemd_packages < <( dpkg --list | grep '^ii' | grep "$systemd_version" | awk '{print $2}' | tr '\n' ' ' ) -extra_packages=() -# shellcheck disable=SC2068 -for package in ${systemd_packages[@]}; do - # We are looking for dlopens, so filter for libraries - mapfile -t -O "${#extra_packages[@]}" extra_packages < <(dpkg-query --showformat '${Suggests}' --show "$package" | sed -e "s/, /\n/g" -e "s/|.*//" | grep "lib") - mapfile -t -O "${#extra_packages[@]}" extra_packages < <(dpkg-query --showformat '${Recommends}' --show "$package" | sed -e "s/, /\n/g" -e "s/|.*//" | grep "lib") -done - -if [ "${#extra_packages[@]}" -eq 0 ]; then - exit 0 -fi - -apt install "${extra_packages[@]}" diff --git a/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare b/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare index 645671a0313..acab113b8c1 100755 --- a/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare +++ b/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare @@ -2,17 +2,15 @@ # SPDX-License-Identifier: LGPL-2.1-or-later set -e -if [ "$1" = "build" ] || ((NO_BUILD)); then +if [[ "$1" == "build" ]]; then exit 0 fi -# shellcheck source=/dev/null -. "$BUILDROOT/usr/lib/os-release" +mapfile -t PACKAGES < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG") -if [ ! -d "pkg/$ID/debian" ]; then - echo "deb rules not found at pkg/$ID/debian, run mkosi once with -ff to make sure the rules are cloned" >&2 - exit 1 -fi - -cd "pkg/$ID" -DEB_BUILD_PROFILES="pkg.systemd.upstream" apt-get build-dep . +apt-cache depends "${PACKAGES[@]}" | + grep --invert-match --regexp "<" --regexp "|" --regexp systemd | # Remove e.g. and |dbus-broker like results + grep --extended-regexp "Depends|Suggests|Recommends" | + sed --quiet 's/.*: //p' | # Get every line with ": " in it and strip it at the same time. + sort --unique | + xargs --delimiter '\n' --no-run-if-empty mkosi-install diff --git a/mkosi.conf.d/10-fedora/mkosi.conf b/mkosi.conf.d/10-fedora/mkosi.conf index ff716e27df9..1b76d9ac941 100644 --- a/mkosi.conf.d/10-fedora/mkosi.conf +++ b/mkosi.conf.d/10-fedora/mkosi.conf @@ -7,11 +7,6 @@ Distribution=fedora Release=rawhide [Content] -Environment= - GIT_URL=https://src.fedoraproject.org/rpms/systemd.git - GIT_BRANCH=rawhide - GIT_COMMIT=a3524fc837f5e7b68f86b3e0a9d470a94a04c4c8 - Packages= compsize dnf5 diff --git a/mkosi.conf.d/10-opensuse/mkosi.conf b/mkosi.conf.d/10-opensuse/mkosi.conf index 06edcbae413..df01c3b6bed 100644 --- a/mkosi.conf.d/10-opensuse/mkosi.conf +++ b/mkosi.conf.d/10-opensuse/mkosi.conf @@ -12,12 +12,9 @@ Repositories=non-oss PackageManagerTrees=macros.db_backend:/etc/rpm/macros.db_backend [Content] -Environment= - GIT_URL=https://code.opensuse.org/package/systemd - GIT_BRANCH=master - GIT_COMMIT=6812406e52a474568744c267e7bade1496bb26a5 - VolatilePackages= + libsystemd0 + libudev1 systemd systemd-boot systemd-container @@ -43,23 +40,14 @@ Packages= docbook-xsl-stylesheets f2fs-tools gawk - gcc-c++ git-core glibc-locale-base gnutls grep - group(bin) - group(daemon) - group(games) - group(nobody) - group(root) gzip iputils kernel-default kmod - libasan8 - libkmod2 - libubsan1 multipath-tools ncat open-iscsi @@ -74,7 +62,6 @@ Packages= python3-pexpect python3-psutil quota - rpm-build rsync sbsigntools sed @@ -85,20 +72,13 @@ Packages= tgt timezone tpm2.0-tools - user(bin) - user(daemon) - user(games) - user(nobody) - user(root) veritysetup vim xz zypper InitrdPackages= - clang kmod - libkmod2 tpm2.0-tools InitrdVolatilePackages= diff --git a/mkosi.conf.d/10-opensuse/mkosi.prepare b/mkosi.conf.d/10-opensuse/mkosi.prepare index c57aa878b8b..6ee0af2de93 100755 --- a/mkosi.conf.d/10-opensuse/mkosi.prepare +++ b/mkosi.conf.d/10-opensuse/mkosi.prepare @@ -2,63 +2,22 @@ # SPDX-License-Identifier: LGPL-2.1-or-later set -e -if [ "$1" = "build" ] || ((NO_BUILD)); then +if [[ "$1" == "build" ]]; then exit 0 fi -# shellcheck source=/dev/null -. "$BUILDROOT/usr/lib/os-release" -ID="${ID%-*}" +DEPS="" -if [ ! -f "pkg/$ID/systemd.spec" ]; then - echo "spec not found at pkg/$ID/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2 - exit 1 -fi +while read -r PACKAGE; do + # zypper's output is not machine readable so we make do with sed instead. + DEPS="$DEPS\n$( + zypper info --requires --recommends --suggests "$PACKAGE" | + sed '/Requires/,$!d' | # Remove everything before Requires line + sed --quiet 's/^ //p' # All indented lines have dependencies + )" +done < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG") -# TODO: Drop when the spec is fixed (either the patch is adapted or not applied when building for upstream). -sed --in-place '/0009-pid1-handle-console-specificities-weirdness-for-s390.patch/d' "pkg/$ID/systemd.spec" - -for DEPS in --requires --buildrequires; do - mkosi-chroot \ - rpmspec \ - --with upstream \ - --query \ - "$DEPS" \ - --define "_topdir /var/tmp" \ - --define "_sourcedir pkg/$ID" \ - "pkg/$ID/systemd.spec" | - grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev | - sort --unique | - tee /tmp/buildrequires | - xargs --delimiter '\n' mkosi-install -done - -until mkosi-chroot \ - rpmbuild \ - -bd \ - --build-in-place \ - --with upstream \ - --define "_topdir /var/tmp" \ - --define "_sourcedir pkg/$ID" \ - --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \ - "pkg/$ID/systemd.spec" -do - EXIT_STATUS=$? - if [ $EXIT_STATUS -ne 11 ]; then - exit $EXIT_STATUS - fi - - mkosi-chroot \ - rpm \ - --query \ - --package \ - --requires \ - /var/tmp/SRPMS/systemd-*.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 +echo -e "$DEPS" | + grep --invert-match --regexp systemd --regexp udev --regexp qemu | + sort --unique | + xargs --delimiter '\n' --no-run-if-empty mkosi-install diff --git a/mkosi.conf.d/20-build.conf b/mkosi.conf.d/20-build.conf new file mode 100644 index 00000000000..8c16d9b9f87 --- /dev/null +++ b/mkosi.conf.d/20-build.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +# Add a dependency on the build image unless NO_BUILD=1. + +[Match] +Environment=!NO_BUILD=1 + +[Config] +Dependencies=build diff --git a/mkosi.conf.d/20-none.conf b/mkosi.conf.d/20-none.conf index 57a2f3f0e37..0e4d919a277 100644 --- a/mkosi.conf.d/20-none.conf +++ b/mkosi.conf.d/20-none.conf @@ -1,9 +1,11 @@ # SPDX-License-Identifier: LGPL-2.1-or-later -# If we're only rerunning the build script, remove all subimage dependencies to speed up builds. +# If we're only rerunning the build script, remove all subimage dependencies except the build image to speed +# up builds. [Match] Format=none [Config] Dependencies= +Dependencies=build diff --git a/mkosi.conf.d/20-sanitizers.conf b/mkosi.conf.d/20-sanitizers.conf index 235b233e1ad..62d052360ab 100644 --- a/mkosi.conf.d/20-sanitizers.conf +++ b/mkosi.conf.d/20-sanitizers.conf @@ -2,6 +2,7 @@ [Match] Environment=SANITIZERS +Environment=!SANITIZERS= [Content] # Set verify_asan_link_order=0 to prevent ASAN warnings when building the image and make sure the real ASAN @@ -17,3 +18,6 @@ KernelCommandLine= systemd.setenv=UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 LSAN_OPTIONS=suppressions=/usr/lib/systemd/leak-sanitizer-suppressions systemd.setenv=LSAN_OPTIONS=suppressions=/usr/lib/systemd/leak-sanitizer-suppressions + +[Config] +Include=%D/mkosi.sanitizers diff --git a/mkosi.images/build/mkosi.conf b/mkosi.images/build/mkosi.conf new file mode 100644 index 00000000000..037d25c5016 --- /dev/null +++ b/mkosi.images/build/mkosi.conf @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Content] +Packages= + clang + erofs-utils + lld + llvm + +[Output] +Format=none diff --git a/mkosi.conf.d/10-arch/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot similarity index 95% rename from mkosi.conf.d/10-arch/mkosi.build.chroot rename to mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot index 268bdc2ee74..7798e78dda4 100755 --- a/mkosi.conf.d/10-arch/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot @@ -2,14 +2,10 @@ # SPDX-License-Identifier: LGPL-2.1-or-later set -e -if ((NO_BUILD)); then - exit 0 -fi - # shellcheck source=/dev/null . /usr/lib/os-release -if [ ! -f "pkg/$ID/PKGBUILD" ]; then +if [[ ! -f "pkg/$ID/PKGBUILD" ]]; then echo "PKGBUILD not found at pkg/$ID/PKGBUILD, run mkosi once with -ff to make sure the PKGBUILD is cloned" >&2 exit 1 fi @@ -65,7 +61,7 @@ EOF # Linting the PKGBUILD takes multiple seconds every build so avoid that by nuking all the linting functions. rm /usr/share/makepkg/lint_pkgbuild/* -if [ -d .git/ ] && [ -z "$(git status --porcelain)" ]; then +if [[ -d .git/ ]] && [[ -z "$(git status --porcelain)" ]]; then TS="$(git show --no-patch --format=%ct HEAD)" else TS="${SOURCE_DATE_EPOCH:-$(date +%s)}" diff --git a/mkosi.images/build/mkosi.conf.d/arch/mkosi.conf b/mkosi.images/build/mkosi.conf.d/arch/mkosi.conf new file mode 100644 index 00000000000..d5148eacb66 --- /dev/null +++ b/mkosi.images/build/mkosi.conf.d/arch/mkosi.conf @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=arch + +[Content] +Environment= + GIT_URL=https://gitlab.archlinux.org/archlinux/packaging/packages/systemd.git + GIT_BRANCH=main + GIT_COMMIT=d74b24c7c6077740c35a876445febe6d26bf013c + +Packages= + base + base-devel + diffutils + git diff --git a/mkosi.images/build/mkosi.conf.d/arch/mkosi.prepare b/mkosi.images/build/mkosi.conf.d/arch/mkosi.prepare new file mode 100755 index 00000000000..e880449b72b --- /dev/null +++ b/mkosi.images/build/mkosi.conf.d/arch/mkosi.prepare @@ -0,0 +1,21 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -e + +if [[ "$1" == "build" ]]; then + exit 0 +fi + +# shellcheck source=/dev/null +. "$BUILDROOT/usr/lib/os-release" + +if [[ ! -f "pkg/$ID/PKGBUILD" ]]; then + echo "PKGBUILD not found at pkg/$ID/PKGBUILD, run mkosi once with -ff to make sure the PKGBUILD is cloned" >&2 + exit 1 +fi + +# shellcheck source=/dev/null +_systemd_UPSTREAM=1 . "pkg/$ID/PKGBUILD" + +# shellcheck disable=SC2154 +mkosi-install "${makedepends[@]}" diff --git a/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot similarity index 95% rename from mkosi.conf.d/10-centos-fedora/mkosi.build.chroot rename to mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot index dcb90c31ccd..3daa699b3e8 100755 --- a/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot @@ -4,25 +4,21 @@ set -e . mkosi.functions -if ((NO_BUILD)); then - exit 0 -fi - # shellcheck source=/dev/null . /usr/lib/os-release -if [ ! -f "pkg/$ID/systemd.spec" ]; then +if [[ ! -f "pkg/$ID/systemd.spec" ]]; then echo "spec not found at pkg/$ID/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2 exit 1 fi -if [ -d .git/ ] && [ -z "$(git status --porcelain)" ]; then +if [[ -d .git/ ]] && [[ -z "$(git status --porcelain)" ]]; then TS="$(git show --no-patch --format=%ct HEAD)" else TS="${SOURCE_DATE_EPOCH:-$(date +%s)}" fi -if systemd-analyze compare-versions "$(rpm --version | cut -d ' ' -f3)" lt "4.19.91"; then +if [[ "$(rpm --eval "%{lua:print(rpm.vercmp('$(rpm --version | cut -d ' ' -f3)', '4.19.91'))}")" == "-1" ]]; then # Fix the %install override so debuginfo packages are generated even when --build-in-place is used. # See https://github.com/rpm-software-management/rpm/issues/3042. tee --append /usr/lib/rpm/redhat/macros <<'EOF' diff --git a/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.conf b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.conf new file mode 100644 index 00000000000..06ea2acc8df --- /dev/null +++ b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.conf @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=|centos +Distribution=|fedora + +[Content] +Packages= + compiler-rt + git-core + libasan + libubsan + rpm-build + rpmautospec diff --git a/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.prepare b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.prepare new file mode 100755 index 00000000000..fe3c14eede6 --- /dev/null +++ b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.prepare @@ -0,0 +1,63 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -e + +if [[ "$1" == "build" ]]; then + exit 0 +fi + +# shellcheck source=/dev/null +. "$BUILDROOT/usr/lib/os-release" + +if [[ ! -f "pkg/$ID/systemd.spec" ]]; then + echo "spec not found at pkg/$ID/systemd.spec, run mkosi with -ff to make sure the spec is cloned" >&2 + exit 1 +fi + +mkosi-chroot \ + rpmspec \ + --with upstream \ + --query \ + --buildrequires \ + --define "_topdir /var/tmp" \ + --define "_sourcedir pkg/$ID" \ + "pkg/$ID/systemd.spec" | + grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev --regexp grubby --regexp sdubby | + sort --unique | + tee /tmp/buildrequires | + xargs --delimiter '\n' mkosi-install + +# rpmbuild -br tries to build a source package which means all source files have to exist which isn't the +# case when using --build-in-place so we get rid of the source file that doesn't exist to make it happy. +# TODO: Use -bd instead of -br and get rid of this once we don't need to build on CentOS Stream 9 anymore. +sed '/Source0/d' --in-place "pkg/$ID/systemd.spec" + +until mkosi-chroot \ + rpmbuild \ + -br \ + --build-in-place \ + --with upstream \ + --define "_topdir /var/tmp" \ + --define "_sourcedir pkg/$ID" \ + --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \ + "pkg/$ID/systemd.spec" +do + EXIT_STATUS=$? + if [[ $EXIT_STATUS -ne 11 ]]; then + exit $EXIT_STATUS + fi + + mkosi-chroot \ + rpm \ + --query \ + --package \ + --requires \ + /var/tmp/SRPMS/systemd-*.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 diff --git a/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf b/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf new file mode 100644 index 00000000000..99316bec5f6 --- /dev/null +++ b/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=centos + +[Content] +Packages= + rsync # TODO: Drop when CentOS Stream 9 CI is removed. + rpmautospec-rpm-macros + +Environment= + GIT_URL=https://git.centos.org/rpms/systemd.git + GIT_BRANCH=c9s-sig-hyperscale + GIT_COMMIT=46480aaa9e0ea63a85b6ca676554ce2aae10ce36 diff --git a/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.build.chroot similarity index 96% rename from mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot rename to mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.build.chroot index 1a03dcd9564..6620bda1755 100755 --- a/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.build.chroot @@ -2,14 +2,10 @@ # SPDX-License-Identifier: LGPL-2.1-or-later set -e -if ((NO_BUILD)); then - exit 0 -fi - # shellcheck source=/dev/null . /usr/lib/os-release -if [ ! -d "pkg/$ID/debian" ]; then +if [[ ! -d "pkg/$ID/debian" ]]; then echo "deb rules not found at pkg/$ID/debian, run mkosi once with -ff to make sure the rules are cloned" >&2 exit 1 fi @@ -25,7 +21,7 @@ rm -rf "$SRCDIR"/debian/patches/* DEB_HOST_GNU_TYPE="$(dpkg-architecture --query DEB_HOST_GNU_TYPE)" mount --mkdir --bind "$BUILDDIR" "$SRCDIR/obj-$DEB_HOST_GNU_TYPE" -if [ -d .git/ ] && [ -z "$(git status --porcelain)" ]; then +if [[ -d .git/ ]] && [[ -z "$(git status --porcelain)" ]]; then TS="$(git show --no-patch --format=%ct HEAD)" else TS="${SOURCE_DATE_EPOCH:-$(date +%s)}" @@ -116,7 +112,7 @@ if ! build; then # by meson install. (cd debian/tmp/ && find . ! -type d ! -path "*dh-exec*" -printf '%P\n') >/tmp/installed-files - if [ -f debian/not-installed ]; then + if [[ -f debian/not-installed ]]; then grep --invert-match "^#" debian/not-installed >>/tmp/installed-files fi @@ -126,7 +122,7 @@ if ! build; then # not in the packaged file. comm -23 /tmp/installed-files /tmp/packaged-files > /tmp/unpackaged-files # If there are no unpackaged files something else went wrong. - if [ ! -s /tmp/unpackaged-files ]; then + if [[ ! -s /tmp/unpackaged-files ]]; then exit 1 fi diff --git a/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.conf b/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.conf new file mode 100644 index 00000000000..a7464aafe3e --- /dev/null +++ b/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.conf @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=|debian +Distribution=|ubuntu + +[Content] +Environment= + GIT_URL=https://salsa.debian.org/systemd-team/systemd.git + GIT_SUBDIR=debian + GIT_BRANCH=debian/master + GIT_COMMIT=abf24e775c67cf054f474526dd5d9d952a00228b + +Packages= + apt + git-core + libclang-rt-dev + dpkg-dev diff --git a/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.prepare b/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.prepare new file mode 100755 index 00000000000..d9021fd65b2 --- /dev/null +++ b/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.prepare @@ -0,0 +1,18 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -e + +if [[ "$1" == "build" ]]; then + exit 0 +fi + +# shellcheck source=/dev/null +. "$BUILDROOT/usr/lib/os-release" + +if [[ ! -d "pkg/$ID/debian" ]]; then + echo "deb rules not found at pkg/$ID/debian, run mkosi once with -ff to make sure the rules are cloned" >&2 + exit 1 +fi + +cd "pkg/$ID" +DEB_BUILD_PROFILES="pkg.systemd.upstream" apt-get build-dep . diff --git a/mkosi.images/build/mkosi.conf.d/fedora/mkosi.conf b/mkosi.images/build/mkosi.conf.d/fedora/mkosi.conf new file mode 100644 index 00000000000..1f001452eb3 --- /dev/null +++ b/mkosi.images/build/mkosi.conf.d/fedora/mkosi.conf @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=fedora + +[Content] +Environment= + GIT_URL=https://src.fedoraproject.org/rpms/systemd.git + GIT_BRANCH=rawhide + GIT_COMMIT=a3524fc837f5e7b68f86b3e0a9d470a94a04c4c8 diff --git a/mkosi.conf.d/10-opensuse/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot similarity index 94% rename from mkosi.conf.d/10-opensuse/mkosi.build.chroot rename to mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot index 0c598eae563..266695ccc78 100755 --- a/mkosi.conf.d/10-opensuse/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot @@ -4,20 +4,16 @@ set -e . mkosi.functions -if ((NO_BUILD)); then - exit 0 -fi - # shellcheck source=/dev/null . /usr/lib/os-release ID="${ID%-*}" -if [ ! -f "pkg/$ID/systemd.spec" ]; then +if [[ ! -f "pkg/$ID/systemd.spec" ]]; then echo "spec not found at pkg/$ID/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2 exit 1 fi -if [ -d .git/ ] && [ -z "$(git status --porcelain)" ]; then +if [[ -d .git/ ]] && [[ -z "$(git status --porcelain)" ]]; then TS="$(git show --no-patch --format=%ct HEAD)" else TS="${SOURCE_DATE_EPOCH:-$(date +%s)}" @@ -28,7 +24,7 @@ fi # extension. find "pkg/$ID" -name "files.*" -exec sed --in-place 's/\.gz$//' {} \; -if systemd-analyze compare-versions "$(rpm --version | cut -d ' ' -f3)" lt "4.20"; then +if [[ "$(rpm --eval "%{lua:print(rpm.vercmp('$(rpm --version | cut -d ' ' -f3)', '4.20'))}")" == "-1" ]]; then # Fix the %install override so debuginfo packages are generated. tee --append /usr/lib/rpm/suse/macros <<'EOF' %install %{debug_package}\ @@ -122,7 +118,7 @@ build() { } if ! build; then - if [ ! -s /tmp/unpackaged-files ]; then + if [[ ! -s /tmp/unpackaged-files ]]; then exit 1 fi diff --git a/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.conf b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.conf new file mode 100644 index 00000000000..ad6388faf7b --- /dev/null +++ b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.conf @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=opensuse + +[Content] +Environment= + GIT_URL=https://code.opensuse.org/package/systemd + GIT_BRANCH=master + GIT_COMMIT=6812406e52a474568744c267e7bade1496bb26a5 + +Packages= + gcc-c++ + git-core + patterns-base-minimal_base + rpm-build diff --git a/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.prepare b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.prepare new file mode 100755 index 00000000000..3c398593b59 --- /dev/null +++ b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.prepare @@ -0,0 +1,62 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -e + +if [[ "$1" == "build" ]]; then + exit 0 +fi + +# shellcheck source=/dev/null +. "$BUILDROOT/usr/lib/os-release" +ID="${ID%-*}" + +if [[ ! -f "pkg/$ID/systemd.spec" ]]; then + echo "spec not found at pkg/$ID/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2 + exit 1 +fi + +# TODO: Drop when the spec is fixed (either the patch is adapted or not applied when building for upstream). +sed --in-place '/0009-pid1-handle-console-specificities-weirdness-for-s390.patch/d' "pkg/$ID/systemd.spec" + +mkosi-chroot \ + rpmspec \ + --with upstream \ + --query \ + --buildrequires \ + --define "_topdir /var/tmp" \ + --define "_sourcedir pkg/$ID" \ + "pkg/$ID/systemd.spec" | + grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev | + sort --unique | + tee /tmp/buildrequires | + xargs --delimiter '\n' mkosi-install + +until mkosi-chroot \ + rpmbuild \ + -bd \ + --build-in-place \ + --with upstream \ + --define "_topdir /var/tmp" \ + --define "_sourcedir pkg/$ID" \ + --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \ + "pkg/$ID/systemd.spec" +do + EXIT_STATUS=$? + if [[ $EXIT_STATUS -ne 11 ]]; then + exit $EXIT_STATUS + fi + + mkosi-chroot \ + rpm \ + --query \ + --package \ + --requires \ + /var/tmp/SRPMS/systemd-*.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 diff --git a/mkosi.sync b/mkosi.images/build/mkosi.sync similarity index 88% rename from mkosi.sync rename to mkosi.images/build/mkosi.sync index d56ddf57906..198e1bc1475 100755 --- a/mkosi.sync +++ b/mkosi.images/build/mkosi.sync @@ -14,6 +14,11 @@ if [[ -d "$PKG_SUBDIR/.git" ]]; then exit 0 fi + if ! git -C "$PKG_SUBDIR" show-ref --quiet "origin/$GIT_BRANCH"; then + git -C "$PKG_SUBDIR" remote set-url origin "$GIT_URL" + git -C "$PKG_SUBDIR" fetch origin "$GIT_BRANCH" + fi + # If work is being done on the packaging rules in a separate branch, don't touch the checkout. if ! git -C "$PKG_SUBDIR" merge-base --is-ancestor HEAD "origin/$GIT_BRANCH"; then EXIT_STATUS=$? diff --git a/mkosi.images/exitrd/mkosi.conf b/mkosi.images/exitrd/mkosi.conf index 3b25091759c..28da8a592b8 100644 --- a/mkosi.images/exitrd/mkosi.conf +++ b/mkosi.images/exitrd/mkosi.conf @@ -12,3 +12,6 @@ MakeInitrd=yes Packages= bash + +[Config] +Include=%D/mkosi.sanitizers diff --git a/mkosi.images/exitrd/mkosi.conf.d/10-arch.conf b/mkosi.images/exitrd/mkosi.conf.d/10-arch.conf index c8b1904f6f4..a5a6506e942 100644 --- a/mkosi.images/exitrd/mkosi.conf.d/10-arch.conf +++ b/mkosi.images/exitrd/mkosi.conf.d/10-arch.conf @@ -4,7 +4,7 @@ Distribution=arch [Content] -Packages= +VolatilePackages= systemd RemoveFiles= diff --git a/mkosi.images/exitrd/mkosi.conf.d/10-centos-fedora.conf b/mkosi.images/exitrd/mkosi.conf.d/10-centos-fedora.conf index 8458dee37ef..a1fa32b7860 100644 --- a/mkosi.images/exitrd/mkosi.conf.d/10-centos-fedora.conf +++ b/mkosi.images/exitrd/mkosi.conf.d/10-centos-fedora.conf @@ -5,5 +5,5 @@ Distribution=|centos Distribution=|fedora [Content] -Packages= +VolatilePackages= systemd-standalone-shutdown diff --git a/mkosi.images/exitrd/mkosi.conf.d/10-debian.conf b/mkosi.images/exitrd/mkosi.conf.d/10-debian.conf index 68b0aa5fe7f..6ca310cbc26 100644 --- a/mkosi.images/exitrd/mkosi.conf.d/10-debian.conf +++ b/mkosi.images/exitrd/mkosi.conf.d/10-debian.conf @@ -4,5 +4,5 @@ Distribution=debian [Content] -Packages= +VolatilePackages= systemd-standalone-shutdown diff --git a/mkosi.images/exitrd/mkosi.conf.d/10-opensuse.conf b/mkosi.images/exitrd/mkosi.conf.d/10-opensuse.conf index 3f6df21f841..fb0a498df5f 100644 --- a/mkosi.images/exitrd/mkosi.conf.d/10-opensuse.conf +++ b/mkosi.images/exitrd/mkosi.conf.d/10-opensuse.conf @@ -5,4 +5,7 @@ Distribution=opensuse [Content] Packages= + patterns-base-minimal_base + +VolatilePackages= systemd diff --git a/mkosi.images/exitrd/mkosi.conf.d/10-ubuntu.conf b/mkosi.images/exitrd/mkosi.conf.d/10-ubuntu.conf index ddd68dc1b4b..61fe6baee03 100644 --- a/mkosi.images/exitrd/mkosi.conf.d/10-ubuntu.conf +++ b/mkosi.images/exitrd/mkosi.conf.d/10-ubuntu.conf @@ -4,5 +4,5 @@ Distribution=ubuntu [Content] -Packages= +VolatilePackages= systemd diff --git a/mkosi.images/exitrd/mkosi.conf.d/20-build.conf b/mkosi.images/exitrd/mkosi.conf.d/20-build.conf new file mode 100644 index 00000000000..8c16d9b9f87 --- /dev/null +++ b/mkosi.images/exitrd/mkosi.conf.d/20-build.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +# Add a dependency on the build image unless NO_BUILD=1. + +[Match] +Environment=!NO_BUILD=1 + +[Config] +Dependencies=build diff --git a/mkosi.images/minimal-base/mkosi.conf b/mkosi.images/minimal-base/mkosi.conf index f6deeeadfb8..d841f9b76b5 100644 --- a/mkosi.images/minimal-base/mkosi.conf +++ b/mkosi.images/minimal-base/mkosi.conf @@ -14,3 +14,6 @@ Packages= coreutils grep util-linux + +[Config] +Include=%D/mkosi.sanitizers diff --git a/mkosi.images/minimal-base/mkosi.conf.d/10-arch.conf b/mkosi.images/minimal-base/mkosi.conf.d/10-arch.conf index 4978ca5cf7b..044199a6c13 100644 --- a/mkosi.images/minimal-base/mkosi.conf.d/10-arch.conf +++ b/mkosi.images/minimal-base/mkosi.conf.d/10-arch.conf @@ -9,6 +9,9 @@ Packages= iproute nmap +VolatilePackages= + systemd-libs + RemoveFiles= # 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 image. diff --git a/mkosi.images/minimal-base/mkosi.conf.d/10-centos-fedora.conf b/mkosi.images/minimal-base/mkosi.conf.d/10-centos-fedora.conf index c0a43cba19d..e9893ad9897 100644 --- a/mkosi.images/minimal-base/mkosi.conf.d/10-centos-fedora.conf +++ b/mkosi.images/minimal-base/mkosi.conf.d/10-centos-fedora.conf @@ -10,3 +10,6 @@ Packages= iproute iproute-tc nmap-ncat + +VolatilePackages= + systemd-libs diff --git a/mkosi.images/minimal-base/mkosi.conf.d/10-debian-ubuntu-opensuse.conf b/mkosi.images/minimal-base/mkosi.conf.d/10-debian-ubuntu.conf similarity index 76% rename from mkosi.images/minimal-base/mkosi.conf.d/10-debian-ubuntu-opensuse.conf rename to mkosi.images/minimal-base/mkosi.conf.d/10-debian-ubuntu.conf index b293926b08d..d524ec17fee 100644 --- a/mkosi.images/minimal-base/mkosi.conf.d/10-debian-ubuntu-opensuse.conf +++ b/mkosi.images/minimal-base/mkosi.conf.d/10-debian-ubuntu.conf @@ -10,3 +10,7 @@ Packages= iproute2 mount ncat + +VolatilePackages= + libsystemd0 + libudev1 diff --git a/mkosi.images/minimal-base/mkosi.conf.d/10-opensuse.conf b/mkosi.images/minimal-base/mkosi.conf.d/10-opensuse.conf index c164d328745..9bd40cff379 100644 --- a/mkosi.images/minimal-base/mkosi.conf.d/10-opensuse.conf +++ b/mkosi.images/minimal-base/mkosi.conf.d/10-opensuse.conf @@ -9,3 +9,7 @@ Packages= iproute2 ncat patterns-base-minimal_base + +VolatilePackages= + libsystemd0 + libudev1 diff --git a/mkosi.images/minimal-base/mkosi.conf.d/20-build.conf b/mkosi.images/minimal-base/mkosi.conf.d/20-build.conf new file mode 100644 index 00000000000..8c16d9b9f87 --- /dev/null +++ b/mkosi.images/minimal-base/mkosi.conf.d/20-build.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +# Add a dependency on the build image unless NO_BUILD=1. + +[Match] +Environment=!NO_BUILD=1 + +[Config] +Dependencies=build diff --git a/mkosi.initrd/mkosi.conf b/mkosi.initrd/mkosi.conf index 8f8cc2fbe6f..baf08726c0a 100644 --- a/mkosi.initrd/mkosi.conf +++ b/mkosi.initrd/mkosi.conf @@ -1,7 +1,9 @@ # SPDX-License-Identifier: LGPL-2.1-or-later [Content] -PostInstallationScripts=../mkosi.sanitizers.chroot ExtraTrees= ../mkosi.leak-sanitizer-suppressions:/usr/lib/systemd/leak-sanitizer-suppressions ../mkosi.coredump-journal-storage.conf:/usr/lib/systemd/coredump.conf.d/10-coredump-journal-storage.conf + +[Config] +Include=../mkosi.sanitizers diff --git a/mkosi.sanitizers/mkosi.conf b/mkosi.sanitizers/mkosi.conf new file mode 100644 index 00000000000..844541ce8b4 --- /dev/null +++ b/mkosi.sanitizers/mkosi.conf @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Environment=SANITIZERS +Environment=!SANITIZERS= diff --git a/mkosi.sanitizers/mkosi.conf.d/arch.conf b/mkosi.sanitizers/mkosi.conf.d/arch.conf new file mode 100644 index 00000000000..195556aa9b9 --- /dev/null +++ b/mkosi.sanitizers/mkosi.conf.d/arch.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=arch +Environment=LLVM=1 + +[Content] +Packages= + compiler-rt diff --git a/mkosi.sanitizers/mkosi.conf.d/debian-ubuntu.conf b/mkosi.sanitizers/mkosi.conf.d/debian-ubuntu.conf new file mode 100644 index 00000000000..cfeef85758a --- /dev/null +++ b/mkosi.sanitizers/mkosi.conf.d/debian-ubuntu.conf @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# TODO: Drop when https://bugzilla.suse.com/show_bug.cgi?id=1225784 is fixed. + +[Match] +Distribution=|debian +Distribution=|ubuntu +Environment=LLVM=1 + +[Content] +Packages= + libclang-rt-dev diff --git a/mkosi.sanitizers/mkosi.conf.d/opensuse.conf b/mkosi.sanitizers/mkosi.conf.d/opensuse.conf new file mode 100644 index 00000000000..28357df498b --- /dev/null +++ b/mkosi.sanitizers/mkosi.conf.d/opensuse.conf @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# TODO: Drop when https://bugzilla.suse.com/show_bug.cgi?id=1225784 is fixed. + +[Match] +Distribution=opensuse +Environment=LLVM=1 + +[Content] +Packages= + clang diff --git a/mkosi.sanitizers.chroot b/mkosi.sanitizers/mkosi.postinst similarity index 66% rename from mkosi.sanitizers.chroot rename to mkosi.sanitizers/mkosi.postinst index 524e3dadb19..e0ad422f5d6 100755 --- a/mkosi.sanitizers.chroot +++ b/mkosi.sanitizers/mkosi.postinst @@ -3,31 +3,35 @@ set -e set -o nounset -if [[ -z "${SANITIZERS:-}" ]]; then +LIBSYSTEMD="$(mkosi-chroot ldconfig -p | grep libsystemd.so.0 | sed 's/[^/]*\//\//')" + +if [[ ! -f "$BUILDROOT/$LIBSYSTEMD" ]]; then exit 0 fi # Sanitizers log to stderr by default. However, journald's stderr is connected to /dev/null, so we lose # all the sanitizer logs. To rectify that, let's connect journald's stdout to kmsg so that the sanitizer # failures end up in the journal. -mkdir -p /etc/systemd/system/systemd-journald.service.d -cat >/etc/systemd/system/systemd-journald.service.d/10-stdout-tty.conf <"$BUILDROOT"/etc/systemd/system/systemd-journald.service.d/10-stdout-tty.conf < 50s when built with sanitizers so let's not run it by default. -systemctl mask systemd-hwdb-update.service +systemctl --root="$BUILDROOT" mask systemd-hwdb-update.service -ASAN_RT_PATH="$(grep libasan.so < <(ldd /usr/lib/systemd/systemd) | cut -d ' ' -f 3)" +ASAN_RT_PATH="$(grep libasan.so < <(mkosi-chroot ldd "$LIBSYSTEMD") | cut -d ' ' -f 3)" if [[ -z "$ASAN_RT_PATH" ]]; then - ASAN_RT_PATH="$(grep libclang_rt.asan < <(ldd /usr/lib/systemd/systemd) | cut -d ' ' -f 3)" + ASAN_RT_PATH="$(grep libclang_rt.asan < <(mkosi-chroot ldd "$LIBSYSTEMD") | cut -d ' ' -f 3)" # As clang's ASan DSO is usually in a non-standard path, let's check if the RUNPATH is set accordingly. - if ldd /usr/lib/systemd/systemd | grep -q "libclang_rt.asan.*not found"; then + if mkosi-chroot ldd "$LIBSYSTEMD" | grep -q "libclang_rt.asan.*not found"; then echo >&2 "clang's ASan DSO libclang_rt.asan is not present in the runtime library path" exit 1 fi @@ -94,7 +98,7 @@ wrap=( ) for bin in "${wrap[@]}"; do - if ! command -v "$bin" >/dev/null; then + if ! mkosi-chroot command -v "$bin" >/dev/null; then continue fi @@ -104,11 +108,11 @@ for bin in "${wrap[@]}"; do enable_lsan=0 fi - target="$(command -v "$bin")" + target="$(mkosi-chroot command -v "$bin")" - mv "$target" "$target.orig" + mv "$BUILDROOT/$target" "$BUILDROOT/$target.orig" - cat >"$target" <"$BUILDROOT/$target" </usr/lib/systemd/systemd-asan-env <"$BUILDROOT"/usr/lib/systemd/systemd-asan-env < Date: Fri, 5 Jul 2024 11:56:44 +0200 Subject: [PATCH 04/15] mkosi: Make epel repositories optional for CentOS Stream 9 This allows us to add CI for CentOS Stream 10 as EPEL 10 doesn't exist yet and won't exist for quite some time. CentOS Stream 10 will be enabled later as soon as https://issues.redhat.com/browse/RHEL-46604 is resolved. --- mkosi.conf | 6 +----- mkosi.conf.d/10-arch/mkosi.conf | 5 +++++ mkosi.conf.d/10-centos-fedora/mkosi.conf | 3 --- mkosi.conf.d/10-centos/mkosi.conf | 4 ---- mkosi.conf.d/10-centos/mkosi.conf.d/10-epel.conf | 9 +++++++++ .../10-centos/mkosi.conf.d/20-epel-packages.conf | 13 +++++++++++++ mkosi.conf.d/10-debian-ubuntu/mkosi.conf | 5 +++++ mkosi.conf.d/10-fedora/mkosi.conf | 13 ++++++++++++- mkosi.conf.d/10-opensuse/mkosi.conf | 5 +++++ mkosi.images/build/mkosi.conf | 1 - mkosi.images/build/mkosi.conf.d/arch/mkosi.conf | 1 + .../build/mkosi.conf.d/centos-fedora/mkosi.conf | 1 - mkosi.images/build/mkosi.conf.d/centos/mkosi.conf | 2 +- .../centos/mkosi.conf.d/epel-packages.conf | 9 +++++++++ .../build/mkosi.conf.d/debian-ubuntu/mkosi.conf | 1 + mkosi.images/build/mkosi.conf.d/fedora/mkosi.conf | 4 ++++ mkosi.images/build/mkosi.conf.d/opensuse/mkosi.conf | 1 + 17 files changed, 67 insertions(+), 16 deletions(-) create mode 100644 mkosi.conf.d/10-centos/mkosi.conf.d/10-epel.conf create mode 100644 mkosi.conf.d/10-centos/mkosi.conf.d/20-epel-packages.conf create mode 100644 mkosi.images/build/mkosi.conf.d/centos/mkosi.conf.d/epel-packages.conf diff --git a/mkosi.conf b/mkosi.conf index 5654af0956c..dfcd9fe0404 100644 --- a/mkosi.conf +++ b/mkosi.conf @@ -78,12 +78,12 @@ KernelCommandLine=systemd.crash_shell # These don't ship proper units with [Install] directives so we have to mask them instead. systemd.mask=isc-dhcp-server.service systemd.mask=mdmonitor.service + psi=1 KernelModulesInitrdExclude=.* KernelModulesInitrdInclude=default InitrdPackages= - btrfs-progs findutils grep sed @@ -93,14 +93,12 @@ Packages= attr bash-completion bpftrace - btrfs-progs coreutils curl diffutils dnsmasq dosfstools e2fsprogs - erofs-utils findutils gdb grep @@ -109,7 +107,6 @@ Packages= kbd kexec-tools kmod - knot less lvm2 man @@ -123,7 +120,6 @@ Packages= p11-kit pciutils python3 - qrencode radvd rsync sed diff --git a/mkosi.conf.d/10-arch/mkosi.conf b/mkosi.conf.d/10-arch/mkosi.conf index e7288cc19df..7b719ff7b09 100644 --- a/mkosi.conf.d/10-arch/mkosi.conf +++ b/mkosi.conf.d/10-arch/mkosi.conf @@ -15,16 +15,19 @@ VolatilePackages= Packages= bind bpf + btrfs-progs compsize cryptsetup dbus-broker dbus-broker-units dhcp + erofs-utils f2fs-tools git gnutls iproute iputils + knot linux man-db multipath-tools @@ -39,6 +42,7 @@ Packages= psmisc python-pexpect python-psutil + qrencode quota-tools sbsigntools shadow @@ -50,6 +54,7 @@ Packages= vim InitrdPackages= + btrfs-progs tpm2-tools InitrdVolatilePackages= diff --git a/mkosi.conf.d/10-centos-fedora/mkosi.conf b/mkosi.conf.d/10-centos-fedora/mkosi.conf index d046eb218b5..8882c89b1b9 100644 --- a/mkosi.conf.d/10-centos-fedora/mkosi.conf +++ b/mkosi.conf.d/10-centos-fedora/mkosi.conf @@ -27,8 +27,6 @@ Packages= cryptsetup device-mapper-event device-mapper-multipath - dfuzzer - dhcp-server dnf git-core glibc-langpack-de @@ -54,7 +52,6 @@ Packages= python3-pexpect quota rpm - sbsigntools softhsm squashfs-tools stress-ng diff --git a/mkosi.conf.d/10-centos/mkosi.conf b/mkosi.conf.d/10-centos/mkosi.conf index f9ea9a6596e..88b863c5a03 100644 --- a/mkosi.conf.d/10-centos/mkosi.conf +++ b/mkosi.conf.d/10-centos/mkosi.conf @@ -5,10 +5,6 @@ Distribution=centos [Distribution] Release=9 -Repositories=epel - epel-next - hyperscale-packages-main - hyperscale-packages-experimental [Content] Environment= diff --git a/mkosi.conf.d/10-centos/mkosi.conf.d/10-epel.conf b/mkosi.conf.d/10-centos/mkosi.conf.d/10-epel.conf new file mode 100644 index 00000000000..9e92a4f2261 --- /dev/null +++ b/mkosi.conf.d/10-centos/mkosi.conf.d/10-epel.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Release=9 + +[Distribution] +Repositories= + epel + epel-next diff --git a/mkosi.conf.d/10-centos/mkosi.conf.d/20-epel-packages.conf b/mkosi.conf.d/10-centos/mkosi.conf.d/20-epel-packages.conf new file mode 100644 index 00000000000..11dc96918af --- /dev/null +++ b/mkosi.conf.d/10-centos/mkosi.conf.d/20-epel-packages.conf @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Repositories=epel + +[Content] +Packages= + dfuzzer + dhcp-server + erofs-utils + knot + qrencode + sbsigntools diff --git a/mkosi.conf.d/10-debian-ubuntu/mkosi.conf b/mkosi.conf.d/10-debian-ubuntu/mkosi.conf index 41f1972e1f5..d282b47fb66 100644 --- a/mkosi.conf.d/10-debian-ubuntu/mkosi.conf +++ b/mkosi.conf.d/10-debian-ubuntu/mkosi.conf @@ -36,12 +36,14 @@ VolatilePackages= udev Packages= + btrfs-progs apt bind9-dnsutils cryptsetup-bin dbus-broker dbus-user-session dmsetup + erofs-utils f2fs-tools fdisk git-core @@ -49,6 +51,7 @@ Packages= iproute2 iputils-ping isc-dhcp-server + knot libcap-ng-utils locales man-db @@ -63,6 +66,7 @@ Packages= psmisc python3-pexpect python3-psutil + qrencode quota softhsm2 squashfs-tools @@ -73,6 +77,7 @@ Packages= xxd InitrdPackages= + btrfs-progs tpm2-tools InitrdVolatilePackages= diff --git a/mkosi.conf.d/10-fedora/mkosi.conf b/mkosi.conf.d/10-fedora/mkosi.conf index 1b76d9ac941..92f0c7e9b0f 100644 --- a/mkosi.conf.d/10-fedora/mkosi.conf +++ b/mkosi.conf.d/10-fedora/mkosi.conf @@ -8,10 +8,21 @@ Release=rawhide [Content] Packages= + btrfs-progs compsize + dfuzzer + dhcp-server dnf5 + erofs-utils f2fs-tools - scsi-target-utils # Required for systemd-networkd-tests.py (netdevsim and sch_xxx modules) kernel-modules-extra kernel-modules-internal + knot + qrencode + rpmautospec + sbsigntools + scsi-target-utils + +InitrdPackages= + btrfs-progs diff --git a/mkosi.conf.d/10-opensuse/mkosi.conf b/mkosi.conf.d/10-opensuse/mkosi.conf index df01c3b6bed..2a6bd6e7bf7 100644 --- a/mkosi.conf.d/10-opensuse/mkosi.conf +++ b/mkosi.conf.d/10-opensuse/mkosi.conf @@ -34,10 +34,12 @@ VolatilePackages= Packages= bind-utils bpftool + btrfs-progs cryptsetup device-mapper dhcp-server docbook-xsl-stylesheets + erofs-utils f2fs-tools gawk git-core @@ -48,6 +50,7 @@ Packages= iputils kernel-default kmod + knot multipath-tools ncat open-iscsi @@ -61,6 +64,7 @@ Packages= python3-pefile python3-pexpect python3-psutil + qrencode quota rsync sbsigntools @@ -78,6 +82,7 @@ Packages= zypper InitrdPackages= + btrfs-progs kmod tpm2.0-tools diff --git a/mkosi.images/build/mkosi.conf b/mkosi.images/build/mkosi.conf index 037d25c5016..8a67c76ee59 100644 --- a/mkosi.images/build/mkosi.conf +++ b/mkosi.images/build/mkosi.conf @@ -3,7 +3,6 @@ [Content] Packages= clang - erofs-utils lld llvm diff --git a/mkosi.images/build/mkosi.conf.d/arch/mkosi.conf b/mkosi.images/build/mkosi.conf.d/arch/mkosi.conf index d5148eacb66..610c76585e0 100644 --- a/mkosi.images/build/mkosi.conf.d/arch/mkosi.conf +++ b/mkosi.images/build/mkosi.conf.d/arch/mkosi.conf @@ -13,4 +13,5 @@ Packages= base base-devel diffutils + erofs-utils git diff --git a/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.conf b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.conf index 06ea2acc8df..158b78bd356 100644 --- a/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.conf +++ b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.conf @@ -11,4 +11,3 @@ Packages= libasan libubsan rpm-build - rpmautospec diff --git a/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf b/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf index 99316bec5f6..1dc4f0084a0 100644 --- a/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf +++ b/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf @@ -6,7 +6,7 @@ Distribution=centos [Content] Packages= rsync # TODO: Drop when CentOS Stream 9 CI is removed. - rpmautospec-rpm-macros + squashfs-tools Environment= GIT_URL=https://git.centos.org/rpms/systemd.git diff --git a/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf.d/epel-packages.conf b/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf.d/epel-packages.conf new file mode 100644 index 00000000000..15849c51452 --- /dev/null +++ b/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf.d/epel-packages.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Repositories=epel + +[Content] +Packages= + erofs-utils + rpmautospec-rpm-macros diff --git a/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.conf b/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.conf index a7464aafe3e..84105008ed8 100644 --- a/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.conf +++ b/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.conf @@ -13,6 +13,7 @@ Environment= Packages= apt + erofs-utils git-core libclang-rt-dev dpkg-dev diff --git a/mkosi.images/build/mkosi.conf.d/fedora/mkosi.conf b/mkosi.images/build/mkosi.conf.d/fedora/mkosi.conf index 1f001452eb3..74a951ed2a7 100644 --- a/mkosi.images/build/mkosi.conf.d/fedora/mkosi.conf +++ b/mkosi.images/build/mkosi.conf.d/fedora/mkosi.conf @@ -8,3 +8,7 @@ Environment= GIT_URL=https://src.fedoraproject.org/rpms/systemd.git GIT_BRANCH=rawhide GIT_COMMIT=a3524fc837f5e7b68f86b3e0a9d470a94a04c4c8 + +Packages= + erofs-utils + rpmautospec diff --git a/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.conf b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.conf index ad6388faf7b..770a78bc2a7 100644 --- a/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.conf +++ b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.conf @@ -11,6 +11,7 @@ Environment= Packages= gcc-c++ + erofs-utils git-core patterns-base-minimal_base rpm-build From 3cfb020cb9ce5958ac39a7fd586cc4e893a7b190 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 11 Jul 2024 16:19:20 +0200 Subject: [PATCH 05/15] mkosi: Use squashfs for sysext if mkfs.erofs is not available CentOS Stream 10 does not have erofs-utils so let's add a fallback to squashfs when building the sysext. --- mkosi.functions | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mkosi.functions b/mkosi.functions index c19c1aa6435..993f2e8a394 100644 --- a/mkosi.functions +++ b/mkosi.functions @@ -38,7 +38,15 @@ EOF rm -f "$BUILDDIR"/systemd.raw - env --unset=SYSTEMD_REPART_OVERRIDE_FSTYPE_ROOT \ + local fstype + + if command -v mkfs.erofs; then + fstype=erofs + else + fstype=squashfs + fi + + env SYSTEMD_REPART_OVERRIDE_FSTYPE_ROOT="$fstype" \ "$BUILDDIR"/systemd-repart \ --make-ddi=sysext-unsigned \ --copy-source="$1" \ From 8b32cc79ec028fa783072676346141821444b638 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 11 Jul 2024 15:49:17 +0200 Subject: [PATCH 06/15] mkosi: Add CI for CentOS Stream 10 We switch to the c10s-sig-hyperscale branch of the spec repository as it will receive all the latest changes the earliest before they end up in the c9s-sig-hyperscale branch. --- .github/workflows/mkosi.yml | 6 ++++++ mkosi.images/build/mkosi.conf.d/centos/mkosi.conf | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mkosi.yml b/.github/workflows/mkosi.yml index 48ed15d9adc..7070e9c6364 100644 --- a/.github/workflows/mkosi.yml +++ b/.github/workflows/mkosi.yml @@ -96,6 +96,12 @@ jobs: llvm: 0 cflags: "-Og" relabel: yes + - distro: centos + release: "10" + sanitizers: "" + llvm: 0 + cflags: "-Og" + relabel: yes steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 diff --git a/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf b/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf index 1dc4f0084a0..cbb7ed2d296 100644 --- a/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf +++ b/mkosi.images/build/mkosi.conf.d/centos/mkosi.conf @@ -10,5 +10,5 @@ Packages= Environment= GIT_URL=https://git.centos.org/rpms/systemd.git - GIT_BRANCH=c9s-sig-hyperscale + GIT_BRANCH=c10s-sig-hyperscale GIT_COMMIT=46480aaa9e0ea63a85b6ca676554ce2aae10ce36 From ff8c89aa5a84733dd777f3e9113df33ce6c1ab1e Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 12 Jul 2024 16:04:22 +0200 Subject: [PATCH 07/15] test: do not attempt to set xattr on tmpfs This is only possible since a recent kernel version, and fails otherwise, like on CentOS 9 --- test/units/TEST-29-PORTABLE.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/units/TEST-29-PORTABLE.sh b/test/units/TEST-29-PORTABLE.sh index b4dcd5a1a29..41dce4d48a0 100755 --- a/test/units/TEST-29-PORTABLE.sh +++ b/test/units/TEST-29-PORTABLE.sh @@ -355,15 +355,16 @@ portablectl "${ARGS[@]}" attach --copy=symlink --now --runtime /tmp/rootdir mini portablectl detach --now --runtime --enable /tmp/rootdir minimal-app0 # The wrong file should be ignored, given the right one has the xattr set -mkdir -p /tmp/wrongext/usr/lib/extension-release.d /tmp/wrongext/usr/lib/systemd/system/ -echo "[Service]" > /tmp/wrongext/usr/lib/systemd/system/app0.service -touch /tmp/wrongext/usr/lib/extension-release.d/extension-release.wrongext_somethingwrong.txt -cp /tmp/rootdir/usr/lib/os-release /tmp/wrongext/usr/lib/extension-release.d/extension-release.app0 -setfattr -n user.extension-release.strict -v "false" /tmp/wrongext/usr/lib/extension-release.d/extension-release.app0 -portablectl "${ARGS[@]}" attach --runtime --extension /tmp/wrongext /tmp/rootdir app0 +trap 'rm -rf /var/cache/wrongext' EXIT +mkdir -p /var/cache/wrongext/usr/lib/extension-release.d /var/cache/wrongext/usr/lib/systemd/system/ +echo "[Service]" > /var/cache/wrongext/usr/lib/systemd/system/app0.service +touch /var/cache/wrongext/usr/lib/extension-release.d/extension-release.wrongext_somethingwrong.txt +cp /tmp/rootdir/usr/lib/os-release /var/cache/wrongext/usr/lib/extension-release.d/extension-release.app0 +setfattr -n user.extension-release.strict -v "false" /var/cache/wrongext/usr/lib/extension-release.d/extension-release.app0 +portablectl "${ARGS[@]}" attach --runtime --extension /var/cache/wrongext /tmp/rootdir app0 status="$(portablectl is-attached --extension wrongext rootdir)" [[ "${status}" == "attached-runtime" ]] -portablectl detach --runtime --extension /tmp/wrongext /tmp/rootdir app0 +portablectl detach --runtime --extension /var/cache/wrongext /tmp/rootdir app0 umount /tmp/rootdir umount /tmp/app0 From 54ab97e59dfa048dd563e2918b594db267efd698 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 12 Jul 2024 16:42:00 +0200 Subject: [PATCH 08/15] mkosi: Extend arch build script comment about symlinks --- mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot index 7798e78dda4..444f069b6f9 100755 --- a/mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot @@ -11,10 +11,13 @@ if [[ ! -f "pkg/$ID/PKGBUILD" ]]; then fi # We can't configure the source or build directory so we use symlinks instead to make sure they are in the -# expected locations. +# expected locations. Because we run with --noextract we are responsible for making sure the source files +# appear in src/. This means not only the systemd source directory, but also the patches and configuration +# files that are shipped in the packaging repository. To achieve this, instead of symlinking the systemd +# sources and build directory directly into "pkg/$ID/src", we symlink them into "pkg/$ID" and then symlink +# "pkg/$ID" to "pkg/$ID/src". ln --symbolic "$SRCDIR" "pkg/$ID/systemd" ln --symbolic "$BUILDDIR" "pkg/$ID/build" -# Because we run with --noextract we are responsible for making sure the source files appear in src/. ln --symbolic . "pkg/$ID/src" MKOSI_CFLAGS="-O0 -Wp,-U_FORTIFY_SOURCE" From 6e212a6db9fb04ebb5dd4f365e7cb3a9a9b59e2b Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 12 Jul 2024 16:45:04 +0200 Subject: [PATCH 09/15] mkosi: Use clang --print-runtime-dir --- mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot | 2 +- .../build/mkosi.conf.d/centos-fedora/mkosi.build.chroot | 2 +- .../build/mkosi.conf.d/debian-ubuntu/mkosi.build.chroot | 2 +- mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot index 444f069b6f9..dcdb7584dae 100755 --- a/mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/arch/mkosi.build.chroot @@ -28,7 +28,7 @@ fi MKOSI_LDFLAGS="" if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then - MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(clang --print-file-name="")lib/linux" + MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(realpath "$(clang --print-runtime-dir)")" fi MKOSI_MESON_OPTIONS="-D mode=developer -D b_sanitize=${SANITIZERS:-none}" diff --git a/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot index 3daa699b3e8..dc45e259909 100755 --- a/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot @@ -56,7 +56,7 @@ fi MKOSI_LDFLAGS="" if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then - MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(dirname "$(clang --print-file-name=libclang_rt.asan.so)")" + MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(realpath "$(clang --print-runtime-dir)")" fi MKOSI_MESON_OPTIONS="-D mode=developer -D b_sanitize=${SANITIZERS:-none}" diff --git a/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.build.chroot index 6620bda1755..fc9c796ad27 100755 --- a/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/debian-ubuntu/mkosi.build.chroot @@ -48,7 +48,7 @@ fi MKOSI_LDFLAGS="" if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then - MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(clang --print-file-name="")lib/linux" + MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(realpath "$(clang --print-runtime-dir)")" fi MKOSI_MESON_OPTIONS="-D mode=developer -D b_sanitize=${SANITIZERS:-none}" diff --git a/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot index 266695ccc78..82e81cc9d80 100755 --- a/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot @@ -51,7 +51,7 @@ fi MKOSI_LDFLAGS="$(rpm --eval "%{?build_ldflags}")" if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then - MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(clang --print-file-name="")lib/linux" + MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(realpath "$(clang --print-runtime-dir)")" fi # A macro can't have an empty body and currently opensuse does not specify any of its own linker flags so From d97b48176b072211be099318f75dfea62820b4f8 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 14 Jul 2024 22:27:09 +0200 Subject: [PATCH 10/15] TEST-64-UDEV-STORAGE: Use max_ioqpairs instead of num_queues Fixes a deprecation warning from qemu. --- test/TEST-64-UDEV-STORAGE/nvme_basic.configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/TEST-64-UDEV-STORAGE/nvme_basic.configure b/test/TEST-64-UDEV-STORAGE/nvme_basic.configure index 28ddfa46c11..b740c096c4e 100755 --- a/test/TEST-64-UDEV-STORAGE/nvme_basic.configure +++ b/test/TEST-64-UDEV-STORAGE/nvme_basic.configure @@ -25,7 +25,7 @@ def add_drive(i: int, serial: str) -> None: "Options": "cache=unsafe", } ] - config["QemuArgs"] += ["-device", f"nvme,drive={id},serial={serial},num_queues=8"] + config["QemuArgs"] += ["-device", f"nvme,drive={id},serial={serial},max_ioqpairs=8"] for i in range(5): add_drive(i, serial=f"deadbeef{i}") From a1071c12499c7a5d918f5a6c93d052efbcaec803 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 14 Jul 2024 22:56:43 +0200 Subject: [PATCH 11/15] mkosi: Install binutils --- mkosi.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkosi.conf b/mkosi.conf index dfcd9fe0404..cafd563c358 100644 --- a/mkosi.conf +++ b/mkosi.conf @@ -92,6 +92,7 @@ Packages= acl attr bash-completion + binutils bpftrace coreutils curl From f65ec2e90483689546d4d700c5ad8475f19a3ab7 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 15 Jul 2024 09:21:51 +0200 Subject: [PATCH 12/15] TEST-55-OOMD: Remove the opensuse user@ dropin Required to make TEST-55-OOMD pass on OpenSUSE. --- test/TEST-55-OOMD/meson.build | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/TEST-55-OOMD/meson.build b/test/TEST-55-OOMD/meson.build index adc05097869..2566316c93c 100644 --- a/test/TEST-55-OOMD/meson.build +++ b/test/TEST-55-OOMD/meson.build @@ -5,6 +5,9 @@ integration_tests += [ 'name' : fs.name(meson.current_source_dir()), 'credentials' : integration_test_template['credentials'] + [ files('systemd.unit-dropin.init.scope'), + # OpenSUSE disables all controller delegation for the user manager template. Mask the + # dropin to make TEST-55-OOMD pass on OpenSUSE. + 'systemd.unit-dropin.user@.service~20-defaults-SUSE=', ], 'vm' : true, }, From 985d5b4bc23f791bdc79d4c2a9a949cc5d3bc27a Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 15 Jul 2024 12:26:04 +0200 Subject: [PATCH 13/15] systemd-networkd-tests: Skip tests requiring dhcpd if it is not available dhcpd is not available on CentOS Stream 10 See https://github.com/systemd/systemd/issues/33717 --- test/test-network/systemd-networkd-tests.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 7c336ba9e29..ba8e65ee90b 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -7120,6 +7120,7 @@ class NetworkdDHCPPDTests(unittest.TestCase, Utilities): self.assertGreater(prefixInfo[0]['PreferredLifetimeUSec'], 0) self.assertGreater(prefixInfo[0]['ValidLifetimeUSec'], 0) + @unittest.skipUnless(shutil.which('dhcpd'), reason="dhcpd is not available on CentOS Stream 10") def test_dhcp6pd_no_address(self): # For issue #29979. copy_network_unit('25-veth.netdev', '25-dhcp6pd-server.network', '25-dhcp6pd-upstream-no-address.network') @@ -7136,6 +7137,7 @@ class NetworkdDHCPPDTests(unittest.TestCase, Utilities): self.check_dhcp6_prefix('veth99') + @unittest.skipUnless(shutil.which('dhcpd'), reason="dhcpd is not available on CentOS Stream 10") def test_dhcp6pd_no_assign(self): # Similar to test_dhcp6pd_no_assign(), but in this case UseAddress=yes (default), # However, the server does not provide IA_NA. For issue #31349. @@ -7153,6 +7155,7 @@ class NetworkdDHCPPDTests(unittest.TestCase, Utilities): self.check_dhcp6_prefix('veth99') + @unittest.skipUnless(shutil.which('dhcpd'), reason="dhcpd is not available on CentOS Stream 10") def test_dhcp6pd(self): copy_network_unit('25-veth.netdev', '25-dhcp6pd-server.network', '25-dhcp6pd-upstream.network', '25-veth-downstream-veth97.netdev', '25-dhcp-pd-downstream-veth97.network', '25-dhcp-pd-downstream-veth97-peer.network', From 88221219a3290ee20de27aa030c2b23f03d8238a Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 15 Jul 2024 17:15:43 +0200 Subject: [PATCH 14/15] mkosi: Disable unique debug source names We use -fdebug-prefix-map= because debugedit doesn't work for us (for a currently unknown reason since it's the most obtuse code I've ever had the pleasure of reading). With all the unique macros enabled, the destination directory we pass to -fdebug-prefix-map= includes the package release. The release is either the timestamp of the current commit or the current time if the working tree is dirty. This means it generally changes every time we rerun the build script. However, meson only reads compiler arguments the first time it is invoked or if --wipe is specified. This means that on a rerun -fdebug-prefix-map= will be configured wrong and the build will fail. Let's prevent this from happening by disabling the unique debug source names by overriding the --unique-debug-src-base option that is passed to find-debuginfo.sh by rpm via the _find_debuginfo_opts macro. --- .../build/mkosi.conf.d/centos-fedora/mkosi.build.chroot | 7 ++----- .../build/mkosi.conf.d/opensuse/mkosi.build.chroot | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot index dc45e259909..ce1e162ebfa 100755 --- a/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot @@ -31,10 +31,6 @@ fi VERSION="$(cat meson.version)" RELEASE="$(date "+%Y%m%d%H%M%S" --date "@$TS")" -DIST="$(rpm --eval %dist)" -ARCH="$(rpm --eval %_arch)" -SRCDEST="/usr/src/debug/systemd-$VERSION-${RELEASE}${DIST}.$ARCH" - COMMON_MACRO_OVERRIDES=( --define "toolchain $( ((LLVM)) && echo clang || echo gcc)" --define "_fortify_level 0" @@ -47,7 +43,7 @@ COMMON_MACRO_OVERRIDES=( # TODO: Drop -U_FORTIFY_SOURCE when we switch to CentOS Stream 10. MKOSI_CFLAGS="-O0 -Wp,-U_FORTIFY_SOURCE" if ((WITH_DEBUG)); then - MKOSI_CFLAGS="$MKOSI_CFLAGS -fdebug-prefix-map=../src=$SRCDEST" + MKOSI_CFLAGS="$MKOSI_CFLAGS -fdebug-prefix-map=../src=/usr/src/debug/systemd" fi if ((LLVM)); then # TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed. @@ -105,6 +101,7 @@ CXX_LD="$( ((LLVM)) && echo lld)" \ --define "__brp_check_rpaths %{nil}" \ --define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \ --define "__script_requires %{nil}" \ + --define "_find_debuginfo_opts --unique-debug-src-base \"%{name}\"" \ --define "_find_debuginfo_dwz_opts %{nil}" \ --define "_fixperms true" \ --undefine _package_note_flags \ diff --git a/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot index 82e81cc9d80..95d747cd937 100755 --- a/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot +++ b/mkosi.images/build/mkosi.conf.d/opensuse/mkosi.build.chroot @@ -36,13 +36,9 @@ fi VERSION="$(cat meson.version)" RELEASE="$(date "+%Y%m%d%H%M%S" --date "@$TS")" -DIST="$(rpm --eval %dist)" -ARCH="$(rpm --eval %_arch)" -SRCDEST="/usr/src/debug/systemd-$VERSION-${RELEASE}${DIST}.$ARCH" - MKOSI_CFLAGS="-O0 -Wp,-U_FORTIFY_SOURCE" if ((WITH_DEBUG)); then - MKOSI_CFLAGS="$MKOSI_CFLAGS -fdebug-prefix-map=../src=$SRCDEST" + MKOSI_CFLAGS="$MKOSI_CFLAGS -fdebug-prefix-map=../src=/usr/src/debug/systemd" fi if ((LLVM)); then # TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed. @@ -104,6 +100,7 @@ build() { --define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \ --define "__script_requires %{nil}" \ --define "_find_debuginfo_dwz_opts %{nil}" \ + --define "_find_debuginfo_opts --unique-debug-src-base \"%{name}\"" \ --define "_fixperms true" \ --noclean \ "$@" \ From 5ac0dc70ff330a531539a92552fbeb0f542edfb5 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 15 Jul 2024 23:07:52 +0200 Subject: [PATCH 15/15] TEST-13-NSPAWN: make sure we don't load libnss_systemd Let's make sure we don't load libnss_systemd.so from bash as the necessary environment variables aren't set to make that work when we're running with sanitizers enabled. We can't add a sanitizer wrapper for bash as the wrapper runs using bash so you end up in a loop. --- test/units/TEST-13-NSPAWN.nspawn.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/units/TEST-13-NSPAWN.nspawn.sh b/test/units/TEST-13-NSPAWN.nspawn.sh index c73b49b1a54..ee0fef8d061 100755 --- a/test/units/TEST-13-NSPAWN.nspawn.sh +++ b/test/units/TEST-13-NSPAWN.nspawn.sh @@ -179,6 +179,10 @@ elif [[ $1 == initgroups ]]; then fi EOF chmod +x "$root/bin/getent" + # The useradd is important here so the user is added to /etc/passwd. If the user is not in /etc/passwd, + # bash will end up loading libnss_systemd.so which breaks when libnss_systemd.so is built with sanitizers + # as bash isn't invoked with the necessary environment variables for that. + useradd --root="$root" --uid 1000 --user-group --create-home testuser systemd-nspawn --directory="$root" bash -xec '[[ $USER == root ]]' systemd-nspawn --directory="$root" --user=testuser bash -xec '[[ $USER == testuser ]]' @@ -672,8 +676,10 @@ fi EOF chmod +x "$root/bin/getent" - mkdir -p "$root/home/testuser" - chown 1010:1010 "$root/home/testuser" + # The useradd is important here so the user is added to /etc/passwd. If the user is not in /etc/passwd, + # bash will end up loading libnss_systemd.so which breaks when libnss_systemd.so is built with sanitizers + # as bash isn't invoked with the necessary environment variables for that. + useradd --root="$root" --uid 1010 --user-group --create-home testuser cmd='PERMISSIONS=$(stat -c "%u:%g" /home/testuser/file); if [[ $PERMISSIONS != "1010:1010" ]]; then echo "*** wrong permissions: $PERMISSIONS"; return 1; fi; touch /home/testuser/other_file' if ! SYSTEMD_LOG_TARGET=console \