1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

Merge pull request #34240 from DaanDeMeyer/mkosi

mkosi: Rework debian/ubuntu prepare script to install dependencies
This commit is contained in:
Daan De Meyer 2024-09-03 17:52:43 +02:00 committed by GitHub
commit a026c3fb41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 13 deletions

View File

@ -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

View File

@ -13,7 +13,7 @@ for DEPS in --requires --recommends --suggests; do
# --latest-limit=1 is per <name>.<arch> 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

View File

@ -8,9 +8,23 @@ fi
mapfile -t PACKAGES < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG")
apt-cache depends "${PACKAGES[@]}" |
grep --invert-match --regexp "<" --regexp "|" --regexp systemd | # Remove e.g. <python3:any> and |dbus-broker like results
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[@]}"

View File

@ -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