]>
git.ipfire.org Git - thirdparty/systemd.git/blob - mkosi.build
2 # SPDX-License-Identifier: LGPL-2.1-or-later
5 # This is a build script for OS image generation using mkosi (https://github.com/systemd/mkosi).
6 # Simply invoke "mkosi" in the project directory to build an OS image.
8 # If mkosi.builddir/ exists mkosi will set $BUILDDIR to it, let's then use it
9 # as out-of-tree build dir. Otherwise, let's make up our own builddir.
10 [ -z "$BUILDDIR" ] && BUILDDIR
="$PWD"/build
12 # Let's make sure we're using stuff from the build directory first if available there.
13 PATH
="$BUILDDIR:$PATH"
16 # The bpftool script shipped by Ubuntu tries to find the actual program to run via querying `uname -r` and
17 # using the current kernel version. This obviously doesn't work in containers. As a workaround, we override
18 # the ubuntu script with a symlink to the first bpftool program we can find.
19 for bpftool
in /usr
/lib
/linux-tools
/*/bpftool
; do
20 [ -x "$bpftool" ] ||
continue
21 ln -sf "$bpftool" "$BUILDDIR"/bpftool
25 # CentOS Stream 8 includes bpftool 4.18.0 which is lower than what we need. However, they've backported the
26 # specific feature we need ("gen skeleton") to this version, so we replace bpftool with a script that reports
27 # version 5.6.0 to satisfy meson which makes bpf work on CentOS Stream 8 as well.
28 if [ "$(grep '^ID=' /etc/os-release)" = "ID=\"centos\"" ] && [ "$(grep '^VERSION=' /etc/os-release)" = "VERSION=\"8\"" ]; then
29 cat >"$BUILDDIR"/bpftool
<<EOF
31 if [ "\$1" = --version ]; then
34 exec /usr/sbin/bpftool \$@
37 chmod +x
"$BUILDDIR"/bpftool
40 if [ ! -f "$BUILDDIR"/build.ninja
] ; then
41 sysvinit_path
=$
(realpath
/etc
/init.d
)
43 init_path
=$
(realpath
/sbin
/init
2>/dev
/null
)
44 if [ -z "$init_path" ] ; then
47 rootprefix
=${init_path%/lib/systemd/systemd}
48 rootprefix
=/${rootprefix#/}
51 # On debian-like systems the library directory is not /usr/lib64 but /usr/lib/<arch-triplet>/.
52 # It is important to use the right one especially for cryptsetup plugins, otherwise they will be
53 # installed in the wrong directory and not be found by cryptsetup. Assume native build.
54 if grep -q -e "ID=debian" -e "ID_LIKE=debian" /etc
/os-release
&& command -v dpkg
2>/dev
/null
; then
55 LIBDIR
="-Drootlibdir=/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
56 PAMDIR
="-Dpamlibdir=/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/security"
59 # Cannot quote $LIBDIR and $PAMDIR, because they may be empty, and meson will fail.
60 # shellcheck disable=SC2086
61 meson setup
"$BUILDDIR" \
64 -D "sysvinit-path=$sysvinit_path" \
65 -D "rootprefix=$rootprefix" \
67 -D translations
=false \
68 -D version-tag
="${VERSION_TAG}" \
70 -D b_sanitize
="${SANITIZERS:-none}" \
71 -D install-tests
=true \
80 -D environment-d
=true \
99 -D nss-myhostname
=true \
100 -D nss-mymachines
=true \
101 -D nss-resolve
=true \
102 -D nss-systemd
=true \
113 -D xdg-autostart
=true \
114 -D translations
=true \
124 -D libcryptsetup
=true \
132 -D cryptolib
=openssl \
143 -D kernel-install
=true \
145 -D bpf-framework
=true \
149 ninja
-C "$BUILDDIR" "$@"
150 if [ "$WITH_TESTS" = 1 ] ; then
151 if [ -n "$SANITIZERS" ]; then
152 export ASAN_OPTIONS
="$MKOSI_ASAN_OPTIONS"
153 export UBSAN_OPTIONS
="$MKOSI_UBSAN_OPTIONS"
159 meson
test -C "$BUILDDIR" --print-errorlogs --timeout-multiplier=$TIMEOUT_MULTIPLIER
162 meson
install -C "$BUILDDIR" --quiet --no-rebuild --only-changed
164 if [ -d mkosi.kernel
/ ]; then
165 SRCDIR
="$SRCDIR/mkosi.kernel"
166 BUILDDIR
="$BUILDDIR/mkosi.kernel"
170 # Ensure fast incremental builds by fixating these values which usually change for each build.
171 export KBUILD_BUILD_TIMESTAMP
="Fri Jun 5 15:58:00 CEST 2015"
172 export KBUILD_BUILD_HOST
="mkosi"
174 scripts
/kconfig
/merge_config.sh
-O "$BUILDDIR" \
175 ..
/mkosi.kernel.config \
176 tools
/testing
/selftests
/bpf
/config.x86_64 \
177 tools
/testing
/selftests
/bpf
/config
179 make O
="$BUILDDIR" -j "$(nproc)"
181 KERNEL_RELEASE
=$
(make O
="$BUILDDIR" -s kernelrelease
)
182 mkdir
-p "$DESTDIR/usr/lib/modules/$KERNEL_RELEASE"
183 make O
="$BUILDDIR" INSTALL_MOD_PATH
="$DESTDIR/usr" modules_install
184 make O
="$BUILDDIR" INSTALL_PATH
="$DESTDIR/usr/lib/modules/$KERNEL_RELEASE" install
185 mkdir
-p "$DESTDIR/usr/lib/kernel/selftests"
186 make -C tools
/testing
/selftests
-j "$(nproc)" O
="$BUILDDIR" KSFT_INSTALL_PATH
="$DESTDIR/usr/lib/kernel/selftests" SKIP_TARGETS
="" install
188 ln -sf /usr
/lib
/kernel
/selftests
/bpf
/bpftool
"$DESTDIR/usr/bin/bpftool"