commit:     88363d5349960e09082915da4e7e5b08e379c564
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Thu Mar  5 19:20:42 2026 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Thu Mar  5 20:36:11 2026 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=88363d53

sys-fs/mdadm: ignore exit status 2 when assembling in init script

Closes: https://bugs.gentoo.org/295397
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
Part-of: https://codeberg.org/gentoo/gentoo/pulls/224
Merges: https://codeberg.org/gentoo/gentoo/pulls/224

 sys-fs/mdadm/files/mdraid.rc                           | 15 ++++++++++++++-
 sys-fs/mdadm/{mdadm-4.4.ebuild => mdadm-4.4-r1.ebuild} |  2 +-
 sys-fs/mdadm/{mdadm-4.5.ebuild => mdadm-4.5-r1.ebuild} |  0
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/sys-fs/mdadm/files/mdraid.rc b/sys-fs/mdadm/files/mdraid.rc
index a30035dbbba2..6fbe4a26ea13 100644
--- a/sys-fs/mdadm/files/mdraid.rc
+++ b/sys-fs/mdadm/files/mdraid.rc
@@ -7,11 +7,24 @@ depend() {
        after modules
 }
 
+assemble() {
+       local rv
+       mdadm -As ${MDADM_ASSEMBLE_OPTS} 2>&1
+       rv=$?
+       if [ ${rv} -eq 2 ]; then
+               # mdadm exits with status 2 when there is nothing to assemble.
+               # This is undocumented.
+               # https://bugs.gentoo.org/295397
+               return 0
+       fi
+       return "${rv}"
+}
+
 start() {
        local output
 
        ebegin "Starting up RAID devices"
-       output=$(mdadm -As ${MDADM_ASSEMBLE_OPTS} 2>&1)
+       output=$(assemble)
        eend $? "${output}"
 
        local pat="/dev/md_d*"

diff --git a/sys-fs/mdadm/mdadm-4.4.ebuild b/sys-fs/mdadm/mdadm-4.4-r1.ebuild
similarity index 98%
rename from sys-fs/mdadm/mdadm-4.4.ebuild
rename to sys-fs/mdadm/mdadm-4.4-r1.ebuild
index cb3b0a96ed35..3e0c88d505a1 100644
--- a/sys-fs/mdadm/mdadm-4.4.ebuild
+++ b/sys-fs/mdadm/mdadm-4.4-r1.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2025 Gentoo Authors
+# Copyright 1999-2026 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8

diff --git a/sys-fs/mdadm/mdadm-4.5.ebuild b/sys-fs/mdadm/mdadm-4.5-r1.ebuild
similarity index 100%
rename from sys-fs/mdadm/mdadm-4.5.ebuild
rename to sys-fs/mdadm/mdadm-4.5-r1.ebuild

Reply via email to