blob: 6d097791644cd2a93a1fe84eff308eabcd078900 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
# shellcheck source=/dev/null
. /usr/lib/os-release
ID="${ID%-*}"
if [ ! -f "pkg/$ID/systemd.spec" ]; then
echo "spec not found at pkg/$ID/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
exit 1
fi
if [ -d .git/ ] && [ -z "$(git status --porcelain)" ]; then
TS="$(git show --no-patch --format=%ct HEAD)"
else
TS="${SOURCE_DATE_EPOCH:-$(date +%s)}"
fi
# The openSUSE filelists hardcode the manpage compression extension. This causes rpmbuild errors since we
# disable manpage compression as the files cannot be found. Fix the issue by removing the compression
# extension.
find "pkg/$ID" -name "files.*" -exec sed --in-place 's/\.gz$//' {} \;
# Fix the %install override so debuginfo packages are generated.
tee --append /usr/lib/rpm/suse/macros <<'EOF'
%install %{debug_package}\
%%install\
%{nil}
EOF
VERSION="$(cat meson.version)"
RELEASE="$(date "+%Y%m%d%H%M%S" --date "@$TS")"
DIST="$(rpm --eval %dist)"
ARCH="$(rpm --eval %_arch)"
SRCDEST="/usr/src/debug/systemd-$VERSION-${RELEASE}${DIST}.$ARCH"
# TODO: Enable this when the opensuse spec stops unconditionally setting FORTIFY_SOURCE=2.
# EXTRA_CFLAGS="-O${OPTIMIZATION:-0} -Wp,-U_FORTIFY_SOURCE"
EXTRA_CFLAGS=""
if ((WITH_DEBUG)); then
EXTRA_CFLAGS="$EXTRA_CFLAGS -ffile-prefix-map=../src=$SRCDEST"
fi
build() {
IFS=
# TODO: Replace meson_build and meson_install overrides with "--undefine __meson_verbose" once
# https://github.com/mesonbuild/meson/pull/12835 is available.
# shellcheck disable=SC2046
rpmbuild \
-bb \
--build-in-place \
--with upstream \
$( ((WITH_TESTS)) || echo --nocheck) \
--define "_topdir /var/tmp" \
--define "_sourcedir pkg/$ID" \
--define "_rpmdir $OUTPUTDIR" \
${BUILDDIR:+--define} \
${BUILDDIR:+"_vpath_builddir $BUILDDIR"} \
--define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
--define "_binary_payload w.ufdio" \
$( ((WITH_DEBUG)) || echo --define) \
$( ((WITH_DEBUG)) || echo "debug_package %{nil}") \
--define "vendor openSUSE" \
--define "version_override $VERSION" \
--define "release_override $RELEASE" \
--define "__check_files sh -c '$(rpm --eval %__check_files) | tee /tmp/unpackaged-files'" \
--define "build_cflags $(rpm --eval %build_cflags) $EXTRA_CFLAGS" \
--define "meson_build %{shrink:%{__meson} compile -C %{_vpath_builddir} -j %{_smp_build_ncpus} %{nil}}" \
--define "meson_install %{shrink:DESTDIR=%{buildroot} %{__meson} install -C %{_vpath_builddir} --no-rebuild --quiet %{nil}}" \
--define "meson_extra_configure_options -D mode=developer -D b_sanitize=${SANITIZERS:-none}" \
--define "__os_install_post /usr/lib/rpm/brp-suse %{nil}" \
--define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \
--define "__script_requires %{nil}" \
--define "_find_debuginfo_dwz_opts %{nil}" \
--noclean \
"$@" \
"pkg/$ID/systemd.spec"
}
if ! build; then
if [ ! -s /tmp/unpackaged-files ]; then
exit 1
fi
# rpm will append to any existing systemd.lang so delete it explicitly so we don't get duplicate file
# warnings.
rm systemd.lang
cat /tmp/unpackaged-files >>"pkg/$ID/files.systemd"
build --noprep --nocheck
fi
cp "$OUTPUTDIR"/*.rpm "$PACKAGEDIR"
|