]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: Set up -ffile-prefix-map= correctly when building debuginfo packages
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 17 Apr 2024 12:55:08 +0000 (14:55 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 17 Apr 2024 13:21:01 +0000 (15:21 +0200)
This makes sure that the debuginfo files contain source files pointing
to the source files shipped by the debugsource package.

Normally this should be done automatically by rpm invoking debugedit
but for some unknown reason debugedit refuses to rewrite the source
files in our binaries.

Given that debugedit is completely undebugable (does not generate any
logs at all, and its source code is ridiculously obtuse), let's set
-ffile-prefix-map= when building instead which achieves the same
effect.

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

index e2d20d4b87ee84981a11a251662ae4fb6b0fabea..bb6854c38fb02c7f9f93bd28a400e6d1eafca9f4 100755 (executable)
@@ -24,6 +24,18 @@ tee --append /usr/lib/rpm/redhat/macros <<'EOF'
 %{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"
+
+EXTRA_CFLAGS="-Og"
+if ((WITH_DEBUG)); then
+    EXTRA_CFLAGS="$EXTRA_CFLAGS -ffile-prefix-map=../src=$SRCDEST"
+fi
+
 IFS=
 # TODO: Replace meson_build and meson_install overrides with "--undefine __meson_verbose" once
 # https://github.com/mesonbuild/meson/pull/12835 is available.
@@ -43,9 +55,9 @@ rpmbuild \
     --define "_binary_payload w.ufdio" \
     $( ((WITH_DEBUG)) || echo --define) \
     $( ((WITH_DEBUG)) || echo "debug_package %{nil}") \
-    --define "version_override $(cat meson.version)" \
-    --define "release_override $(date "+%Y%m%d%H%M%S" --date "@$TS")" \
-    --define "_distro_extra_cflags -Og" \
+    --define "version_override $VERSION" \
+    --define "release_override $RELEASE" \
+    --define "_distro_extra_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}" \