Merge pull request #32302 from DaanDeMeyer/mkosi

Various mkosi improvements
This commit is contained in:
Daan De Meyer 2024-04-16 16:59:41 +02:00 committed by GitHub
commit d398a2e004
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 56 additions and 31 deletions

View file

@ -276,22 +276,9 @@ To simplify debugging systemd when testing changes using mkosi, we're going to s
QEMU.
To allow VSCode's debugger to attach to systemd running in a mkosi image, we have to make sure it can access
the virtual machine spawned by mkosi where systemd is running. mkosi makes this possible via a handy SSH
option that makes the generated image accessible via SSH when booted. Thus you must build the image with
`mkosi --ssh`. The easiest way to set the option is to create a file `mkosi.local.conf` in the root of the
repository and add the following contents:
```
[Host]
Ssh=yes
RuntimeTrees=.
```
Also make sure that the SSH agent is running on your system and that you've added your SSH key to it with
`ssh-add`. Also make sure that `virtiofsd` is installed.
After rebuilding the image and booting it with `mkosi qemu`, you should now be able to connect to it by
running `mkosi ssh` from the same directory in another terminal window.
the virtual machine spawned by mkosi where systemd is running. After booting the image with `mkosi qemu`, you
should now be able to connect to it by running `mkosi ssh` from the same directory in another terminal
window.
Now we need to configure VSCode. First, make sure the C/C++ extension is installed. If you're already using
a different extension for code completion and other IDE features for C in VSCode, make sure to disable the
@ -320,16 +307,12 @@ the directory, and add the following contents:
"name": "systemd",
"pipeTransport": {
"pipeProgram": "mkosi",
"pipeArgs": [
"-C",
"/path/to/systemd/repo/directory/on/host/system/",
"ssh"
],
"pipeArgs": ["-C", "${workspaceFolder}", "ssh"],
"debuggerPath": "/usr/bin/gdb"
},
"MIMode": "gdb",
"sourceFileMap": {
"/root/src/systemd": {
"/work/src": {
"editorPath": "${workspaceFolder}",
"useForBreakpoints": false
},

View file

@ -20,6 +20,7 @@ BuildSourcesEphemeral=yes
[Host]
@Incremental=yes
@RuntimeSize=8G
@RuntimeBuildSources=yes
ToolsTreePackages=virtiofsd
KernelCommandLineExtra=systemd.crash_shell
systemd.log_level=debug,console:info

View file

@ -40,6 +40,7 @@ Packages=
udev
util-linux
valgrind
which
wireguard-tools
xfsprogs
zsh

View file

@ -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.

View file

@ -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}" \
@ -48,6 +59,7 @@ rpmbuild \
--define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \
--define "__script_requires %{nil}" \
--undefine _lto_cflags \
--noclean \
"pkg/$ID/systemd.spec"
cp "$OUTPUTDIR"/*.rpm "$PACKAGEDIR"

View file

@ -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" \

View file

@ -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")" \
@ -49,6 +58,7 @@ build() {
--define "__os_install_post /usr/lib/rpm/brp-suse %{nil}" \
--define "__elf_exclude_path ^/usr/lib/systemd/tests/unit-tests/.*$" \
--define "__script_requires %{nil}" \
--noclean \
"$@" \
"pkg/$ID/systemd.spec"
}

View file

@ -1,3 +0,0 @@
set debuginfod enabled off
set build-id-verbose 0
set substitute-path ../src /root/src/systemd

View file

@ -1,4 +1,5 @@
#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1-or-later
mkdir -p "$BUILDROOT"/usr/share/factory/mkosi
cp --archive --recursive --no-target-directory --reflink=auto "$BUILDROOT"/etc "$BUILDROOT"/usr/share/factory/mkosi