In the subimages we also want to make sure all dependencies of the
systemd packages are cached so reuse the same prepare scripts from
the main image to do that.
We only want required dependencies in the subimages, not recommended
or suggested dependendencies, so add an environment variable
$SYSTEMD_REQUIRED_DEPS_ONLY which the prepare scripts can check for
and enable it for the subimages.
(cherry picked from commit
52a82bcfc9ea627c12ae32f3065b1582dfbf864b)
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" |
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.
# 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[@]}"
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
)"
[Output]
Format=directory
+[Build]
+Environment=SYSTEMD_REQUIRED_DEPS_ONLY=1
+
[Content]
Bootable=no
Locale=C.UTF-8
Distribution=arch
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/arch/mkosi.prepare
VolatilePackages=
systemd
systemd-libs
Distribution=|fedora
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/centos-fedora/mkosi.prepare
VolatilePackages=
systemd-standalone-shutdown
Distribution=debian
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
VolatilePackages=
systemd-standalone-shutdown
Distribution=opensuse
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/opensuse/mkosi.prepare
Packages=
diffutils
grep
Distribution=ubuntu
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
VolatilePackages=
libsystemd-shared
libsystemd0
%D/mkosi/mkosi.sanitizers
%D/mkosi/mkosi.coverage
+[Build]
+Environment=SYSTEMD_REQUIRED_DEPS_ONLY=1
+
[Content]
ExtraTrees=%D/mkosi/mkosi.extra.common
Distribution=arch
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/arch/mkosi.prepare
Packages=
btrfs-progs
tpm2-tools
Distribution=|fedora
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/centos-fedora/mkosi.prepare
Packages=
tpm2-tools
Distribution=|ubuntu
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
Packages=
btrfs-progs
tpm2-tools
Distribution=opensuse
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/opensuse/mkosi.prepare
Packages=
btrfs-progs
kmod
[Output]
Format=directory
+[Build]
+Environment=SYSTEMD_REQUIRED_DEPS_ONLY=1
+
[Content]
Bootable=no
Locale=C.UTF-8
Distribution=arch
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/arch/mkosi.prepare
Packages=
inetutils
iproute
Distribution=|fedora
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/centos-fedora/mkosi.prepare
Packages=
hostname
iproute
Distribution=|ubuntu
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
Packages=
hostname
iproute2
Distribution=opensuse
[Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/opensuse/mkosi.prepare
Packages=
diffutils
grep