]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: Reuse main image prepare scripts in subimages
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 16 Apr 2025 12:04:33 +0000 (14:04 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 23 Jun 2025 18:49:24 +0000 (03:49 +0900)
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)

20 files changed:
mkosi/mkosi.conf.d/arch/mkosi.prepare
mkosi/mkosi.conf.d/centos-fedora/mkosi.prepare
mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
mkosi/mkosi.conf.d/opensuse/mkosi.prepare
mkosi/mkosi.images/exitrd/mkosi.conf
mkosi/mkosi.images/exitrd/mkosi.conf.d/arch.conf
mkosi/mkosi.images/exitrd/mkosi.conf.d/centos-fedora.conf
mkosi/mkosi.images/exitrd/mkosi.conf.d/debian.conf
mkosi/mkosi.images/exitrd/mkosi.conf.d/opensuse.conf
mkosi/mkosi.images/exitrd/mkosi.conf.d/ubuntu.conf
mkosi/mkosi.images/initrd/mkosi.conf
mkosi/mkosi.images/initrd/mkosi.conf.d/arch.conf
mkosi/mkosi.images/initrd/mkosi.conf.d/centos-fedora.conf
mkosi/mkosi.images/initrd/mkosi.conf.d/debian-ubuntu.conf
mkosi/mkosi.images/initrd/mkosi.conf.d/opensuse.conf
mkosi/mkosi.images/minimal-base/mkosi.conf
mkosi/mkosi.images/minimal-base/mkosi.conf.d/arch.conf
mkosi/mkosi.images/minimal-base/mkosi.conf.d/centos-fedora.conf
mkosi/mkosi.images/minimal-base/mkosi.conf.d/debian-ubuntu.conf
mkosi/mkosi.images/minimal-base/mkosi.conf.d/opensuse.conf

index 76f67c14e5256f5e2a62a55f388ae02b01b835b8..052ce928652868885dfc281cd8bdf08d958267e1 100755 (executable)
@@ -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" |
index 1e5bd2199586cc3dd95b0d5d76ea92a989fbdccd..9e5185bbc6def5f2a17c2cf50a3852c27d2cfc3a 100755 (executable)
@@ -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.
index bf2c5eb91f622c62b266e968c0c9aeffe3a8a10e..22be35f823850a2299a333e05c166004b6c453c7 100755 (executable)
@@ -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[@]}"
index 728b502b133db13e25b0d9c14fb054a2ade893de..32a9312d293c4f6abfe72b19fe8666e045474417 100755 (executable)
@@ -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
     )"
index 8d8b7e976178da29a50215fbc3e3eb3216c408c2..4a811e15e2fe4028b53b6ac756baa438ab6ff75e 100644 (file)
@@ -3,6 +3,9 @@
 [Output]
 Format=directory
 
+[Build]
+Environment=SYSTEMD_REQUIRED_DEPS_ONLY=1
+
 [Content]
 Bootable=no
 Locale=C.UTF-8
index b5f3194a847be95c7e43af572ac245bd30ad446c..8ccf722238801a09b15f853170ab99e5c60f2dbf 100644 (file)
@@ -4,6 +4,7 @@
 Distribution=arch
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/arch/mkosi.prepare
 VolatilePackages=
         systemd
         systemd-libs
index a1fa32b7860efc432a865da487310a710ce5c4a3..1665f8b471460b485596b091fce69164aa5b8236 100644 (file)
@@ -5,5 +5,6 @@ Distribution=|centos
 Distribution=|fedora
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/centos-fedora/mkosi.prepare
 VolatilePackages=
         systemd-standalone-shutdown
index 6ca310cbc261bd71f24b5d92b0b742e13d6ddf7f..c745a1a1d3fe63da45f0e90fdfa431415bf98571 100644 (file)
@@ -4,5 +4,6 @@
 Distribution=debian
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
 VolatilePackages=
         systemd-standalone-shutdown
index 37f6220ea0f0e1ac60278e54910fbd02cd633f22..7acc4813892175dcac66223a371af2b02b9c84ac 100644 (file)
@@ -4,6 +4,7 @@
 Distribution=opensuse
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/opensuse/mkosi.prepare
 Packages=
         diffutils
         grep
index 9a7e1d8cbb3235d1ca3b7dea6ebd9855cd68785c..742d9985040825ab9fb8b7bcfc02aa097654c8af 100644 (file)
@@ -4,6 +4,7 @@
 Distribution=ubuntu
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
 VolatilePackages=
         libsystemd-shared
         libsystemd0
index b54fe2daf4bfe810dbe41d606befd098a0186421..2b731d4397e03ef0e89ef48ea1d896ba49b541a0 100644 (file)
@@ -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
 
index 99e039d1dc53c6420a6173a0477300da433f9fe5..74f4bee9c91a5e12115832b1e04a01da66ed3442 100644 (file)
@@ -4,6 +4,7 @@
 Distribution=arch
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/arch/mkosi.prepare
 Packages=
         btrfs-progs
         tpm2-tools
index 6607dab0891c91361a235e00a6f918df3736ce3b..7e5ccd22b76e7c8da0f646f5ca1bb3dac709ffe0 100644 (file)
@@ -5,6 +5,7 @@ Distribution=|centos
 Distribution=|fedora
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/centos-fedora/mkosi.prepare
 Packages=
         tpm2-tools
 
index 093c1bd8867ea44b0413b25eda101e16665625d5..5e0355974ebf26eb8077d8e623d0d0698a0e36b9 100644 (file)
@@ -5,6 +5,7 @@ Distribution=|debian
 Distribution=|ubuntu
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
 Packages=
         btrfs-progs
         tpm2-tools
index 9f685e61e5612dfeb6c914bd574e9771a0b8bda4..f0e07f49acbd811ab2bda8b59eb7809419e32786 100644 (file)
@@ -4,6 +4,7 @@
 Distribution=opensuse
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/opensuse/mkosi.prepare
 Packages=
         btrfs-progs
         kmod
index b51ac638d6f6590887768aa21f64209866ad0764..be80db6cc196e6422ee048884c8b540f78900d9e 100644 (file)
@@ -3,6 +3,9 @@
 [Output]
 Format=directory
 
+[Build]
+Environment=SYSTEMD_REQUIRED_DEPS_ONLY=1
+
 [Content]
 Bootable=no
 Locale=C.UTF-8
index 044199a6c137b7970aa6a6449c1ae914127d7a4a..070506b8f5d2c92990c1b629b52e067ea0a3624c 100644 (file)
@@ -4,6 +4,7 @@
 Distribution=arch
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/arch/mkosi.prepare
 Packages=
         inetutils
         iproute
index e9893ad989742dbb9c795339fbac16c6da7841ad..6d4caebef43ed9439f9c7c1af2451492e002c7bc 100644 (file)
@@ -5,6 +5,7 @@ Distribution=|centos
 Distribution=|fedora
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/centos-fedora/mkosi.prepare
 Packages=
         hostname
         iproute
index d524ec17feeec74bf521a80833da81eb2865a709..ddf1a18807503015e1d85d49360f978952edab7c 100644 (file)
@@ -5,6 +5,7 @@ Distribution=|debian
 Distribution=|ubuntu
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare
 Packages=
         hostname
         iproute2
index 3d891b8ed0af3a057b0a2cfb032402baaae9e39a..4f96c7d34b4800285166c740f4c1810b669580a6 100644 (file)
@@ -4,6 +4,7 @@
 Distribution=opensuse
 
 [Content]
+PrepareScripts=%D/mkosi/mkosi.conf.d/opensuse/mkosi.prepare
 Packages=
         diffutils
         grep