1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 18:55:40 +03:00

mkosi: Make sure our systemd build always overrides the distros

Currently, we install the systemd install tree in the base image and
then build the initrd and final images from the base image. This means
if that any systemd package is pulled in during the initrd or final
image builds, it will override our version.

To fix this, we stop installing our build of systemd in the base image,
and store it in the output directory instead. That allows us to refer to
it using ExtraTrees= in the final and initrd image builds to install it
after all the distro packages have been installed, ensuring our version
always takes priority.
This commit is contained in:
Daan De Meyer 2023-08-04 10:40:30 +02:00
parent f2f8ed193c
commit 6ac5aa97ec
8 changed files with 32 additions and 20 deletions

View File

@ -9,6 +9,11 @@ if [ "${container:-}" != "mkosi" ]; then
exec mkosi-chroot "$SCRIPT" "$@" exec mkosi-chroot "$SCRIPT" "$@"
fi fi
# We don't want to install our build of systemd in the base image, but use it as an extra tree for the
# initrd and final images, so override DESTDIR to store it in the output directory so we can reference it as
# an extra tree in the initrd and final image builds.
DESTDIR="$OUTPUTDIR/systemd"
# If mkosi.builddir/ exists mkosi will set $BUILDDIR to it, let's then use it # If mkosi.builddir/ exists mkosi will set $BUILDDIR to it, let's then use it
# as out-of-tree build dir. Otherwise, let's make up our own builddir. # as out-of-tree build dir. Otherwise, let's make up our own builddir.
[ -z "$BUILDDIR" ] && BUILDDIR="$PWD"/build [ -z "$BUILDDIR" ] && BUILDDIR="$PWD"/build
@ -29,7 +34,8 @@ done
# CentOS Stream 8 includes bpftool 4.18.0 which is lower than what we need. However, they've backported the # CentOS Stream 8 includes bpftool 4.18.0 which is lower than what we need. However, they've backported the
# specific feature we need ("gen skeleton") to this version, so we replace bpftool with a script that reports # specific feature we need ("gen skeleton") to this version, so we replace bpftool with a script that reports
# version 5.6.0 to satisfy meson which makes bpf work on CentOS Stream 8 as well. # version 5.6.0 to satisfy meson which makes bpf work on CentOS Stream 8 as well.
if [ "$(grep '^ID=' /etc/os-release)" = "ID=\"centos\"" ] && [ "$(grep '^VERSION=' /etc/os-release)" = "VERSION=\"8\"" ]; then . /usr/lib/os-release
if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then
cat >"$BUILDDIR"/bpftool <<EOF cat >"$BUILDDIR"/bpftool <<EOF
#!/bin/sh #!/bin/sh
if [ "\$1" = --version ]; then if [ "\$1" = --version ]; then
@ -44,7 +50,6 @@ fi
if [ ! -f "$BUILDDIR"/build.ninja ]; then if [ ! -f "$BUILDDIR"/build.ninja ]; then
sysvinit_path=$(realpath /etc/init.d) sysvinit_path=$(realpath /etc/init.d)
. /etc/os-release
if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then
UKIFY=false UKIFY=false
else else
@ -157,7 +162,7 @@ if [ ! -f "$BUILDDIR"/build.ninja ]; then
# On debian-like systems the library directory is not /usr/lib64 but /usr/lib/<arch-triplet>/. # On debian-like systems the library directory is not /usr/lib64 but /usr/lib/<arch-triplet>/.
# It is important to use the right one especially for cryptsetup plugins, otherwise they will be # It is important to use the right one especially for cryptsetup plugins, otherwise they will be
# installed in the wrong directory and not be found by cryptsetup. Assume native build. # installed in the wrong directory and not be found by cryptsetup. Assume native build.
if grep -q -e "ID=debian" -e "ID_LIKE=debian" /etc/os-release && command -v dpkg 2>/dev/null; then if grep -q -e "ID=debian" -e "ID_LIKE=debian" /usr/lib/os-release && command -v dpkg 2>/dev/null; then
CONFIGURE_OPTS+=( CONFIGURE_OPTS+=(
-D libdir="/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)" -D libdir="/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
-D pamlibdir="/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/security" -D pamlibdir="/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/security"
@ -167,7 +172,7 @@ if [ ! -f "$BUILDDIR"/build.ninja ]; then
# Set various uids and gids for which Fedora has "soft static" allocations. # Set various uids and gids for which Fedora has "soft static" allocations.
# Without this, we would get warning about mismatched sysusers.d entries # Without this, we would get warning about mismatched sysusers.d entries
# between the files that we and Fedora's setup package install. # between the files that we and Fedora's setup package install.
if grep -q '^ID=fedora' /etc/os-release; then if grep -q '^ID=fedora' /usr/lib/os-release; then
CONFIGURE_OPTS+=( CONFIGURE_OPTS+=(
-Dadm-gid=4 -Dadm-gid=4
-Daudio-gid=63 -Daudio-gid=63
@ -192,7 +197,7 @@ if [ ! -f "$BUILDDIR"/build.ninja ]; then
) )
fi fi
if grep -q '^ID="opensuse' /etc/os-release; then if grep -q '^ID="opensuse' /usr/lib/os-release; then
CONFIGURE_OPTS+=( CONFIGURE_OPTS+=(
-Dbpf-compiler=gcc -Dbpf-compiler=gcc
) )

View File

@ -9,8 +9,7 @@ CleanPackageMetadata=no
Packages= Packages=
kmod kmod
less less
systemd util-linux
udev
BuildPackages= BuildPackages=
acl acl

View File

@ -5,16 +5,18 @@ Distribution=arch
[Content] [Content]
Packages= Packages=
cryptsetup
dbus
gnutls gnutls
libbpf libbpf
libfido2 libfido2
libmicrohttpd libmicrohttpd
libnftnl libnftnl
libpwquality libpwquality
libseccomp
libxkbcommon libxkbcommon
openssl openssl
qrencode qrencode
systemd-sysvcompat
tpm2-tss tpm2-tss
BuildPackages= BuildPackages=

View File

@ -21,8 +21,6 @@ Packages=
libqrencode4 libqrencode4
libssl3 libssl3
libtss2-dev # Use the -dev package to avoid churn in updating version numbers libtss2-dev # Use the -dev package to avoid churn in updating version numbers
systemd
systemd-sysv
tzdata tzdata
BuildPackages= BuildPackages=

View File

@ -4,9 +4,12 @@
Distribution=opensuse Distribution=opensuse
[Content] [Content]
# We install gawk, gzip, grep, xz here explicitly so that the busybox versions don't get installed instead. # We install gawk, gzip, grep, xz, sed, rsync and docbook-xsl-stylesheets here explicitly so that the busybox
# versions don't get installed instead.
Packages= Packages=
device-mapper device-mapper
distribution-release
docbook-xsl-stylesheets
gawk gawk
grep grep
gzip gzip
@ -25,16 +28,16 @@ Packages=
libp11-kit0 libp11-kit0
libqrencode4 libqrencode4
libseccomp2 libseccomp2
libxkbcommon0
libzstd1
pam
shadow
libtss2-esys0 libtss2-esys0
libtss2-mu0 libtss2-mu0
libtss2-rc0 libtss2-rc0
libtss2-tcti-device0 libtss2-tcti-device0
# Workaround for CI issue with our stub getting overwritten libxkbcommon0
systemd-boot libzstd1
pam
rsync
sed
shadow
tpm2-0-tss tpm2-0-tss
xz xz
@ -43,7 +46,6 @@ BuildPackages=
bpftool bpftool
cross-bpf-gcc13 cross-bpf-gcc13
dbus-1-devel dbus-1-devel
docbook-xsl-stylesheets
fdupes fdupes
gcc-c++ gcc-c++
glib2-devel glib2-devel
@ -84,7 +86,6 @@ BuildPackages=
python3-pytest-flakes python3-pytest-flakes
qrencode-devel qrencode-devel
shadow shadow
systemd-sysvinit
timezone timezone
tpm2-0-tss-devel tpm2-0-tss-devel
xen-devel xen-devel

View File

@ -9,7 +9,11 @@ Format=cpio
[Content] [Content]
BaseTrees=../../mkosi.output/base BaseTrees=../../mkosi.output/base
ExtraTrees=../../mkosi.output/base-systemd
MakeInitrd=yes MakeInitrd=yes
Packages=
systemd
udev
# Arch Linux doesn't split their gcc-libs package so we manually remove unneeded stuff here to make sure it # 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. # doesn't end up in the initrd.

View File

@ -3,6 +3,7 @@
[Content] [Content]
Autologin=yes Autologin=yes
BaseTrees=../../mkosi.output/base BaseTrees=../../mkosi.output/base
ExtraTrees=../../mkosi.output/base-systemd
ExtraTrees=../../src:/root/src ExtraTrees=../../src:/root/src
Initrds=../../mkosi.output/initrd Initrds=../../mkosi.output/initrd
Packages= Packages=
@ -28,8 +29,10 @@ Packages=
sed sed
socat socat
strace strace
systemd
tmux tmux
tree tree
udev
util-linux util-linux
valgrind valgrind
wireguard-tools wireguard-tools

View File

@ -79,7 +79,7 @@ fi
# Let tmpfiles.d/systemd-resolve.conf handle the symlink # Let tmpfiles.d/systemd-resolve.conf handle the symlink
rm -f /etc/resolv.conf rm -f /etc/resolv.conf
. /etc/os-release . /usr/lib/os-release
if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then
alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1