diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-04-16 11:24:56 +0200 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-04-16 15:25:37 +0200 |
commit | 4980ae0fbc9dca90f8476950cdacd7bdcf3fefac (patch) | |
tree | cc9dd36745abdea9a38128fac7ee09916b57ab07 /mkosi.images/system | |
parent | mkosi: Add --noclean when running rpmbuild (diff) | |
download | systemd-4980ae0fbc9dca90f8476950cdacd7bdcf3fefac.tar.xz systemd-4980ae0fbc9dca90f8476950cdacd7bdcf3fefac.zip |
mkosi: Add support for building debug packages
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.
Diffstat (limited to 'mkosi.images/system')
4 files changed, 46 insertions, 6 deletions
diff --git a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.build.chroot b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.build.chroot index 807823205f..fb85580360 100755 --- a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.build.chroot +++ b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.build.chroot @@ -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. diff --git a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot index 371af8f4b9..e2d20d4b87 100755 --- a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot +++ b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.build.chroot @@ -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}" \ diff --git a/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot b/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot index a811ff05e4..3a89e49c5b 100755 --- a/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot +++ b/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.build.chroot @@ -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" \ diff --git a/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.build.chroot b/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.build.chroot index 5bc78aee3b..fe89611e36 100755 --- a/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.build.chroot +++ b/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.build.chroot @@ -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")" \ |