aboutsummaryrefslogtreecommitdiffstats
path: root/main/mdadm
diff options
context:
space:
mode:
Diffstat (limited to 'main/mdadm')
-rw-r--r--main/mdadm/APKBUILD44
-rw-r--r--main/mdadm/mdadm-raid.initd48
-rw-r--r--main/mdadm/mdadm.confd5
-rw-r--r--main/mdadm/mdadm.initd28
-rw-r--r--main/mdadm/uclibc-bswap.patch18
5 files changed, 143 insertions, 0 deletions
diff --git a/main/mdadm/APKBUILD b/main/mdadm/APKBUILD
new file mode 100644
index 0000000000..65d151c14c
--- /dev/null
+++ b/main/mdadm/APKBUILD
@@ -0,0 +1,44 @@
+# Contributor: Carlo Landmeter <clandmeter at gmail>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=mdadm
+pkgver=3.2.2
+pkgrel=0
+pkgdesc="a tool for managing Linux Software RAID arrays"
+url="http://neil.brown.name/blog/mdadm"
+arch="all"
+license="GPL-2"
+depends=
+makedepends="groff"
+subpackages="$pkgname-doc"
+source="http://www.kernel.org/pub/linux/utils/raid/${pkgname}/${pkgname}-${pkgver}.tar.gz
+ ${pkgname}.initd
+ ${pkgname}.confd
+ mdadm-raid.initd
+ uclibc-bswap.patch
+ "
+
+prepare() {
+ cd "$srcdir/$pkgname-$pkgver"
+ patch -p1 -i "$srcdir"/uclibc-bswap.patch || return 1
+}
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make
+}
+
+package() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR=$pkgdir INSTALL=install install
+
+ install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
+ install -m755 -D "$srcdir"/$pkgname-raid.initd "$pkgdir"/etc/init.d/$pkgname-raid
+ install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+ install -m644 -D mdadm.conf-example "$pkgdir"/etc/mdadm.conf
+}
+
+md5sums="109c8bdd68daf146e693359b781ded65 mdadm-3.2.2.tar.gz
+ce57e798431f7ab89f9b07a7daaa4852 mdadm.initd
+16d2b8eb2e17184357db503470fdd8eb mdadm.confd
+ec48f19ee921eb49eb49a845bf01f1ff mdadm-raid.initd
+e6dde992d7da016f25161d6637474d26 uclibc-bswap.patch"
diff --git a/main/mdadm/mdadm-raid.initd b/main/mdadm/mdadm-raid.initd
new file mode 100644
index 0000000000..4692f76534
--- /dev/null
+++ b/main/mdadm/mdadm-raid.initd
@@ -0,0 +1,48 @@
+#!/sbin/runscript
+
+# script to start raid devices described in /etc/mdadm.conf.
+depend() {
+ before checkfs fsck
+ after modules
+}
+
+array_devices() {
+ awk '/^ARRAY/ {print $2}' /etc/mdadm.conf
+}
+
+start() {
+ [ -f /etc/mdadm.conf ] || return 0
+ # start all devices that are not already started
+ [ -f /proc/mdstat ] || modprobe -k md > /dev/null 2>&1
+ local tostart=
+ for i in $(array_devices); do
+ [ -b "$i" ] && continue
+ tostart="$tostart $i"
+ done
+ [ -z "$tostart" ] && return 0
+
+ ebegin "Starting RAID devices"
+ mdadm --assemble --scan --quiet $tostart
+ eend $?
+}
+
+is_mounted_as() {
+ local mnt
+ for mnt in $(awk "\$1 == \"$1\" {print \$2}" /proc/mounts); do
+ [ "$mnt" = "$2" ] && return 0
+ done
+ return 1
+}
+
+stop() {
+ # stop all raid devices except anything mounted as /
+ [ -f /etc/mdadm.conf ] || return 0
+ ebegin "Stopping RAID devices"
+ local tostop=
+ for i in $(array_devices); do
+ is_mounted_as $i / && continue
+ tostop="$tostop $i"
+ done
+ mdadm --stop --quiet $tostop
+ eend $?
+}
diff --git a/main/mdadm/mdadm.confd b/main/mdadm/mdadm.confd
new file mode 100644
index 0000000000..f1ed9c41d2
--- /dev/null
+++ b/main/mdadm/mdadm.confd
@@ -0,0 +1,5 @@
+# Misc options to pass to mdadm in monitor mode.
+# For more info, run `mdadm --monitor --help` or see
+# the mdadm(8) manpage.
+
+OPTS="--syslog"
diff --git a/main/mdadm/mdadm.initd b/main/mdadm/mdadm.initd
new file mode 100644
index 0000000000..77384e2658
--- /dev/null
+++ b/main/mdadm/mdadm.initd
@@ -0,0 +1,28 @@
+#!/sbin/runscript
+
+# Sample init.d file for alpine linux.
+
+NAME=mdadm
+DAEMON=/sbin/$NAME
+
+depend() {
+ use logger dns net
+ after firewall
+}
+
+start() {
+ ebegin "Starting ${NAME}"
+ start-stop-daemon --start --quiet --background \
+ --exec ${DAEMON} -- \
+ --monitor --scan \
+ --daemonise ${OPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${NAME}"
+ start-stop-daemon --stop --quiet \
+ --exec ${DAEMON}
+ eend $?
+}
+
diff --git a/main/mdadm/uclibc-bswap.patch b/main/mdadm/uclibc-bswap.patch
new file mode 100644
index 0000000000..b1d0428dc8
--- /dev/null
+++ b/main/mdadm/uclibc-bswap.patch
@@ -0,0 +1,18 @@
+--- ./mdadm.h.orig
++++ ./mdadm.h
+@@ -104,12 +104,15 @@
+ * and there is no standard conversion function so... */
+ /* And dietlibc doesn't think byteswap is ok, so.. */
+ /* #include <byteswap.h> */
++#undef bswap_16
+ #define bswap_16(x) (((x) & 0x00ffU) << 8 | \
+ ((x) & 0xff00U) >> 8)
++#undef bswap_32
+ #define bswap_32(x) (((x) & 0x000000ffU) << 24 | \
+ ((x) & 0xff000000U) >> 24 | \
+ ((x) & 0x0000ff00U) << 8 | \
+ ((x) & 0x00ff0000U) >> 8)
++#undef bswap_64
+ #define bswap_64(x) (((x) & 0x00000000000000ffULL) << 56 | \
+ ((x) & 0xff00000000000000ULL) >> 56 | \
+ ((x) & 0x000000000000ff00ULL) << 40 | \