]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: Add support for building debug packages 32302/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 16 Apr 2024 09:24:56 +0000 (11:24 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 16 Apr 2024 13:25:37 +0000 (15:25 +0200)
This allows building debug packages by setting WITH_DEBUG=1. This
slows down the build a lot so it's opt in. We don't yet install
these but can do so in a future commit.

mkosi.images/system/mkosi.conf.d/10-arch/mkosi.build.chroot
mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot
mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot
mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.build.chroot

index 807823205f16daa1da2542a3c89d45db8ffab734..fb8558036023efdf7f23d1a4d0866eece81affca 100755 (executable)
@@ -26,7 +26,17 @@ mount --mkdir --rbind "$PWD/pkg/$ID" "pkg/$ID/src/"
 # tmpfs during the build script so these changes don't end up in the image itself.
 tee --append /etc/makepkg.conf >/dev/null <<EOF
 CFLAGS="$CFLAGS -Og"
-OPTIONS=(!strip docs !libtool !staticlibs emptydirs !zipman purge !debug !lto)
+OPTIONS=(
+    docs
+    !libtool
+    !staticlibs
+    emptydirs
+    !zipman
+    purge
+    $( ((WITH_DEBUG)) && echo strip || echo !strip)
+    $( ((WITH_DEBUG)) && echo debug || echo !debug)
+    !lto
+)
 EOF
 
 # Linting the PKGBUILD takes multiple seconds every build so avoid that by nuking all the linting functions.
index 371af8f4b9fc85d28d64cfd03ae14bee76ab73fe..e2d20d4b87ee84981a11a251662ae4fb6b0fabea 100755 (executable)
@@ -16,6 +16,15 @@ else
     TS="${SOURCE_DATE_EPOCH:-$(date +%s)}"
 fi
 
+# Fix the %install override so debuginfo packages are generated even when --build-in-place is used.
+# See https://github.com/rpm-software-management/rpm/issues/3042.
+tee --append /usr/lib/rpm/redhat/macros <<'EOF'
+%install %{?_enable_debug_packages:%{debug_package}}\
+%%install\
+%{nil}
+EOF
+
+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
@@ -32,14 +41,16 @@ rpmbuild \
     ${BUILDDIR:+"_vpath_builddir $BUILDDIR"} \
     --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
     --define "_binary_payload w.ufdio" \
-    --define "debug_package %{nil}" \
+    $( ((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 "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 "__brp_strip %{nil}" \
+    $( ((WITH_DEBUG)) || echo --define) \
+    $( ((WITH_DEBUG)) || echo "__brp_strip %{nil}") \
     --define "__brp_compress %{nil}" \
     --define "__brp_mangle_shebangs %{nil}" \
     --define "__brp_strip_comment_note %{nil}" \
index a811ff05e4b7e73d099667827e5528eb2acc6624..3a89e49c5bb0dfe3190a0527edede831a365342b 100755 (executable)
@@ -42,8 +42,18 @@ cat debian/changelog >>debian/changelog.new
 mv debian/changelog.new debian/changelog
 
 build() {
-    DEB_BUILD_OPTIONS="$( ((WITH_TESTS)) || echo nocheck) $( ((WITH_DOCS)) || echo nodoc) nostrip terse optimize=-lto" \
-    DEB_BUILD_PROFILES="$( ((WITH_TESTS)) || echo nocheck) $( ((WITH_DOCS)) || echo nodoc) pkg.systemd.upstream" \
+    DEB_BUILD_OPTIONS="\
+        $( ((WITH_TESTS)) || echo nocheck) \
+        $( ((WITH_DOCS)) || echo nodoc) \
+        $( ((WITH_DEBUG)) || echo nostrip) \
+        terse
+        optimize=-lto \
+    " \
+    DEB_BUILD_PROFILES="\
+        $( ((WITH_TESTS)) || echo nocheck) \
+        $( ((WITH_DOCS)) || echo nodoc) \
+        pkg.systemd.upstream \
+    " \
     DEB_CFLAGS_APPEND="-Og" \
     DPKG_FORCE="unsafe-io" \
     DPKG_DEB_COMPRESSOR_TYPE="none" \
index 5bc78aee3bf7faa45dcf46be04a657d78e516514..fe89611e36ed90ac13da0fbe1ba0b32ad357d82f 100755 (executable)
@@ -22,7 +22,15 @@ fi
 # 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
+
 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
@@ -38,7 +46,8 @@ build() {
         ${BUILDDIR:+"_vpath_builddir $BUILDDIR"} \
         --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
         --define "_binary_payload w.ufdio" \
-        --define "debug_package %{nil}" \
+        $( ((WITH_DEBUG)) || echo --define) \
+        $( ((WITH_DEBUG)) || echo "debug_package %{nil}") \
         --define "vendor openSUSE" \
         --define "version_override $(cat meson.version)" \
         --define "release_override $(date "+%Y%m%d%H%M%S" --date "@$TS")" \