1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-02 13:47:27 +03:00

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.
This commit is contained in:
Daan De Meyer 2024-04-07 20:23:56 +02:00
parent 8826953547
commit 8440ea8f21
6 changed files with 57 additions and 67 deletions

View File

@ -20,8 +20,10 @@ Packages=
cryptsetup cryptsetup
dbus-broker dbus-broker
dbus-broker-units dbus-broker-units
debugedit
dhcp dhcp
f2fs-tools f2fs-tools
fakeroot
git git
gnutls gnutls
iproute iproute
@ -31,6 +33,7 @@ Packages=
openssh openssh
openssl openssl
pacman pacman
pkgconf
polkit polkit
quota-tools quota-tools
sbsigntools sbsigntools
@ -41,8 +44,3 @@ Packages=
InitrdPackages= InitrdPackages=
btrfs-progs btrfs-progs
tpm2-tools tpm2-tools
BuildPackages=
fakeroot
pkgconf
debugedit

View File

@ -2,23 +2,25 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
set -e set -e
if [ "$1" = "build" ]; then
exit 0
fi
if [ ! -f "pkg/$PKG_SUBDIR/PKGBUILD" ]; then 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 echo "PKGBUILD not found at pkg/$PKG_SUBDIR/PKGBUILD, run mkosi once with -ff to make sure the PKGBUILD is cloned" >&2
exit 1 exit 1
fi fi
if [ "$1" = "final" ]; then # We get depends and optdepends from .SRCINFO as getting them from the PKGBUILD is rather complex.
# We get depends and optdepends from .SRCINFO as getting them from the PKGBUILD is rather complex. sed --expression 's/^[ \t]*//' "pkg/$PKG_SUBDIR/.SRCINFO" |
sed --expression 's/^[ \t]*//' "pkg/$PKG_SUBDIR/.SRCINFO" | grep --regexp '^depends =' --regexp '^optdepends =' |
grep --regexp '^depends =' --regexp '^optdepends =' | sed --expression 's/^depends = //' --expression 's/^optdepends = //' --expression 's/:.*//' |
sed --expression 's/^depends = //' --expression 's/^optdepends = //' --expression 's/:.*//' | xargs --delimiter '\n' mkosi-install
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"
# shellcheck disable=SC2154 # We get makedepends from the PKGBUILD as .SRCINFO can't encode conditional dependencies depending on
mkosi-install "${makedepends[@]}" # whether some environment variable is set or not.
fi # shellcheck source=/dev/null
UPSTREAM=1 . "pkg/$PKG_SUBDIR/PKGBUILD"
# shellcheck disable=SC2154
mkosi-install "${makedepends[@]}"

View File

@ -2,33 +2,29 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
set -e set -e
if [ "$1" = "build" ]; then
exit 0
fi
if [ ! -f "pkg/$PKG_SUBDIR/systemd.spec" ]; then 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 echo "spec not found at pkg/$PKG_SUBDIR/systemd.spec, run mkosi with -ff to make sure the spec is cloned" >&2
exit 1 exit 1
fi fi
if [ "$1" = "final" ]; then for DEPS in --requires --buildrequires; do
DEPS="--requires" mkosi-chroot \
else rpmspec \
DEPS="--buildrequires" --with upstream \
fi --query \
"$DEPS" \
mkosi-chroot \ --define "_topdir /var/tmp" \
rpmspec \ --define "_sourcedir pkg/$PKG_SUBDIR" \
--with upstream \ "pkg/$PKG_SUBDIR/systemd.spec" |
--query \ grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev |
"$DEPS" \ sort --unique |
--define "_topdir /var/tmp" \ tee /tmp/buildrequires |
--define "_sourcedir pkg/$PKG_SUBDIR" \ xargs --delimiter '\n' mkosi-install
"pkg/$PKG_SUBDIR/systemd.spec" | done
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
# rpmbuild -br tries to build a source package which means all source files have to exist which isn't the # 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. # case when using --build-in-place so we get rid of the source file that doesn't exist to make it happy.

View File

@ -36,6 +36,7 @@ Packages=
dbus-broker dbus-broker
dbus-user-session dbus-user-session
dmsetup dmsetup
dpkg-dev
f2fs-tools f2fs-tools
fdisk fdisk
git-core git-core
@ -59,6 +60,3 @@ Packages=
InitrdPackages= InitrdPackages=
btrfs-progs btrfs-progs
tpm2-tools tpm2-tools
BuildPackages=
dpkg-dev

View File

@ -2,7 +2,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
set -e set -e
if [ "$1" = "final" ]; then if [ "$1" = "build" ]; then
exit 0 exit 0
fi fi

View File

@ -2,33 +2,29 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
set -e set -e
if [ "$1" = "build" ]; then
exit 0
fi
if [ ! -f "pkg/$PKG_SUBDIR/systemd.spec" ]; then 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 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 exit 1
fi fi
if [ "$1" = "final" ]; then for DEPS in --requires --buildrequires; do
DEPS="--requires" mkosi-chroot \
else rpmspec \
DEPS="--buildrequires" --with upstream \
fi --query \
"$DEPS" \
mkosi-chroot \ --define "_topdir /var/tmp" \
rpmspec \ --define "_sourcedir pkg/$PKG_SUBDIR" \
--with upstream \ "pkg/$PKG_SUBDIR/systemd.spec" |
--query \ grep --invert-match --regexp systemd --regexp /bin/sh --regexp "rpmlib(" --regexp udev |
"$DEPS" \ sort --unique |
--define "_topdir /var/tmp" \ tee /tmp/buildrequires |
--define "_sourcedir pkg/$PKG_SUBDIR" \ xargs --delimiter '\n' mkosi-install
"pkg/$PKG_SUBDIR/systemd.spec" | done
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
until mkosi-chroot \ until mkosi-chroot \
rpmbuild \ rpmbuild \