| 1 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 |
|
| 3 |
# This is intended to be included by mkosi.build.chroot, |
| 4 |
# and sets the following variables and one common function: |
| 5 |
# - $MKOSI_CFLAGS |
| 6 |
# - $MKOSI_LDFLAGS |
| 7 |
# - $MKOSI_MESON_OPTIONS |
| 8 |
|
| 9 |
MKOSI_CFLAGS="-O0 -g" |
| 10 |
if ((LLVM)); then |
| 11 |
# TODO: Remove -fno-sanitize-function when https://github.com/systemd/systemd/issues/29972 is fixed. |
| 12 |
MKOSI_CFLAGS="$MKOSI_CFLAGS -shared-libasan -fno-sanitize=function" |
| 13 |
fi |
| 14 |
|
| 15 |
MKOSI_LDFLAGS="" |
| 16 |
if ((LLVM)) && [[ -n "$SANITIZERS" ]]; then |
| 17 |
MKOSI_LDFLAGS="$MKOSI_LDFLAGS -Wl,-rpath=$(realpath "$(clang --print-runtime-dir)")" |
| 18 |
fi |
| 19 |
|
| 20 |
MKOSI_MESON_OPTIONS="-D mode=developer -D vcs-tag=${VCS_TAG:-true} -D b_sanitize=${SANITIZERS:-none} -Dtime-epoch=1744207869" |
| 21 |
if ((WIPE)) && [[ -d "$BUILDDIR/meson-private" ]]; then |
| 22 |
MKOSI_MESON_OPTIONS="$MKOSI_MESON_OPTIONS --wipe" |
| 23 |
fi |
| 24 |
|
| 25 |
if ((COVERAGE)); then |
| 26 |
MKOSI_MESON_OPTIONS="$MKOSI_MESON_OPTIONS -D b_coverage=true" |
| 27 |
MKOSI_CFLAGS="$MKOSI_CFLAGS -fprofile-dir=/coverage" |
| 28 |
fi |
| 29 |
|
| 30 |
make_sysext_unsigned() { |
| 31 |
if ! ((SYSEXT)); then |
| 32 |
return |
| 33 |
fi |
| 34 |
|
| 35 |
mkdir -p /usr/lib/systemd/repart/definitions/sysext-unsigned.repart.d |
| 36 |
cat >/usr/lib/systemd/repart/definitions/sysext-unsigned.repart.d/10-root.conf <<EOF |
| 37 |
[Partition] |
| 38 |
Type=root |
| 39 |
Format=erofs |
| 40 |
CopyFiles=/usr/ |
| 41 |
Minimize=best |
| 42 |
EOF |
| 43 |
|
| 44 |
. /usr/lib/os-release |
| 45 |
|
| 46 |
mkdir -p "$1"/usr/lib/extension-release.d |
| 47 |
cat >"$1"/usr/lib/extension-release.d/extension-release.systemd <<EOF |
| 48 |
ID=$ID |
| 49 |
SYSEXT_ID=systemd |
| 50 |
SYSEXT_SCOPE=system |
| 51 |
ARCHITECTURE=$ARCHITECTURE |
| 52 |
EOF |
| 53 |
|
| 54 |
if [[ -n "$VERSION_ID" ]]; then |
| 55 |
cat >>"$1"/usr/lib/extension-release.d/extension-release.systemd <<EOF |
| 56 |
VERSION_ID=$VERSION_ID |
| 57 |
EOF |
| 58 |
fi |
| 59 |
|
| 60 |
if [[ -n "$SYSEXT_LEVEL" ]]; then |
| 61 |
cat >>"$1"/usr/lib/extension-release.d/extension-release.systemd <<EOF |
| 62 |
SYSEXT_LEVEL=$SYSEXT_LEVEL |
| 63 |
EOF |
| 64 |
fi |
| 65 |
|
| 66 |
rm -f "$BUILDDIR"/systemd.raw |
| 67 |
|
| 68 |
local fstype |
| 69 |
|
| 70 |
if command -v mkfs.erofs; then |
| 71 |
fstype=erofs |
| 72 |
else |
| 73 |
fstype=squashfs |
| 74 |
fi |
| 75 |
|
| 76 |
env SYSTEMD_REPART_OVERRIDE_FSTYPE_ROOT="$fstype" \ |
| 77 |
"$BUILDDIR"/systemd-repart \ |
| 78 |
--make-ddi=sysext-unsigned \ |
| 79 |
--copy-source="$1" \ |
| 80 |
--pretty=no \ |
| 81 |
"$BUILDDIR"/systemd.raw |
| 82 |
} |