[LEDE-DEV] [PATCH] mdadm: Fix config generation

Rosen Penev rosenp at gmail.com
Fri Oct 6 01:28:52 PDT 2017


The init script generated something like "DEVICE=/dev/sda" when it should have been generating "DEVICE /dev/sda". mdadm errors on this. Patch by jow.

Also changed the default sendmail path to /usr/sbin/sendmail. No package in LEDE provides /sbin/sendmail. msmtp provides /usr/sbin/sendmail so use that.

Also add a patch to fix file paths for mdadm runtime files. mdadm currently errors on them since /run is missing. Once /run is added to stock LEDE, this patch can be removed.

Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
 package/utils/mdadm/Makefile                       |  2 +-
 package/utils/mdadm/files/mdadm.init               | 11 ++++----
 .../utils/mdadm/patches/201-Fix-directories.patch  | 31 ++++++++++++++++++++++
 3 files changed, 37 insertions(+), 7 deletions(-)
 create mode 100644 package/utils/mdadm/patches/201-Fix-directories.patch

diff --git a/package/utils/mdadm/Makefile b/package/utils/mdadm/Makefile
index 1ed62d8174..5b2aa8e172 100644
--- a/package/utils/mdadm/Makefile
+++ b/package/utils/mdadm/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=mdadm
 PKG_VERSION:=4.0
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE_URL:=@KERNEL/linux/utils/raid/mdadm
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
diff --git a/package/utils/mdadm/files/mdadm.init b/package/utils/mdadm/files/mdadm.init
index e6624a776e..64a50b35de 100644
--- a/package/utils/mdadm/files/mdadm.init
+++ b/package/utils/mdadm/files/mdadm.init
@@ -34,14 +34,13 @@ mdadm_common() {
 	local cfg="$1"
 	local email devices
 
-	if [ -x /sbin/sendmail ]; then
-		append_option email "$cfg" email "MAILADDR"
-
+	if [ -x /usr/sbin/sendmail ]; then
+		config_get email "$cfg" email
+		[ -n "$email" ] && printf "MAILADDR %s\n" "$email" >> $CONF
 	fi
 
-	append_option devices "$cfg" devices DEVICE " "
-
-	printf "%s\n%s\n" "$email" "$devices" >> $CONF
+	config_list_foreach "$cfg" devices append_list_item devices " "
+	[ -n "$devices" ] && printf "DEVICE %s\n" "$devices" >> $CONF
 }
 
 mdadm_array() {
diff --git a/package/utils/mdadm/patches/201-Fix-directories.patch b/package/utils/mdadm/patches/201-Fix-directories.patch
new file mode 100644
index 0000000000..c795441b27
--- /dev/null
+++ b/package/utils/mdadm/patches/201-Fix-directories.patch
@@ -0,0 +1,31 @@
+diff --git a/mdadm.h b/mdadm.h
+index 71b8afb..1d8fca3 100644
+--- a/mdadm.h
++++ b/mdadm.h
+@@ -103,7 +103,7 @@ struct dlm_lksb {
+  * /run  seems to have emerged as the best standard.
+  */
+ #ifndef MAP_DIR
+-#define MAP_DIR "/run/mdadm"
++#define MAP_DIR "/tmp/run/mdadm"
+ #endif /* MAP_DIR */
+ /* MAP_FILE is what we name the map file we put in MAP_DIR, in case you
+  * want something other than the default of "map"
+@@ -120,7 +120,7 @@ struct dlm_lksb {
+  * boot process and stays up as long as possible during shutdown.
+  */
+ #ifndef MDMON_DIR
+-#define MDMON_DIR "/run/mdadm"
++#define MDMON_DIR "/tmp/run/mdadm"
+ #endif /* MDMON_DIR */
+ 
+ /* FAILED_SLOTS is where to save files storing recent removal of array
+@@ -128,7 +128,7 @@ struct dlm_lksb {
+  * slot for array recovery
+  */
+ #ifndef FAILED_SLOTS_DIR
+-#define FAILED_SLOTS_DIR "/run/mdadm/failed-slots"
++#define FAILED_SLOTS_DIR "/tmp/run/mdadm/failed-slots"
+ #endif /* FAILED_SLOTS */
+ 
+ #include	"md_u.h"
-- 
2.13.6




More information about the Lede-dev mailing list