diff options
Diffstat (limited to 'libre-testing/mdadm')
-rw-r--r-- | libre-testing/mdadm/PKGBUILD | 52 | ||||
-rw-r--r-- | libre-testing/mdadm/disable-werror.patch | 11 | ||||
-rw-r--r-- | libre-testing/mdadm/linux-3.0.patch | 45 | ||||
-rw-r--r-- | libre-testing/mdadm/mdadm-fix-udev-rules.patch | 137 | ||||
-rw-r--r-- | libre-testing/mdadm/mdadm.conf | 67 | ||||
-rwxr-xr-x | libre-testing/mdadm/mdadm_hook | 49 | ||||
-rw-r--r-- | libre-testing/mdadm/mdadm_install | 46 | ||||
-rw-r--r-- | libre-testing/mdadm/mdadm_udev_install | 25 | ||||
-rw-r--r-- | libre-testing/mdadm/repos/core-x86_64/PKGBUILD | 53 | ||||
-rw-r--r-- | libre-testing/mdadm/repos/core-x86_64/disable-werror.patch | 11 | ||||
-rw-r--r-- | libre-testing/mdadm/repos/core-x86_64/linux-3.0.patch | 45 | ||||
-rw-r--r-- | libre-testing/mdadm/repos/core-x86_64/mdadm-fix-udev-rules.patch | 137 | ||||
-rw-r--r-- | libre-testing/mdadm/repos/core-x86_64/mdadm.conf | 67 | ||||
-rwxr-xr-x | libre-testing/mdadm/repos/core-x86_64/mdadm_hook | 49 | ||||
-rw-r--r-- | libre-testing/mdadm/repos/core-x86_64/mdadm_install | 46 | ||||
-rw-r--r-- | libre-testing/mdadm/repos/core-x86_64/mdadm_udev_install | 25 |
16 files changed, 865 insertions, 0 deletions
diff --git a/libre-testing/mdadm/PKGBUILD b/libre-testing/mdadm/PKGBUILD new file mode 100644 index 000000000..ae3148e89 --- /dev/null +++ b/libre-testing/mdadm/PKGBUILD @@ -0,0 +1,52 @@ +# Maintainer: Tobias Powalowski <tpowa@archlinux.org> +# Contributor: Judd Vinet <jvinet@zeroflux.org> +pkgname=mdadm +pkgver=4.0 +pkgrel=1 +pkgdesc="A tool for managing/monitoring Linux md device arrays, also known as Software RAID" +arch=(x86_64 ppc64le) +license=('GPL') +url="http://neil.brown.name/blog/mdadm" +groups=('base') +conflicts=('mkinitcpio<0.7') +depends=('glibc') +backup=('etc/mdadm.conf') +source=("https://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-4.0.tar."{xz,sign} + mdadm.conf + mdadm_install + mdadm_hook + mdadm_udev_install + disable-werror.patch) +replaces=('raidtools') +validpgpkeys=('6A86B80E1D22F21D0B26BA75397D82E0531A9C91') # Jes Sorensen +md5sums=('2cb4feffea9167ba71b5f346a0c0a40d' + 'SKIP' + '5a37c112aa07dccdde62f9fa5b888607' + 'af2f73f0094ebee66f503ca4710c7142' + 'fbfb7d07efcbaf5dc61af424c5f6e352' + 'b6b0bfd6487c99264578630616dfe5eb' + '599745ed2bec4489e83991cff89c46ee') + +prepare() { + cd $srcdir/$pkgname-$pkgver + patch -Np0 -i ../disable-werror.patch +} + +build() { + cd $srcdir/$pkgname-$pkgver + make CXFLAGS="$CFLAGS" BINDIR=/usr/bin UDEVDIR=/usr/lib/udev + # build static mdassemble for Arch's initramfs + make MDASSEMBLE_AUTO=1 mdassemble + +} + +package() { + cd $srcdir/$pkgname-$pkgver + make INSTALL=/usr/bin/install BINDIR=/usr/bin DESTDIR=$pkgdir UDEVDIR=/usr/lib/udev install + make SYSTEMD_DIR=$pkgdir/usr/lib/systemd/system install-systemd + install -D -m755 mdassemble $pkgdir/usr/bin/mdassemble + install -D -m644 ../mdadm.conf $pkgdir/etc/mdadm.conf + install -D -m644 ../mdadm_install $pkgdir/usr/lib/initcpio/install/mdadm + install -D -m644 ../mdadm_hook $pkgdir/usr/lib/initcpio/hooks/mdadm + install -D -m644 ../mdadm_udev_install $pkgdir/usr/lib/initcpio/install/mdadm_udev +} diff --git a/libre-testing/mdadm/disable-werror.patch b/libre-testing/mdadm/disable-werror.patch new file mode 100644 index 000000000..a80a41456 --- /dev/null +++ b/libre-testing/mdadm/disable-werror.patch @@ -0,0 +1,11 @@ +--- Makefile.old 2011-06-17 09:38:03.269238332 +0200 ++++ Makefile 2011-06-17 09:38:14.122398837 +0200 +@@ -42,7 +42,7 @@ + + CC = $(CROSS_COMPILE)gcc + CXFLAGS ?= -ggdb +-CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter ++CWFLAGS = -Wall -Wstrict-prototypes -Wextra -Wno-unused-parameter + ifdef WARN_UNUSED + CWFLAGS += -Wp,-D_FORTIFY_SOURCE=2 -O3 + endif diff --git a/libre-testing/mdadm/linux-3.0.patch b/libre-testing/mdadm/linux-3.0.patch new file mode 100644 index 000000000..cd9d5473c --- /dev/null +++ b/libre-testing/mdadm/linux-3.0.patch @@ -0,0 +1,45 @@ +From f161d047eed634b3380262767f955eb888502e88 Mon Sep 17 00:00:00 2001 +From: NeilBrown <neilb@suse.de> +Date: Fri, 17 Jun 2011 22:49:24 +1000 +Subject: [PATCH 1/1] util: correctly parse shorter linux version numbers. + +The next version of Linux might be 3.0. If it is, get_linux_version +will fail. +So make it more robust. + +Reported-by: Namhyung Kim <namhyung@gmail.com> +Reported-by: Milan Broz <mbroz@redhat.com> +Signed-off-by: NeilBrown <neilb@suse.de> +--- + util.c | 10 +++++----- + 1 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/util.c b/util.c +index 10bbe56..55d171a 100644 +--- a/util.c ++++ b/util.c +@@ -146,16 +146,16 @@ int get_linux_version() + { + struct utsname name; + char *cp; +- int a,b,c; ++ int a = 0, b = 0,c = 0; + if (uname(&name) <0) + return -1; + + cp = name.release; + a = strtoul(cp, &cp, 10); +- if (*cp != '.') return -1; +- b = strtoul(cp+1, &cp, 10); +- if (*cp != '.') return -1; +- c = strtoul(cp+1, NULL, 10); ++ if (*cp == '.') ++ b = strtoul(cp+1, &cp, 10); ++ if (*cp == '.') ++ c = strtoul(cp+1, &cp, 10); + + return (a*1000000)+(b*1000)+c; + } +-- +1.7.2.3 + diff --git a/libre-testing/mdadm/mdadm-fix-udev-rules.patch b/libre-testing/mdadm/mdadm-fix-udev-rules.patch new file mode 100644 index 000000000..941cadf3a --- /dev/null +++ b/libre-testing/mdadm/mdadm-fix-udev-rules.patch @@ -0,0 +1,137 @@ +diff --git a/Makefile b/Makefile +index b6edb23..bedef96 100644 +--- a/Makefile ++++ b/Makefile +@@ -253,8 +253,9 @@ + $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4 + $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 + +-install-udev: udev-md-raid.rules +- $(INSTALL) -D -m 644 udev-md-raid.rules $(DESTDIR)/lib/udev/rules.d/64-md-raid.rules ++install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules ++ $(INSTALL) -D -m 644 udev-md-raid-arrays.rules $(DESTDIR)/usr/lib/udev/rules.d/63-md-raid-arrays.rules ++ $(INSTALL) -D -m 644 udev-md-raid-assembly.rules $(DESTDIR)/usr/lib/udev/rules.d/64-md-raid-assembly.rules + + uninstall: + rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm +diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules +new file mode 100644 +index 0000000..883ee4d +--- /dev/null ++++ b/udev-md-raid-arrays.rules +@@ -0,0 +1,35 @@ ++# do not edit this file, it will be overwritten on update ++ ++SUBSYSTEM!="block", GOTO="md_end" ++ ++# handle md arrays ++ACTION!="add|change", GOTO="md_end" ++KERNEL!="md*", GOTO="md_end" ++ ++# partitions have no md/{array_state,metadata_version}, but should not ++# for that reason be ignored. ++ENV{DEVTYPE}=="partition", GOTO="md_ignore_state" ++ ++# container devices have a metadata version of e.g. 'external:ddf' and ++# never leave state 'inactive' ++ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state" ++TEST!="md/array_state", ENV{SYSTEMD_READY}="0", GOTO="md_end" ++ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end" ++LABEL="md_ignore_state" ++ ++IMPORT{program}="/usr/bin/mdadm --detail --export $devnode" ++ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace" ++ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}" ++ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}" ++ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace" ++ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n" ++ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n" ++ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n" ++ ++IMPORT{builtin}="blkid" ++OPTIONS+="link_priority=100" ++OPTIONS+="watch" ++ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" ++ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" ++ ++LABEL="md_end" +diff --git a/udev-md-raid-assembly.rules b/udev-md-raid-assembly.rules +new file mode 100644 +index 0000000..b89775e +--- /dev/null ++++ b/udev-md-raid-assembly.rules +@@ -0,0 +1,19 @@ ++# do not edit this file, it will be overwritten on update ++ ++# assemble md arrays ++ ++SUBSYSTEM!="block", GOTO="md_inc_end" ++ ++# handle potential components of arrays (the ones supported by md) ++ENV{ID_FS_TYPE}=="ddf_raid_member|isw_raid_member|linux_raid_member", GOTO="md_inc" ++GOTO="md_inc_end" ++ ++LABEL="md_inc" ++ ++# remember you can limit what gets auto/incrementally assembled by ++# mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY' ++ACTION=="add", RUN+="/usr/bin/mdadm --incremental $devnode --offroot" ++ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/usr/bin/mdadm -If $name --path $env{ID_PATH}" ++ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/usr/bin/mdadm -If $name" ++ ++LABEL="md_inc_end" +diff --git a/udev-md-raid.rules b/udev-md-raid.rules +deleted file mode 100644 +index cc7f5ef..0000000 +--- a/udev-md-raid.rules ++++ /dev/null +@@ -1,49 +0,0 @@ +-# do not edit this file, it will be overwritten on update +- +-SUBSYSTEM!="block", GOTO="md_end" +- +-# handle potential components of arrays (the ones supported by md) +-ENV{ID_FS_TYPE}=="ddf_raid_member|isw_raid_member|linux_raid_member", GOTO="md_inc" +-GOTO="md_inc_skip" +- +-LABEL="md_inc" +- +-# remember you can limit what gets auto/incrementally assembled by +-# mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY' +-ACTION=="add", RUN+="/sbin/mdadm --incremental $tempnode --offroot" +-ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}" +-ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name" +- +-LABEL="md_inc_skip" +- +-# handle md arrays +-ACTION!="add|change", GOTO="md_end" +-KERNEL!="md*", GOTO="md_end" +- +-# partitions have no md/{array_state,metadata_version}, but should not +-# for that reason be ignored. +-ENV{DEVTYPE}=="partition", GOTO="md_ignore_state" +- +-# container devices have a metadata version of e.g. 'external:ddf' and +-# never leave state 'inactive' +-ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state" +-TEST!="md/array_state", ENV{SYSTEMD_READY}="0", GOTO="md_end" +-ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end" +-LABEL="md_ignore_state" +- +-IMPORT{program}="/sbin/mdadm --detail --export $tempnode" +-ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace" +-ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}" +-ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}" +-ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace" +-ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n" +-ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n" +-ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n" +- +-IMPORT{program}="/sbin/blkid -o udev -p $tempnode" +-OPTIONS+="link_priority=100" +-OPTIONS+="watch" +-ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" +-ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" +- +-LABEL="md_end" diff --git a/libre-testing/mdadm/mdadm.conf b/libre-testing/mdadm/mdadm.conf new file mode 100644 index 000000000..36eaa0cc0 --- /dev/null +++ b/libre-testing/mdadm/mdadm.conf @@ -0,0 +1,67 @@ +# mdadm configuration file +# +# mdadm will function properly without the use of a configuration file, +# but this file is useful for keeping track of arrays and member disks. +# In general, a mdadm.conf file is created, and updated, after arrays +# are created. This is the opposite behavior of /etc/raidtab which is +# created prior to array construction. +# +# +# the config file takes two types of lines: +# +# DEVICE lines specify a list of devices of where to look for +# potential member disks +# +# ARRAY lines specify information about how to identify arrays so +# so that they can be activated +# + + +# You can have more than one device line and use wild cards. The first +# example includes SCSI the first partition of SCSI disks /dev/sdb, +# /dev/sdc, /dev/sdd, /dev/sdj, /dev/sdk, and /dev/sdl. The second +# line looks for array slices on IDE disks. +# +#DEVICE /dev/sd[bcdjkl]1 +#DEVICE /dev/hda1 /dev/hdb1 +# +# The designation "partitions" will scan all partitions found in +# /proc/partitions +DEVICE partitions + + +# ARRAY lines specify an array to assemble and a method of identification. +# Arrays can currently be identified by using a UUID, superblock minor number, +# or a listing of devices. +# +# super-minor is usually the minor number of the metadevice +# UUID is the Universally Unique Identifier for the array +# Each can be obtained using +# +# mdadm -D <md> +# +# To capture the UUIDs for all your RAID arrays to this file, run these: +# to get a list of running arrays: +# # mdadm -D --scan >>/etc/mdadm.conf +# to get a list from superblocks: +# # mdadm -E --scan >>/etc/mdadm.conf +# +#ARRAY /dev/md0 UUID=3aaa0122:29827cfa:5331ad66:ca767371 +#ARRAY /dev/md1 super-minor=1 +#ARRAY /dev/md2 devices=/dev/hda1,/dev/hdb1 +# +# ARRAY lines can also specify a "spare-group" for each array. mdadm --monitor +# will then move a spare between arrays in a spare-group if one array has a +# failed drive but no spare +#ARRAY /dev/md4 uuid=b23f3c6d:aec43a9f:fd65db85:369432df spare-group=group1 +#ARRAY /dev/md5 uuid=19464854:03f71b1b:e0df2edd:246cc977 spare-group=group1 +# + + +# When used in --follow (aka --monitor) mode, mdadm needs a +# mail address and/or a program. To start mdadm's monitor mode, enable +# mdadm.service in systemd. +# +# If the lines are not found, mdadm will exit quietly +#MAILADDR root@mydomain.tld +#PROGRAM /usr/sbin/handle-mdadm-events diff --git a/libre-testing/mdadm/mdadm_hook b/libre-testing/mdadm/mdadm_hook new file mode 100755 index 000000000..5371baaca --- /dev/null +++ b/libre-testing/mdadm/mdadm_hook @@ -0,0 +1,49 @@ +#!/usr/bin/ash + +run_hook() { + local i= mdconfig=/etc/mdadm.conf + + # for partitionable raid, we need to load md_mod first! + modprobe md_mod 2>/dev/null + + if [ -n "$md" ]; then + echo 'DEVICE partitions' >"$mdconfig" + for i in $(cat /proc/cmdline); do + case $i in + # raid + md=[0-9]*,/*) + device=${i%%,*} + device=${device/=/} + array=${i#*,} + echo "ARRAY /dev/$device devices=$array" + ;; + # partitionable raid + md=d[0-9]*,/*) + device=${i%%,*} + device=${device/=/_} + array=${i#*,} + echo "ARRAY /dev/$device devices=$array" + ;; + # raid UUID + md=[0-9]*,[0-9,a-fA-F]*) + device=${i%%,*} + device=${device/=/} + array=${i#*,} + echo "ARRAY /dev/$device UUID=$array" + ;; + # partitionable raid UUID + md=d[0-9]*,[0-9,a-fA-F]*) + device=${i%%,*} + device=${device/=/_} + array=${i#*,} + echo "ARRAY /dev/$device UUID=$array" + ;; + esac + done >>"$mdconfig" + fi + + # assemble everything + [ -s "$mdconfig" ] && /usr/bin/mdassemble +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/libre-testing/mdadm/mdadm_install b/libre-testing/mdadm/mdadm_install new file mode 100644 index 000000000..7390509fa --- /dev/null +++ b/libre-testing/mdadm/mdadm_install @@ -0,0 +1,46 @@ +#!/bin/bash + +build() { + add_checked_modules -f 'dm-' 'drivers/md/*' + + # check if a custom mdadm.conf exists + if grep -q ^ARRAY /etc/mdadm.conf; then + echo "Custom /etc/mdadm.conf file will be used in initramfs for assembling arrays." + add_file "/etc/mdadm.conf" + fi + add_binary "/usr/bin/mdassemble" + add_file "/usr/lib/udev/rules.d/63-md-raid-arrays.rules" + + add_runscript +} + +help() { + cat <<HELPEOF +This hook loads the necessary modules for any raid root device, +and assembles the raid device when run. + +If arrays are defined in /etc/mdadm.conf, the file will be used instead +of command line assembling. + +Command Line Setup: +- for raid arrays with persistent superblocks: + md=<md device no.>,dev0,dev1,...,devn + md=<md device no.>,uuid +- for partitionable raid arrays with persistent superblocks: + md=d<md device no.>,dev0,dev1,...,devn + md=d<md device no.>,uuid + +Parameters: +- <md device no.> = the number of the md device: + 0 means md0, 1 means md1, ... +- <dev0-devn>: e.g. /dev/hda1,/dev/hdc1,/dev/sda1,/dev/sdb1 + or 0900878d:f95f6057:c39a36e9:55efa60a +Examples: +- md=d0,/dev/sda3,/dev/sda4 md=d1,/dev/hda1,/dev/hdb1 + This will setup 2 md partitionable arrays. +- md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1 + This will setup 2 md arrays with persistent superblocks. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/libre-testing/mdadm/mdadm_udev_install b/libre-testing/mdadm/mdadm_udev_install new file mode 100644 index 000000000..c01cbaf24 --- /dev/null +++ b/libre-testing/mdadm/mdadm_udev_install @@ -0,0 +1,25 @@ +#!/bin/bash + +build() { + add_checked_modules -f 'dm-' 'drivers/md/*' + + # check if a custom mdadm.conf exists + if grep -qw ^ARRAY "$BASEDIR/etc/mdadm.conf"; then + echo "Custom /etc/mdadm.conf file will be used in initramfs for assembling arrays." + add_file "/etc/mdadm.conf" + fi + + add_binary "/usr/bin/mdadm" + add_file "/usr/lib/udev/rules.d/63-md-raid-arrays.rules" + add_file "/usr/lib/udev/rules.d/64-md-raid-assembly.rules" +} + +help() { + cat <<HELPEOF +This hook loads the necessary modules for a RAID array and uses incremental +assembly via udev at runtime to create the devices. This hook will NOT work +without the udev hook included on the image. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/libre-testing/mdadm/repos/core-x86_64/PKGBUILD b/libre-testing/mdadm/repos/core-x86_64/PKGBUILD new file mode 100644 index 000000000..0ab2d627a --- /dev/null +++ b/libre-testing/mdadm/repos/core-x86_64/PKGBUILD @@ -0,0 +1,53 @@ +# $Id$ +# Maintainer: Tobias Powalowski <tpowa@archlinux.org> +# Contributor: Judd Vinet <jvinet@zeroflux.org> +pkgname=mdadm +pkgver=4.0 +pkgrel=1 +pkgdesc="A tool for managing/monitoring Linux md device arrays, also known as Software RAID" +arch=(i686 x86_64) +license=('GPL') +url="http://neil.brown.name/blog/mdadm" +groups=('base') +conflicts=('mkinitcpio<0.7') +depends=('glibc') +backup=('etc/mdadm.conf') +source=("ftp://ftp.kernel.org/pub/linux/utils/raid/mdadm/mdadm-${pkgver}.tar."{xz,sign} + mdadm.conf + mdadm_install + mdadm_hook + mdadm_udev_install + disable-werror.patch) +replaces=('raidtools') +validpgpkeys=('6A86B80E1D22F21D0B26BA75397D82E0531A9C91') # Jes Sorensen +md5sums=('2cb4feffea9167ba71b5f346a0c0a40d' + 'SKIP' + '5a37c112aa07dccdde62f9fa5b888607' + 'af2f73f0094ebee66f503ca4710c7142' + 'fbfb7d07efcbaf5dc61af424c5f6e352' + 'b6b0bfd6487c99264578630616dfe5eb' + '599745ed2bec4489e83991cff89c46ee') + +prepare() { + cd $srcdir/$pkgname-$pkgver + patch -Np0 -i ../disable-werror.patch +} + +build() { + cd $srcdir/$pkgname-$pkgver + make CXFLAGS="$CFLAGS" BINDIR=/usr/bin UDEVDIR=/usr/lib/udev + # build static mdassemble for Arch's initramfs + make MDASSEMBLE_AUTO=1 mdassemble + +} + +package() { + cd $srcdir/$pkgname-$pkgver + make INSTALL=/usr/bin/install BINDIR=/usr/bin DESTDIR=$pkgdir UDEVDIR=/usr/lib/udev install + make SYSTEMD_DIR=$pkgdir/usr/lib/systemd/system install-systemd + install -D -m755 mdassemble $pkgdir/usr/bin/mdassemble + install -D -m644 ../mdadm.conf $pkgdir/etc/mdadm.conf + install -D -m644 ../mdadm_install $pkgdir/usr/lib/initcpio/install/mdadm + install -D -m644 ../mdadm_hook $pkgdir/usr/lib/initcpio/hooks/mdadm + install -D -m644 ../mdadm_udev_install $pkgdir/usr/lib/initcpio/install/mdadm_udev +} diff --git a/libre-testing/mdadm/repos/core-x86_64/disable-werror.patch b/libre-testing/mdadm/repos/core-x86_64/disable-werror.patch new file mode 100644 index 000000000..a80a41456 --- /dev/null +++ b/libre-testing/mdadm/repos/core-x86_64/disable-werror.patch @@ -0,0 +1,11 @@ +--- Makefile.old 2011-06-17 09:38:03.269238332 +0200 ++++ Makefile 2011-06-17 09:38:14.122398837 +0200 +@@ -42,7 +42,7 @@ + + CC = $(CROSS_COMPILE)gcc + CXFLAGS ?= -ggdb +-CWFLAGS = -Wall -Werror -Wstrict-prototypes -Wextra -Wno-unused-parameter ++CWFLAGS = -Wall -Wstrict-prototypes -Wextra -Wno-unused-parameter + ifdef WARN_UNUSED + CWFLAGS += -Wp,-D_FORTIFY_SOURCE=2 -O3 + endif diff --git a/libre-testing/mdadm/repos/core-x86_64/linux-3.0.patch b/libre-testing/mdadm/repos/core-x86_64/linux-3.0.patch new file mode 100644 index 000000000..cd9d5473c --- /dev/null +++ b/libre-testing/mdadm/repos/core-x86_64/linux-3.0.patch @@ -0,0 +1,45 @@ +From f161d047eed634b3380262767f955eb888502e88 Mon Sep 17 00:00:00 2001 +From: NeilBrown <neilb@suse.de> +Date: Fri, 17 Jun 2011 22:49:24 +1000 +Subject: [PATCH 1/1] util: correctly parse shorter linux version numbers. + +The next version of Linux might be 3.0. If it is, get_linux_version +will fail. +So make it more robust. + +Reported-by: Namhyung Kim <namhyung@gmail.com> +Reported-by: Milan Broz <mbroz@redhat.com> +Signed-off-by: NeilBrown <neilb@suse.de> +--- + util.c | 10 +++++----- + 1 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/util.c b/util.c +index 10bbe56..55d171a 100644 +--- a/util.c ++++ b/util.c +@@ -146,16 +146,16 @@ int get_linux_version() + { + struct utsname name; + char *cp; +- int a,b,c; ++ int a = 0, b = 0,c = 0; + if (uname(&name) <0) + return -1; + + cp = name.release; + a = strtoul(cp, &cp, 10); +- if (*cp != '.') return -1; +- b = strtoul(cp+1, &cp, 10); +- if (*cp != '.') return -1; +- c = strtoul(cp+1, NULL, 10); ++ if (*cp == '.') ++ b = strtoul(cp+1, &cp, 10); ++ if (*cp == '.') ++ c = strtoul(cp+1, &cp, 10); + + return (a*1000000)+(b*1000)+c; + } +-- +1.7.2.3 + diff --git a/libre-testing/mdadm/repos/core-x86_64/mdadm-fix-udev-rules.patch b/libre-testing/mdadm/repos/core-x86_64/mdadm-fix-udev-rules.patch new file mode 100644 index 000000000..941cadf3a --- /dev/null +++ b/libre-testing/mdadm/repos/core-x86_64/mdadm-fix-udev-rules.patch @@ -0,0 +1,137 @@ +diff --git a/Makefile b/Makefile +index b6edb23..bedef96 100644 +--- a/Makefile ++++ b/Makefile +@@ -253,8 +253,9 @@ + $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4 + $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 + +-install-udev: udev-md-raid.rules +- $(INSTALL) -D -m 644 udev-md-raid.rules $(DESTDIR)/lib/udev/rules.d/64-md-raid.rules ++install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules ++ $(INSTALL) -D -m 644 udev-md-raid-arrays.rules $(DESTDIR)/usr/lib/udev/rules.d/63-md-raid-arrays.rules ++ $(INSTALL) -D -m 644 udev-md-raid-assembly.rules $(DESTDIR)/usr/lib/udev/rules.d/64-md-raid-assembly.rules + + uninstall: + rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm +diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules +new file mode 100644 +index 0000000..883ee4d +--- /dev/null ++++ b/udev-md-raid-arrays.rules +@@ -0,0 +1,35 @@ ++# do not edit this file, it will be overwritten on update ++ ++SUBSYSTEM!="block", GOTO="md_end" ++ ++# handle md arrays ++ACTION!="add|change", GOTO="md_end" ++KERNEL!="md*", GOTO="md_end" ++ ++# partitions have no md/{array_state,metadata_version}, but should not ++# for that reason be ignored. ++ENV{DEVTYPE}=="partition", GOTO="md_ignore_state" ++ ++# container devices have a metadata version of e.g. 'external:ddf' and ++# never leave state 'inactive' ++ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state" ++TEST!="md/array_state", ENV{SYSTEMD_READY}="0", GOTO="md_end" ++ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end" ++LABEL="md_ignore_state" ++ ++IMPORT{program}="/usr/bin/mdadm --detail --export $devnode" ++ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace" ++ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}" ++ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}" ++ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace" ++ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n" ++ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n" ++ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n" ++ ++IMPORT{builtin}="blkid" ++OPTIONS+="link_priority=100" ++OPTIONS+="watch" ++ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" ++ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" ++ ++LABEL="md_end" +diff --git a/udev-md-raid-assembly.rules b/udev-md-raid-assembly.rules +new file mode 100644 +index 0000000..b89775e +--- /dev/null ++++ b/udev-md-raid-assembly.rules +@@ -0,0 +1,19 @@ ++# do not edit this file, it will be overwritten on update ++ ++# assemble md arrays ++ ++SUBSYSTEM!="block", GOTO="md_inc_end" ++ ++# handle potential components of arrays (the ones supported by md) ++ENV{ID_FS_TYPE}=="ddf_raid_member|isw_raid_member|linux_raid_member", GOTO="md_inc" ++GOTO="md_inc_end" ++ ++LABEL="md_inc" ++ ++# remember you can limit what gets auto/incrementally assembled by ++# mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY' ++ACTION=="add", RUN+="/usr/bin/mdadm --incremental $devnode --offroot" ++ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/usr/bin/mdadm -If $name --path $env{ID_PATH}" ++ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/usr/bin/mdadm -If $name" ++ ++LABEL="md_inc_end" +diff --git a/udev-md-raid.rules b/udev-md-raid.rules +deleted file mode 100644 +index cc7f5ef..0000000 +--- a/udev-md-raid.rules ++++ /dev/null +@@ -1,49 +0,0 @@ +-# do not edit this file, it will be overwritten on update +- +-SUBSYSTEM!="block", GOTO="md_end" +- +-# handle potential components of arrays (the ones supported by md) +-ENV{ID_FS_TYPE}=="ddf_raid_member|isw_raid_member|linux_raid_member", GOTO="md_inc" +-GOTO="md_inc_skip" +- +-LABEL="md_inc" +- +-# remember you can limit what gets auto/incrementally assembled by +-# mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY' +-ACTION=="add", RUN+="/sbin/mdadm --incremental $tempnode --offroot" +-ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}" +-ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name" +- +-LABEL="md_inc_skip" +- +-# handle md arrays +-ACTION!="add|change", GOTO="md_end" +-KERNEL!="md*", GOTO="md_end" +- +-# partitions have no md/{array_state,metadata_version}, but should not +-# for that reason be ignored. +-ENV{DEVTYPE}=="partition", GOTO="md_ignore_state" +- +-# container devices have a metadata version of e.g. 'external:ddf' and +-# never leave state 'inactive' +-ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state" +-TEST!="md/array_state", ENV{SYSTEMD_READY}="0", GOTO="md_end" +-ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end" +-LABEL="md_ignore_state" +- +-IMPORT{program}="/sbin/mdadm --detail --export $tempnode" +-ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace" +-ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}" +-ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}" +-ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace" +-ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n" +-ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n" +-ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n" +- +-IMPORT{program}="/sbin/blkid -o udev -p $tempnode" +-OPTIONS+="link_priority=100" +-OPTIONS+="watch" +-ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" +-ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" +- +-LABEL="md_end" diff --git a/libre-testing/mdadm/repos/core-x86_64/mdadm.conf b/libre-testing/mdadm/repos/core-x86_64/mdadm.conf new file mode 100644 index 000000000..36eaa0cc0 --- /dev/null +++ b/libre-testing/mdadm/repos/core-x86_64/mdadm.conf @@ -0,0 +1,67 @@ +# mdadm configuration file +# +# mdadm will function properly without the use of a configuration file, +# but this file is useful for keeping track of arrays and member disks. +# In general, a mdadm.conf file is created, and updated, after arrays +# are created. This is the opposite behavior of /etc/raidtab which is +# created prior to array construction. +# +# +# the config file takes two types of lines: +# +# DEVICE lines specify a list of devices of where to look for +# potential member disks +# +# ARRAY lines specify information about how to identify arrays so +# so that they can be activated +# + + +# You can have more than one device line and use wild cards. The first +# example includes SCSI the first partition of SCSI disks /dev/sdb, +# /dev/sdc, /dev/sdd, /dev/sdj, /dev/sdk, and /dev/sdl. The second +# line looks for array slices on IDE disks. +# +#DEVICE /dev/sd[bcdjkl]1 +#DEVICE /dev/hda1 /dev/hdb1 +# +# The designation "partitions" will scan all partitions found in +# /proc/partitions +DEVICE partitions + + +# ARRAY lines specify an array to assemble and a method of identification. +# Arrays can currently be identified by using a UUID, superblock minor number, +# or a listing of devices. +# +# super-minor is usually the minor number of the metadevice +# UUID is the Universally Unique Identifier for the array +# Each can be obtained using +# +# mdadm -D <md> +# +# To capture the UUIDs for all your RAID arrays to this file, run these: +# to get a list of running arrays: +# # mdadm -D --scan >>/etc/mdadm.conf +# to get a list from superblocks: +# # mdadm -E --scan >>/etc/mdadm.conf +# +#ARRAY /dev/md0 UUID=3aaa0122:29827cfa:5331ad66:ca767371 +#ARRAY /dev/md1 super-minor=1 +#ARRAY /dev/md2 devices=/dev/hda1,/dev/hdb1 +# +# ARRAY lines can also specify a "spare-group" for each array. mdadm --monitor +# will then move a spare between arrays in a spare-group if one array has a +# failed drive but no spare +#ARRAY /dev/md4 uuid=b23f3c6d:aec43a9f:fd65db85:369432df spare-group=group1 +#ARRAY /dev/md5 uuid=19464854:03f71b1b:e0df2edd:246cc977 spare-group=group1 +# + + +# When used in --follow (aka --monitor) mode, mdadm needs a +# mail address and/or a program. To start mdadm's monitor mode, enable +# mdadm.service in systemd. +# +# If the lines are not found, mdadm will exit quietly +#MAILADDR root@mydomain.tld +#PROGRAM /usr/sbin/handle-mdadm-events diff --git a/libre-testing/mdadm/repos/core-x86_64/mdadm_hook b/libre-testing/mdadm/repos/core-x86_64/mdadm_hook new file mode 100755 index 000000000..5371baaca --- /dev/null +++ b/libre-testing/mdadm/repos/core-x86_64/mdadm_hook @@ -0,0 +1,49 @@ +#!/usr/bin/ash + +run_hook() { + local i= mdconfig=/etc/mdadm.conf + + # for partitionable raid, we need to load md_mod first! + modprobe md_mod 2>/dev/null + + if [ -n "$md" ]; then + echo 'DEVICE partitions' >"$mdconfig" + for i in $(cat /proc/cmdline); do + case $i in + # raid + md=[0-9]*,/*) + device=${i%%,*} + device=${device/=/} + array=${i#*,} + echo "ARRAY /dev/$device devices=$array" + ;; + # partitionable raid + md=d[0-9]*,/*) + device=${i%%,*} + device=${device/=/_} + array=${i#*,} + echo "ARRAY /dev/$device devices=$array" + ;; + # raid UUID + md=[0-9]*,[0-9,a-fA-F]*) + device=${i%%,*} + device=${device/=/} + array=${i#*,} + echo "ARRAY /dev/$device UUID=$array" + ;; + # partitionable raid UUID + md=d[0-9]*,[0-9,a-fA-F]*) + device=${i%%,*} + device=${device/=/_} + array=${i#*,} + echo "ARRAY /dev/$device UUID=$array" + ;; + esac + done >>"$mdconfig" + fi + + # assemble everything + [ -s "$mdconfig" ] && /usr/bin/mdassemble +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/libre-testing/mdadm/repos/core-x86_64/mdadm_install b/libre-testing/mdadm/repos/core-x86_64/mdadm_install new file mode 100644 index 000000000..7390509fa --- /dev/null +++ b/libre-testing/mdadm/repos/core-x86_64/mdadm_install @@ -0,0 +1,46 @@ +#!/bin/bash + +build() { + add_checked_modules -f 'dm-' 'drivers/md/*' + + # check if a custom mdadm.conf exists + if grep -q ^ARRAY /etc/mdadm.conf; then + echo "Custom /etc/mdadm.conf file will be used in initramfs for assembling arrays." + add_file "/etc/mdadm.conf" + fi + add_binary "/usr/bin/mdassemble" + add_file "/usr/lib/udev/rules.d/63-md-raid-arrays.rules" + + add_runscript +} + +help() { + cat <<HELPEOF +This hook loads the necessary modules for any raid root device, +and assembles the raid device when run. + +If arrays are defined in /etc/mdadm.conf, the file will be used instead +of command line assembling. + +Command Line Setup: +- for raid arrays with persistent superblocks: + md=<md device no.>,dev0,dev1,...,devn + md=<md device no.>,uuid +- for partitionable raid arrays with persistent superblocks: + md=d<md device no.>,dev0,dev1,...,devn + md=d<md device no.>,uuid + +Parameters: +- <md device no.> = the number of the md device: + 0 means md0, 1 means md1, ... +- <dev0-devn>: e.g. /dev/hda1,/dev/hdc1,/dev/sda1,/dev/sdb1 + or 0900878d:f95f6057:c39a36e9:55efa60a +Examples: +- md=d0,/dev/sda3,/dev/sda4 md=d1,/dev/hda1,/dev/hdb1 + This will setup 2 md partitionable arrays. +- md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1 + This will setup 2 md arrays with persistent superblocks. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/libre-testing/mdadm/repos/core-x86_64/mdadm_udev_install b/libre-testing/mdadm/repos/core-x86_64/mdadm_udev_install new file mode 100644 index 000000000..c01cbaf24 --- /dev/null +++ b/libre-testing/mdadm/repos/core-x86_64/mdadm_udev_install @@ -0,0 +1,25 @@ +#!/bin/bash + +build() { + add_checked_modules -f 'dm-' 'drivers/md/*' + + # check if a custom mdadm.conf exists + if grep -qw ^ARRAY "$BASEDIR/etc/mdadm.conf"; then + echo "Custom /etc/mdadm.conf file will be used in initramfs for assembling arrays." + add_file "/etc/mdadm.conf" + fi + + add_binary "/usr/bin/mdadm" + add_file "/usr/lib/udev/rules.d/63-md-raid-arrays.rules" + add_file "/usr/lib/udev/rules.d/64-md-raid-assembly.rules" +} + +help() { + cat <<HELPEOF +This hook loads the necessary modules for a RAID array and uses incremental +assembly via udev at runtime to create the devices. This hook will NOT work +without the udev hook included on the image. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: |