]> git.ipfire.org Git - thirdparty/systemd.git/blame - mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot
mkosi: Override build_cflags instead of _distro_extra_cflags
[thirdparty/systemd.git] / mkosi.images / system / mkosi.conf.d / 10-centos-fedora / mkosi.build.chroot
CommitLineData
4d0f1451
DDM
1#!/bin/bash
2# SPDX-License-Identifier: LGPL-2.1-or-later
d008a9cf 3set -e
4d0f1451 4
d6f206b9
DDM
5# shellcheck source=/dev/null
6. /usr/lib/os-release
7
8if [ ! -f "pkg/$ID/systemd.spec" ]; then
9 echo "spec not found at pkg/$ID/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
4d0f1451
DDM
10 exit 1
11fi
12
13if [ -d .git/ ] && [ -z "$(git status --porcelain)" ]; then
14 TS="$(git show --no-patch --format=%ct HEAD)"
15else
16 TS="${SOURCE_DATE_EPOCH:-$(date +%s)}"
17fi
18
4980ae0f
DDM
19# Fix the %install override so debuginfo packages are generated even when --build-in-place is used.
20# See https://github.com/rpm-software-management/rpm/issues/3042.
21tee --append /usr/lib/rpm/redhat/macros <<'EOF'
22%install %{?_enable_debug_packages:%{debug_package}}\
23%%install\
24%{nil}
25EOF
26
8e728c14
DDM
27VERSION="$(cat meson.version)"
28RELEASE="$(date "+%Y%m%d%H%M%S" --date "@$TS")"
29
30DIST="$(rpm --eval %dist)"
31ARCH="$(rpm --eval %_arch)"
32SRCDEST="/usr/src/debug/systemd-$VERSION-${RELEASE}${DIST}.$ARCH"
33
34EXTRA_CFLAGS="-Og"
35if ((WITH_DEBUG)); then
36 EXTRA_CFLAGS="$EXTRA_CFLAGS -ffile-prefix-map=../src=$SRCDEST"
37fi
38
4980ae0f 39IFS=
4d0f1451
DDM
40# TODO: Replace meson_build and meson_install overrides with "--undefine __meson_verbose" once
41# https://github.com/mesonbuild/meson/pull/12835 is available.
42# shellcheck disable=SC2046
43rpmbuild \
44 -bb \
45 --build-in-place \
46 --with upstream \
0a6bf709
DDM
47 $( ((WITH_TESTS)) || echo "--nocheck") \
48 $( ((WITH_DOCS)) || echo "--without docs") \
4d0f1451 49 --define "_topdir /var/tmp" \
d6f206b9 50 --define "_sourcedir pkg/$ID" \
5524d283 51 --define "_rpmdir $OUTPUTDIR" \
4d0f1451
DDM
52 ${BUILDDIR:+--define} \
53 ${BUILDDIR:+"_vpath_builddir $BUILDDIR"} \
54 --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
55 --define "_binary_payload w.ufdio" \
4980ae0f
DDM
56 $( ((WITH_DEBUG)) || echo --define) \
57 $( ((WITH_DEBUG)) || echo "debug_package %{nil}") \
8e728c14
DDM
58 --define "version_override $VERSION" \
59 --define "release_override $RELEASE" \
7f1d7fed 60 --define "build_cflags $(rpm --eval %build_cflags) $EXTRA_CFLAGS" \
4d0f1451
DDM
61 --define "meson_build %{shrink:%{__meson} compile -C %{_vpath_builddir} -j %{_smp_build_ncpus} %{nil}}" \
62 --define "meson_install %{shrink:DESTDIR=%{buildroot} %{__meson} install -C %{_vpath_builddir} --no-rebuild --quiet %{nil}}" \
63 --define "meson_extra_configure_options -D mode=developer -D b_sanitize=${SANITIZERS:-none}" \
4980ae0f
DDM
64 $( ((WITH_DEBUG)) || echo --define) \
65 $( ((WITH_DEBUG)) || echo "__brp_strip %{nil}") \
4d0f1451
DDM
66 --define "__brp_compress %{nil}" \
67 --define "__brp_mangle_shebangs %{nil}" \
68 --define "__brp_strip_comment_note %{nil}" \
69 --define "__brp_strip_static_archive %{nil}" \
70 --define "__brp_check_rpaths %{nil}" \
71 --define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \
72 --define "__script_requires %{nil}" \
73 --undefine _lto_cflags \
f1884281 74 --noclean \
d6f206b9 75 "pkg/$ID/systemd.spec"
5524d283
DDM
76
77cp "$OUTPUTDIR"/*.rpm "$PACKAGEDIR"