mkosi: Two improvements (#37155)

This commit is contained in:
Daan De Meyer
2025-04-16 15:12:15 +02:00
committed by GitHub
20 changed files with 52 additions and 12 deletions
+10 -8
View File
@@ -17,14 +17,16 @@ for PACKAGE in "${PACKAGES[@]}"; do
sed --quiet 's/^Depends On *: //p' # Filter out everything except "Depends On:" line and fetch dependencies from it.
)"
DEPS="$DEPS $(
pacman --sync --info "$PACKAGE" |
sed '1,/^$/d' | # Only keep result from first repository (delete everything after first blank line).
sed --quiet '/Optional Deps/,/Conflicts With/{/Conflicts With/!p}' | # Get every line from "Optional Deps" (inclusive) until "Conflicts With" (exclusive).
sed 's/Optional Deps *: //' | # Drop "Optional Deps :" from first line.
sed 's/ *\(.*\):.*/\1/' | # Drop descriptions (everything after first colon for all lines).
tr '\n' ' ' # Transform newlines to whitespace.
)"
if ! ((SYSTEMD_REQUIRED_DEPS_ONLY)); then
DEPS="$DEPS $(
pacman --sync --info "$PACKAGE" |
sed '1,/^$/d' | # Only keep result from first repository (delete everything after first blank line).
sed --quiet '/Optional Deps/,/Conflicts With/{/Conflicts With/!p}' | # Get every line from "Optional Deps" (inclusive) until "Conflicts With" (exclusive).
sed 's/Optional Deps *: //' | # Drop "Optional Deps :" from first line.
sed 's/ *\(.*\):.*/\1/' | # Drop descriptions (everything after first colon for all lines).
tr '\n' ' ' # Transform newlines to whitespace.
)"
fi
done
echo "$DEPS" |
@@ -8,7 +8,12 @@ fi
mapfile -t PACKAGES < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG")
for DEPS in --requires --recommends --suggests; do
DEP_TYPES=(--requires)
if ! ((SYSTEMD_REQUIRED_DEPS_ONLY)); then
DEP_TYPES+=(--recommends --suggests)
fi
for DEPS in "${DEP_TYPES[@]}"; do
# We need --latest-limit=1 to only consider the newest version of the packages.
# --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.
@@ -22,9 +22,14 @@ 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)"
)
if ! ((SYSTEMD_REQUIRED_DEPS_ONLY)); then
PATTERNS+=(
"?and(?reverse-recommends(?exact-name($PACKAGE)), $COMMON)"
"?and(?reverse-suggests(?exact-name($PACKAGE)), $COMMON)"
)
fi
done
mkosi-install "${PATTERNS[@]}"
+5 -1
View File
@@ -9,11 +9,15 @@ fi
mapfile -t PACKAGES < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG")
DEPS=""
DEP_TYPES=(--requires)
if ! ((SYSTEMD_REQUIRED_DEPS_ONLY)); then
DEP_TYPES+=(--recommends --suggests)
fi
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" |
zypper info "${DEP_TYPES[@]}" "$PACKAGE" |
sed '/Requires/,$!d' | # Remove everything before Requires line
sed --quiet 's/^ //p' # All indented lines have dependencies
)"
+4
View File
@@ -3,6 +3,9 @@
[Output]
Format=directory
[Build]
Environment=SYSTEMD_REQUIRED_DEPS_ONLY=1
[Content]
Bootable=no
Locale=C.UTF-8
@@ -11,6 +14,7 @@ CleanPackageMetadata=yes
MakeInitrd=yes
Packages=
coreutils
bash
[Include]
@@ -4,6 +4,7 @@
Distribution=arch
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/arch/mkosi.prepare
VolatilePackages=
systemd
systemd-libs
@@ -5,5 +5,6 @@ Distribution=|centos
Distribution=|fedora
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/centos-fedora/mkosi.prepare
VolatilePackages=
systemd-standalone-shutdown
@@ -4,5 +4,6 @@
Distribution=debian
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
VolatilePackages=
systemd-standalone-shutdown
@@ -4,6 +4,7 @@
Distribution=opensuse
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/opensuse/mkosi.prepare
Packages=
diffutils
grep
@@ -4,6 +4,7 @@
Distribution=ubuntu
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
VolatilePackages=
libsystemd-shared
libsystemd0
+4
View File
@@ -6,10 +6,14 @@ Include=
%D/mkosi/mkosi.sanitizers
%D/mkosi/mkosi.coverage
[Build]
Environment=SYSTEMD_REQUIRED_DEPS_ONLY=1
[Content]
ExtraTrees=%D/mkosi/mkosi.extra.common
Packages=
coreutils
findutils
grep
sed
@@ -4,6 +4,7 @@
Distribution=arch
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/arch/mkosi.prepare
Packages=
btrfs-progs
tpm2-tools
@@ -5,6 +5,7 @@ Distribution=|centos
Distribution=|fedora
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/centos-fedora/mkosi.prepare
Packages=
tpm2-tools
@@ -5,6 +5,7 @@ Distribution=|debian
Distribution=|ubuntu
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
Packages=
btrfs-progs
tpm2-tools
@@ -4,6 +4,7 @@
Distribution=opensuse
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/opensuse/mkosi.prepare
Packages=
btrfs-progs
kmod
@@ -3,6 +3,9 @@
[Output]
Format=directory
[Build]
Environment=SYSTEMD_REQUIRED_DEPS_ONLY=1
[Content]
Bootable=no
Locale=C.UTF-8
@@ -4,6 +4,7 @@
Distribution=arch
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/arch/mkosi.prepare
Packages=
inetutils
iproute
@@ -5,6 +5,7 @@ Distribution=|centos
Distribution=|fedora
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/centos-fedora/mkosi.prepare
Packages=
hostname
iproute
@@ -5,6 +5,7 @@ Distribution=|debian
Distribution=|ubuntu
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
Packages=
hostname
iproute2
@@ -4,6 +4,7 @@
Distribution=opensuse
[Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/opensuse/mkosi.prepare
Packages=
diffutils
grep