Debian Codegraph @

mkosi/mkosi.images/build/mkosi.conf.d/centos-fedora/mkosi.build.chroot

raw
1 #!/usr/bin/env bash
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3 set -e
4
5 if [[ "$1" == "clangd" ]]; then
6 exit 0
7 fi
8
9 if [[ ! -f "pkg/$PKG_SUBDIR/systemd.spec" ]]; then
10 echo "spec not found at pkg/$PKG_SUBDIR/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
11 exit 1
12 fi
13
14 . mkosi/mkosi.functions
15
16 TS="${SOURCE_DATE_EPOCH:-$(date +%s)}"
17
18 if [[ "$(rpm --eval "%{lua:print(rpm.vercmp('$(rpm --version | cut -d ' ' -f3)', '4.19.91'))}")" == "-1" ]]; then
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.
21 tee --append /usr/lib/rpm/redhat/macros <<'EOF'
22 %install %{?_enable_debug_packages:%{debug_package}}\
23 %%install\
24 %{nil}
25 EOF
26 fi
27
28 VERSION="$(cat meson.version)"
29 RELEASE="$(date "+%Y%m%d%H%M%S" --date "@$TS")"
30
31 COMMON_MACRO_OVERRIDES=(
32 --define "toolchain $( ((LLVM)) && echo clang || echo gcc)"
33 --define "_fortify_level 0"
34 --undefine _lto_cflags
35 # TODO: Remove once redhat-rpm-config 292 is available everywhere.
36 --define "_hardening_clang_cflags --config=/usr/lib/rpm/redhat/redhat-hardened-clang.cfg"
37 --define "_hardening_clang_ldflags --config=/usr/lib/rpm/redhat/redhat-hardened-clang-ld.cfg"
38 )
39
40 # TODO: Drop -U_FORTIFY_SOURCE when we switch to CentOS Stream 10.
41 MKOSI_CFLAGS="$MKOSI_CFLAGS -Wp,-U_FORTIFY_SOURCE"
42 if ((WITH_DEBUG)); then
43 MKOSI_CFLAGS="$MKOSI_CFLAGS -fdebug-prefix-map=../src=/usr/src/debug/systemd"
44 fi
45
46 (
47 shopt -s nullglob
48 rm -f "$BUILDDIR"/*.rpm
49 )
50
51 IFS=
52 # TODO: Replace meson_build and meson_install overrides with "--undefine __meson_verbose" once
53 # https://github.com/mesonbuild/meson/pull/12835 is available.
54 # shellcheck disable=SC2046
55 env \
56 --unset=CFLAGS \
57 --unset=CXXFLAGS \
58 --unset=LDFLAGS \
59 ANNOBIN="no-active-checks" \
60 CC_LD="$( ((LLVM)) && echo lld)" \
61 CXX_LD="$( ((LLVM)) && echo lld)" \
62 rpmbuild \
63 -bb \
64 --noprep \
65 --build-in-place \
66 --with upstream \
67 --without lto \
68 $( ((WITH_TESTS)) || echo "--nocheck") \
69 $( ((WITH_DOCS)) || echo "--without=docs") \
70 --define "_topdir /var/tmp" \
71 --define "_sourcedir $PWD/pkg/$PKG_SUBDIR" \
72 --define "_rpmdir $BUILDDIR" \
73 ${BUILDDIR:+"--define=_vpath_builddir $BUILDDIR"} \
74 --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
75 --define "_binary_payload w.ufdio" \
76 $( ((WITH_DEBUG)) || echo "--define=debug_package %{nil}") \
77 --define "version_override $VERSION" \
78 --define "release_override $RELEASE" \
79 "${COMMON_MACRO_OVERRIDES[@]}" \
80 --define "build_cflags $(rpm "${COMMON_MACRO_OVERRIDES[@]}" --eval "%{?build_cflags}") $MKOSI_CFLAGS $CFLAGS" \
81 --define "build_cxxflags $(rpm "${COMMON_MACRO_OVERRIDES[@]}" --eval "%{?build_cxxflags}") $MKOSI_CFLAGS $CFLAGS" \
82 --define "build_ldflags $(rpm "${COMMON_MACRO_OVERRIDES[@]}" --eval "%{?build_ldflags}") $MKOSI_LDFLAGS $LDFLAGS" \
83 --define "meson_build %{shrink:%{__meson} compile -C %{_vpath_builddir} -j %{_smp_build_ncpus} $( ((MESON_VERBOSE)) && echo --verbose) %{nil}}" \
84 --define "meson_install %{shrink:DESTDIR=%{buildroot} %{__meson} install -C %{_vpath_builddir} --no-rebuild --quiet %{nil}}" \
85 --define "meson_extra_configure_options $MKOSI_MESON_OPTIONS $MESON_OPTIONS" \
86 $( ((WITH_DEBUG)) || echo "--define=__brp_strip %{nil}") \
87 --define "__brp_compress %{nil}" \
88 --define "__brp_mangle_shebangs %{nil}" \
89 --define "__brp_strip_comment_note %{nil}" \
90 --define "__brp_strip_static_archive %{nil}" \
91 --define "__brp_check_rpaths %{nil}" \
92 --define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \
93 --define "__script_requires %{nil}" \
94 --define "_find_debuginfo_opts --unique-debug-src-base \"%{name}\"" \
95 --define "_find_debuginfo_dwz_opts %{nil}" \
96 --undefine _package_note_flags \
97 "pkg/$PKG_SUBDIR/systemd.spec"
98
99 cp "$BUILDDIR"/*.rpm "$PACKAGEDIR"
100
101 make_sysext_unsigned /var/tmp/BUILD/*/BUILDROOT