#!/bin/bash # SPDX-License-Identifier: LGPL-2.1-or-later set -e if [[ ! -f "pkg/$PKG_SUBDIR/PKGBUILD" ]]; then echo "PKGBUILD not found at pkg/$PKG_SUBDIR/PKGBUILD, run mkosi once with -ff to make sure the PKGBUILD is cloned" >&2 exit 1 fi # We can't configure the source or build directory so we use symlinks instead to make sure they are in the # 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/$PKG_SUBDIR/src", we symlink them into "pkg/$PKG_SUBDIR" and # then symlink "pkg/$PKG_SUBDIR" to "pkg/$PKG_SUBDIR/src". ln --symbolic "$SRCDIR" "pkg/$PKG_SUBDIR/systemd" ln --symbolic "$BUILDDIR" "pkg/$PKG_SUBDIR/build" ln --symbolic . "pkg/$PKG_SUBDIR/src" MKOSI_CFLAGS="-O0 -Wp,-U_FORTIFY_SOURCE" if ((LLVM)); then # TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed. MKOSI_CFLAGS="$MKOSI_CFLAGS -shared-libasan -fno-sanitize=function" fi MKOSI_LDFLAGS="" if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(realpath "$(clang --print-runtime-dir)")" fi MKOSI_MESON_OPTIONS="-D mode=developer -D b_sanitize=${SANITIZERS:-none}" if ((WIPE)) && [[ -d "$BUILDDIR/meson-private" ]]; then MKOSI_MESON_OPTIONS="$MKOSI_MESON_OPTIONS --wipe" fi # Override the default options. We specifically disable "strip", "zipman" and "lto" as they slow down builds # significantly. OPTIONS= cannot be overridden on the makepkg command line so we append to /etc/makepkg.conf # instead. The rootfs is overlaid with a writable tmpfs during the build script so these changes don't end up # in the image itself. tee --append /etc/makepkg.conf >/dev/null <