summaryrefslogtreecommitdiffstats
path: root/mkosi.conf.d/10-opensuse/mkosi.prepare
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2024-07-12 15:33:49 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2024-07-15 16:17:33 +0200
commit7205fc7dc31eb2be3075ee6ba23ebe84324aa5cb (patch)
tree4425e2413d76af1504d5f8666648a9667f0e4eb6 /mkosi.conf.d/10-opensuse/mkosi.prepare
parentmkosi: update fedora commit reference (diff)
downloadsystemd-7205fc7dc31eb2be3075ee6ba23ebe84324aa5cb.tar.xz
systemd-7205fc7dc31eb2be3075ee6ba23ebe84324aa5cb.zip
mkosi: Introduce build image
We want the exitrd image to be built with the latest systemd as well. As the exitrd image is built as part of mkosi.images, and all subimages are built before the main image, this implies the packages must be built as a subimage in mkosi.images/ as well. So we introduce the build image and move all logic related to building distribution packages there. This also has the nice side effect of slimming down the main image as the build dependencies are not installed into the main image anymore. It also makes sure the packages are built in a "clean" chroot without any of the other packages which we install in the main image available.
Diffstat (limited to 'mkosi.conf.d/10-opensuse/mkosi.prepare')
-rwxr-xr-xmkosi.conf.d/10-opensuse/mkosi.prepare73
1 files changed, 16 insertions, 57 deletions
diff --git a/mkosi.conf.d/10-opensuse/mkosi.prepare b/mkosi.conf.d/10-opensuse/mkosi.prepare
index c57aa878b8..6ee0af2de9 100755
--- a/mkosi.conf.d/10-opensuse/mkosi.prepare
+++ b/mkosi.conf.d/10-opensuse/mkosi.prepare
@@ -2,63 +2,22 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
-if [ "$1" = "build" ] || ((NO_BUILD)); then
+if [[ "$1" == "build" ]]; then
exit 0
fi
-# shellcheck source=/dev/null
-. "$BUILDROOT/usr/lib/os-release"
-ID="${ID%-*}"
-
-if [ ! -f "pkg/$ID/systemd.spec" ]; then
- echo "spec not found at pkg/$ID/systemd.spec, run mkosi once with -ff to make sure the spec is cloned" >&2
- exit 1
-fi
-
-# TODO: Drop when the spec is fixed (either the patch is adapted or not applied when building for upstream).
-sed --in-place '/0009-pid1-handle-console-specificities-weirdness-for-s390.patch/d' "pkg/$ID/systemd.spec"
-
-for DEPS in --requires --buildrequires; do
- mkosi-chroot \
- rpmspec \
- --with upstream \
- --query \
- "$DEPS" \
- --define "_topdir /var/tmp" \
- --define "_sourcedir pkg/$ID" \
- "pkg/$ID/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 \
- -bd \
- --build-in-place \
- --with upstream \
- --define "_topdir /var/tmp" \
- --define "_sourcedir pkg/$ID" \
- --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
- "pkg/$ID/systemd.spec"
-do
- EXIT_STATUS=$?
- if [ $EXIT_STATUS -ne 11 ]; then
- exit $EXIT_STATUS
- fi
-
- mkosi-chroot \
- rpm \
- --query \
- --package \
- --requires \
- /var/tmp/SRPMS/systemd-*.buildreqs.nosrc.rpm |
- grep --invert-match '^rpmlib(' |
- sort --unique >/tmp/dynamic-buildrequires
-
- sort /tmp/buildrequires /tmp/dynamic-buildrequires |
- uniq --unique |
- tee --append /tmp/buildrequires |
- xargs --delimiter '\n' mkosi-install
-done
+DEPS=""
+
+while read -r PACKAGE; do
+ # zypper's output is not machine readable so we make do with sed instead.
+ DEPS="$DEPS\n$(
+ zypper info --requires --recommends --suggests "$PACKAGE" |
+ sed '/Requires/,$!d' | # Remove everything before Requires line
+ sed --quiet 's/^ //p' # All indented lines have dependencies
+ )"
+done < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG")
+
+echo -e "$DEPS" |
+ grep --invert-match --regexp systemd --regexp udev --regexp qemu |
+ sort --unique |
+ xargs --delimiter '\n' --no-run-if-empty mkosi-install