mkosi: Reuse main image prepare scripts in subimages
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.
This commit is contained in:
parent
0ac6fc2917
commit
52a82bcfc9
mkosi
mkosi.conf.d
mkosi.images
exitrd
initrd
minimal-base
|
@ -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[@]}"
|
||||
|
|
|
@ -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
|
||||
)"
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
|
|
@ -6,6 +6,9 @@ Include=
|
|||
%D/mkosi/mkosi.sanitizers
|
||||
%D/mkosi/mkosi.coverage
|
||||
|
||||
[Build]
|
||||
Environment=SYSTEMD_REQUIRED_DEPS_ONLY=1
|
||||
|
||||
[Content]
|
||||
ExtraTrees=%D/mkosi/mkosi.extra.common
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue