summaryrefslogtreecommitdiffstats
path: root/mkosi.conf.d
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2024-09-03 15:18:49 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2024-09-03 16:03:27 +0200
commit89c579788d1f864778c4d6f47b30bf37d04c4947 (patch)
treea74931d9709b81d771d78c9b458b2538a3a8357a /mkosi.conf.d
parentmkosi: Make systemd package filtering more robust (diff)
downloadsystemd-89c579788d1f864778c4d6f47b30bf37d04c4947.tar.xz
systemd-89c579788d1f864778c4d6f47b30bf37d04c4947.zip
mkosi: Use apt patterns to install dependencies on Debian/Ubuntu
Instead of parsing the human readable output of apt-cache, let's use apt patterns to figure out the dependencies. We also filter out virtual packages as apt will fail and say we need to install an implementation of the virtual package even if a package that provides the virtual package is already installed.
Diffstat (limited to 'mkosi.conf.d')
-rwxr-xr-xmkosi.conf.d/10-debian-ubuntu/mkosi.prepare27
1 files changed, 20 insertions, 7 deletions
diff --git a/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare b/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare
index ffff10d2a4..bf2c5eb91f 100755
--- a/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare
+++ b/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare
@@ -8,10 +8,23 @@ fi
mapfile -t PACKAGES < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG")
-apt-cache depends "${PACKAGES[@]}" |
- grep --invert-match --regexp "<" --regexp "|" | # Remove e.g. <python3:any> and |dbus-broker like results
- grep --extended-regexp --invert-match --regexp "$(IFS=\| ; echo "${PACKAGES[*]}")" |
- grep --extended-regexp "Depends|Suggests|Recommends" |
- sed --quiet 's/.*: //p' | # Get every line with ": " in it and strip it at the same time.
- sort --unique |
- xargs --delimiter '\n' --no-run-if-empty mkosi-install
+PATTERNS=()
+
+# The ?reverse-depends() pattern for some weird reason lists all the packages providing systemd-sysusers
+# instead of just excluding it, so we add another pattern to filter out anything that conflicts with
+# any other systemd packages so we filter out both opensysusers and systemd-sysusers-standalone. We also
+# exclude packages that belong to the systemd source package as we'll install these later. Finally, we
+# exclude virtual packages as trying to install these makes apt fail with an error saying we need to install
+# a specific implementation even if one is already installed.
+COMMON="?not(?virtual), ?not(?reverse-conflicts(?source-package(^systemd$))), ?not(?reverse-breaks(?source-package(^systemd$))), ?not(?source-package(^systemd$))"
+
+for PACKAGE in "${PACKAGES[@]}"; do
+ # Get all the dependencies of the systemd packages including recommended and suggested dependencies.
+ PATTERNS+=(
+ "?and(?reverse-depends(?exact-name($PACKAGE)), $COMMON)"
+ "?and(?reverse-recommends(?exact-name($PACKAGE)), $COMMON)"
+ "?and(?reverse-suggests(?exact-name($PACKAGE)), $COMMON)"
+ )
+done
+
+mkosi-install "${PATTERNS[@]}"