diff --git a/mkosi.conf.d/10-arch/mkosi.prepare b/mkosi.conf.d/10-arch/mkosi.prepare index aac7b3d76f9..76f67c14e52 100755 --- a/mkosi.conf.d/10-arch/mkosi.prepare +++ b/mkosi.conf.d/10-arch/mkosi.prepare @@ -6,9 +6,11 @@ if [[ "$1" == "build" ]]; then exit 0 fi +mapfile -t PACKAGES < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG") + DEPS="" -while read -r PACKAGE; do +for PACKAGE in "${PACKAGES[@]}"; do DEPS="$DEPS $( pacman --sync --info "$PACKAGE" | sed '1,/^$/d' | # Only keep result from first repository (delete everything after first blank line). @@ -23,11 +25,11 @@ while read -r PACKAGE; do sed 's/ *\(.*\):.*/\1/' | # Drop descriptions (everything after first colon for all lines). tr '\n' ' ' # Transform newlines to whitespace. )" -done < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG") +done echo "$DEPS" | xargs | # Remove extra whitespace. tr ' ' '\n' | - grep --invert-match --regexp systemd --regexp None | # systemd packages will be installed later on. + grep --extended-regexp --invert-match --regexp "$(IFS=\| ; echo "${PACKAGES[*]}")" --regexp None | # systemd packages will be installed later on. sort --unique | xargs --delimiter '\n' --no-run-if-empty mkosi-install diff --git a/mkosi.conf.d/10-centos-fedora/mkosi.prepare b/mkosi.conf.d/10-centos-fedora/mkosi.prepare index 9e74aabae2e..9aca0096d5b 100755 --- a/mkosi.conf.d/10-centos-fedora/mkosi.prepare +++ b/mkosi.conf.d/10-centos-fedora/mkosi.prepare @@ -13,7 +13,7 @@ for DEPS in --requires --recommends --suggests; do # --latest-limit=1 is per . so we have to pass --arch= explicitly to make sure i686 packages # are not considered on x86-64. dnf repoquery --arch="$DISTRIBUTION_ARCHITECTURE,noarch" --latest-limit=1 --quiet "$DEPS" "${PACKAGES[@]}" | - grep --invert-match --regexp systemd --regexp udev --regexp /bin/sh --regexp grubby --regexp sdubby --regexp libcurl-minimal | + grep --extended-regexp --invert-match --regexp "$(IFS=\| ; echo "${PACKAGES[*]}")" --regexp /bin/sh --regexp grubby --regexp sdubby --regexp libcurl-minimal | sort --unique | xargs --delimiter '\n' --no-run-if-empty mkosi-install done diff --git a/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare b/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare index acab113b8c1..ffff10d2a42 100755 --- a/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare +++ b/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare @@ -9,7 +9,8 @@ fi mapfile -t PACKAGES < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG") apt-cache depends "${PACKAGES[@]}" | - grep --invert-match --regexp "<" --regexp "|" --regexp systemd | # Remove e.g. and |dbus-broker like results + grep --invert-match --regexp "<" --regexp "|" | # Remove e.g. 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 | diff --git a/mkosi.conf.d/10-opensuse/mkosi.prepare b/mkosi.conf.d/10-opensuse/mkosi.prepare index 6ee0af2de93..728b502b133 100755 --- a/mkosi.conf.d/10-opensuse/mkosi.prepare +++ b/mkosi.conf.d/10-opensuse/mkosi.prepare @@ -6,18 +6,20 @@ if [[ "$1" == "build" ]]; then exit 0 fi +mapfile -t PACKAGES < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG") + DEPS="" -while read -r PACKAGE; do +for PACKAGE in "${PACKAGES[@]}"; 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") +done echo -e "$DEPS" | - grep --invert-match --regexp systemd --regexp udev --regexp qemu | + grep --extended-regexp --invert-match --regexp "$(IFS=\| ; echo "${PACKAGES[*]}")" --regexp qemu | sort --unique | xargs --delimiter '\n' --no-run-if-empty mkosi-install