From 8440ea8f21e1f979c704818a6ccea3ca48803b5d Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 7 Apr 2024 20:23:56 +0200 Subject: [PATCH 1/3] Install build dependencies into final image This allows us to build and install after booting without having to build a new image. Together with https://github.com/systemd/mkosi/pull/2601 and after enabling RuntimeBuildSources=yes, after booting, "meson install -C /work/build" can be used to do an incremental build and install. This won't build proper packages, but will be invaluable for having a quick compile, edit, test cycle without having to rebuild the image all the time. --- .../system/mkosi.conf.d/10-arch/mkosi.conf | 8 ++-- .../system/mkosi.conf.d/10-arch/mkosi.prepare | 30 +++++++------- .../10-centos-fedora/mkosi.prepare | 40 +++++++++---------- .../mkosi.conf.d/10-debian-ubuntu/mkosi.conf | 4 +- .../10-debian-ubuntu/mkosi.prepare | 2 +- .../mkosi.conf.d/10-opensuse/mkosi.prepare | 40 +++++++++---------- 6 files changed, 57 insertions(+), 67 deletions(-) diff --git a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf index 131f7d8e68..9c2e152c3a 100644 --- a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf @@ -20,8 +20,10 @@ Packages= cryptsetup dbus-broker dbus-broker-units + debugedit dhcp f2fs-tools + fakeroot git gnutls iproute @@ -31,6 +33,7 @@ Packages= openssh openssl pacman + pkgconf polkit quota-tools sbsigntools @@ -41,8 +44,3 @@ Packages= InitrdPackages= btrfs-progs tpm2-tools - -BuildPackages= - fakeroot - pkgconf - debugedit diff --git a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.prepare b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.prepare index 24c91e5665..2a0ef35965 100755 --- a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.prepare +++ b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.prepare @@ -2,23 +2,25 @@ # SPDX-License-Identifier: LGPL-2.1-or-later set -e +if [ "$1" = "build" ]; then + exit 0 +fi + if [ ! -f "pkg/$PKG_SUBDIR/PKGBUILD" ]; then echo "PKGBUILD not found at pkg/$PKG_SUBDIR/PKGBUILD, run mkosi once with -ff to make sure the PKGBUILD is cloned" >&2 exit 1 fi -if [ "$1" = "final" ]; then - # We get depends and optdepends from .SRCINFO as getting them from the PKGBUILD is rather complex. - sed --expression 's/^[ \t]*//' "pkg/$PKG_SUBDIR/.SRCINFO" | - grep --regexp '^depends =' --regexp '^optdepends =' | - sed --expression 's/^depends = //' --expression 's/^optdepends = //' --expression 's/:.*//' | - xargs --delimiter '\n' mkosi-install -else - # We get makedepends from the PKGBUILD as .SRCINFO can't encode conditional dependencies depending on - # whether some environment variable is set or not. - # shellcheck source=/dev/null - UPSTREAM=1 . "pkg/$PKG_SUBDIR/PKGBUILD" +# We get depends and optdepends from .SRCINFO as getting them from the PKGBUILD is rather complex. +sed --expression 's/^[ \t]*//' "pkg/$PKG_SUBDIR/.SRCINFO" | + grep --regexp '^depends =' --regexp '^optdepends =' | + sed --expression 's/^depends = //' --expression 's/^optdepends = //' --expression 's/:.*//' | + xargs --delimiter '\n' mkosi-install - # shellcheck disable=SC2154 - mkosi-install "${makedepends[@]}" -fi +# We get makedepends from the PKGBUILD as .SRCINFO can't encode conditional dependencies depending on +# whether some environment variable is set or not. +# shellcheck source=/dev/null +UPSTREAM=1 . "pkg/$PKG_SUBDIR/PKGBUILD" + +# shellcheck disable=SC2154 +mkosi-install "${makedepends[@]}" diff --git a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.prepare b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.prepare index 5bcb1ad481..dd78f730ea 100755 --- a/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.prepare +++ b/mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.prepare @@ -2,33 +2,29 @@ # SPDX-License-Identifier: LGPL-2.1-or-later set -e +if [ "$1" = "build" ]; then + exit 0 +fi + if [ ! -f "pkg/$PKG_SUBDIR/systemd.spec" ]; then echo "spec not found at pkg/$PKG_SUBDIR/systemd.spec, run mkosi with -ff to make sure the spec is cloned" >&2 exit 1 fi -if [ "$1" = "final" ]; then - DEPS="--requires" -else - DEPS="--buildrequires" -fi - -mkosi-chroot \ - rpmspec \ - --with upstream \ - --query \ - "$DEPS" \ - --define "_topdir /var/tmp" \ - --define "_sourcedir pkg/$PKG_SUBDIR" \ - "pkg/$PKG_SUBDIR/systemd.spec" | - grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev | - sort --unique | - tee /tmp/buildrequires | - xargs --delimiter '\n' mkosi-install - -if [ "$1" = "final" ]; then - exit 0 -fi +for DEPS in --requires --buildrequires; do + mkosi-chroot \ + rpmspec \ + --with upstream \ + --query \ + "$DEPS" \ + --define "_topdir /var/tmp" \ + --define "_sourcedir pkg/$PKG_SUBDIR" \ + "pkg/$PKG_SUBDIR/systemd.spec" | + grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev | + sort --unique | + tee /tmp/buildrequires | + xargs --delimiter '\n' mkosi-install +done # rpmbuild -br tries to build a source package which means all source files have to exist which isn't the # case when using --build-in-place so we get rid of the source file that doesn't exist to make it happy. diff --git a/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf b/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf index e2be181fe2..364f7b54ff 100644 --- a/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf +++ b/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf @@ -36,6 +36,7 @@ Packages= dbus-broker dbus-user-session dmsetup + dpkg-dev f2fs-tools fdisk git-core @@ -59,6 +60,3 @@ Packages= InitrdPackages= btrfs-progs tpm2-tools - -BuildPackages= - dpkg-dev diff --git a/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare b/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare index ae0d6fd92f..47e7f32789 100755 --- a/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare +++ b/mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare @@ -2,7 +2,7 @@ # SPDX-License-Identifier: LGPL-2.1-or-later set -e -if [ "$1" = "final" ]; then +if [ "$1" = "build" ]; then exit 0 fi diff --git a/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.prepare b/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.prepare index a35a8f3bba..42bf05677f 100755 --- a/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.prepare +++ b/mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.prepare @@ -2,33 +2,29 @@ # SPDX-License-Identifier: LGPL-2.1-or-later set -e +if [ "$1" = "build" ]; then + exit 0 +fi + if [ ! -f "pkg/$PKG_SUBDIR/systemd.spec" ]; then echo "spec not found at pkg/$PKG_SUBDIR/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2 exit 1 fi -if [ "$1" = "final" ]; then - DEPS="--requires" -else - DEPS="--buildrequires" -fi - -mkosi-chroot \ - rpmspec \ - --with upstream \ - --query \ - "$DEPS" \ - --define "_topdir /var/tmp" \ - --define "_sourcedir pkg/$PKG_SUBDIR" \ - "pkg/$PKG_SUBDIR/systemd.spec" | - grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev | - sort --unique | - tee /tmp/buildrequires | - xargs --delimiter '\n' mkosi-install - -if [ "$1" = "final" ]; then - exit 0 -fi +for DEPS in --requires --buildrequires; do + mkosi-chroot \ + rpmspec \ + --with upstream \ + --query \ + "$DEPS" \ + --define "_topdir /var/tmp" \ + --define "_sourcedir pkg/$PKG_SUBDIR" \ + "pkg/$PKG_SUBDIR/systemd.spec" | + grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev | + sort --unique | + tee /tmp/buildrequires | + xargs --delimiter '\n' mkosi-install +done until mkosi-chroot \ rpmbuild \ From da38f93bd6e5a6afa11c895c262a0dfc0bac0363 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 8 Apr 2024 11:35:38 +0200 Subject: [PATCH 2/3] mkosi: Fix environment variable in arch prepare script --- mkosi.images/system/mkosi.conf.d/10-arch/mkosi.prepare | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.prepare b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.prepare index 2a0ef35965..dd4ac96cb9 100755 --- a/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.prepare +++ b/mkosi.images/system/mkosi.conf.d/10-arch/mkosi.prepare @@ -20,7 +20,7 @@ sed --expression 's/^[ \t]*//' "pkg/$PKG_SUBDIR/.SRCINFO" | # We get makedepends from the PKGBUILD as .SRCINFO can't encode conditional dependencies depending on # whether some environment variable is set or not. # shellcheck source=/dev/null -UPSTREAM=1 . "pkg/$PKG_SUBDIR/PKGBUILD" +_systemd_UPSTREAM=1 . "pkg/$PKG_SUBDIR/PKGBUILD" # shellcheck disable=SC2154 mkosi-install "${makedepends[@]}" From 44b6e43e8d252ab495ddb6dc13ae46dd5688a3f0 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 8 Apr 2024 11:36:59 +0200 Subject: [PATCH 3/3] mkosi: Update submodules to latest --- pkg/centos | 2 +- pkg/fedora | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/centos b/pkg/centos index eef64f0d4d..282d1f30a6 160000 --- a/pkg/centos +++ b/pkg/centos @@ -1 +1 @@ -Subproject commit eef64f0d4ddca0f151a9680660a9ba97604e0e88 +Subproject commit 282d1f30a64204630e96bcf048597f6afbe4a8bf diff --git a/pkg/fedora b/pkg/fedora index 976e1b0a68..2822a03dde 160000 --- a/pkg/fedora +++ b/pkg/fedora @@ -1 +1 @@ -Subproject commit 976e1b0a6828cdc1ec6f3d227009dff5edfa744b +Subproject commit 2822a03dded26b9453bddbba7c6a152de8204aec