]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Install build dependencies into final image
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 7 Apr 2024 18:23:56 +0000 (20:23 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 8 Apr 2024 09:36:40 +0000 (11:36 +0200)
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.

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

index 131f7d8e68e61b752203b6b723e28c06ae970131..9c2e152c3a78fdca66b5c9658182da3827609cf2 100644 (file)
@@ -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
index 24c91e5665f62d586b57b41b2ba0e348f2ca17c5..2a0ef359650a34cb9f920ef25aac4d8fff8ce530 100755 (executable)
@@ -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[@]}"
index 5bcb1ad481fefaf8065355033956b666f9f1e4f3..dd78f730eacd8b99ba6166948bacbcc5d79ecdc4 100755 (executable)
@@ -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.
index e2be181fe2bffbef96a56b42c47dea3541bb10f5..364f7b54ff11d757914ee73f0bcfdcb19030a1ad 100644 (file)
@@ -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
index ae0d6fd92ff5c9ed99e98d6d21f228a7f0080809..47e7f32789df322cfb68e863efd0fcc7127a7e86 100755 (executable)
@@ -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
 
index a35a8f3bba2a26adaa8f076dacf118bb62137fc2..42bf05677f65bb08a38abd2fa7f1b91a758a796f 100755 (executable)
@@ -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 \