diff --git a/docs/HACKING.md b/docs/HACKING.md index 2a58780fbf..569f81ab0b 100644 --- a/docs/HACKING.md +++ b/docs/HACKING.md @@ -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 }, diff --git a/mkosi.conf b/mkosi.conf index 96843db488..ee7fa6e2a4 100644 --- a/mkosi.conf +++ b/mkosi.conf @@ -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 diff --git a/mkosi.images/system/mkosi.conf b/mkosi.images/system/mkosi.conf index 303af4acb1..ed09d841b8 100644 --- a/mkosi.images/system/mkosi.conf +++ b/mkosi.images/system/mkosi.conf @@ -40,6 +40,7 @@ Packages= udev util-linux valgrind + which wireguard-tools xfsprogs zsh 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 <>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 62b329998d..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")" \ @@ -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" } diff --git a/mkosi.images/system/mkosi.extra/usr/share/factory/mkosi/gdbinit.d/systemd.gdb b/mkosi.images/system/mkosi.extra/usr/share/factory/mkosi/gdbinit.d/systemd.gdb deleted file mode 100644 index 26f882bc2b..0000000000 --- a/mkosi.images/system/mkosi.extra/usr/share/factory/mkosi/gdbinit.d/systemd.gdb +++ /dev/null @@ -1,3 +0,0 @@ -set debuginfod enabled off -set build-id-verbose 0 -set substitute-path ../src /root/src/systemd diff --git a/mkosi.images/system/mkosi.finalize b/mkosi.images/system/mkosi.finalize index 74b810c152..6da35e5138 100755 --- a/mkosi.images/system/mkosi.finalize +++ b/mkosi.images/system/mkosi.finalize @@ -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