mirror of
https://gitdl.cn/https://github.com/chakralinux/core.git
synced 2025-02-03 03:17:14 +08:00
mdadm moved out of lib/initscriptd too, updated
This commit is contained in:
parent
920e15cb90
commit
37529c4ca9
@ -1,18 +1,17 @@
|
||||
#
|
||||
# Chakra Packages for Chakra, part of chakra-project.org
|
||||
# Core Packages for Chakra, part of chakra-project.org
|
||||
#
|
||||
# maintainer (i686): Phil Miller <philm[at]chakra-project[dog]org>
|
||||
# maintainer (x86_64): Manuel Tortosa <manutortosa[at]chakra-project[dot]org>
|
||||
# maintainer abveritas@chakra-project.org
|
||||
|
||||
pkgname=mdadm
|
||||
pkgver=3.2.1
|
||||
pkgrel=4
|
||||
pkgver=3.2.5
|
||||
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://www.cse.unsw.edu.au/~neilb/source/mdadm/"
|
||||
groups=('base')
|
||||
conflicts=('mkinitcpio<0.5.99')
|
||||
conflicts=('mkinitcpio<0.7')
|
||||
depends=('glibc')
|
||||
backup=('etc/mdadm.conf')
|
||||
source=(ftp://ftp.kernel.org/pub/linux/utils/raid/mdadm/mdadm-$pkgver.tar.bz2
|
||||
@ -20,33 +19,42 @@ source=(ftp://ftp.kernel.org/pub/linux/utils/raid/mdadm/mdadm-$pkgver.tar.bz2
|
||||
mdadm.conf
|
||||
mdadm_install
|
||||
mdadm_hook
|
||||
segfault-3.2.1.patch)
|
||||
install=mdadm.install
|
||||
mdadm_udev_install
|
||||
mdadm.service
|
||||
disable-werror.patch)
|
||||
replaces=('raidtools')
|
||||
|
||||
md5sums=('d1e2549202bd79d9e99f1498d1109530'
|
||||
'6df172c8f77b280018cf87eb3d313f29'
|
||||
md5sums=('83ba4a6249ae24677e915e44c9cfcc58'
|
||||
'8333d405f550317c2bacd5510bf1cb60'
|
||||
'00cbed931db4f15b6ce49e3e7d433966'
|
||||
'865c3d39e5f5dae58388160b563981f1'
|
||||
'1a3eb63832cecd6550f5b0a21d58cfdb'
|
||||
'2fd25605bd1836a33c689ac442cb73ed')
|
||||
'6e1a3377e2ac33e9fb222ab38050c654'
|
||||
'8e02ee595dfa4e5178ed8886e822cf3a'
|
||||
'8450ebbae214e6def01e14b6727d8935'
|
||||
'aafb5f9ac8437a284cbf948b9b13b179'
|
||||
'4ad87b74a4bc9a34621280abe0e0c3e4')
|
||||
|
||||
build() {
|
||||
cd $srcdir/$pkgname-$pkgver
|
||||
patch -Np1 -i ../segfault-3.2.1.patch
|
||||
patch -p0 -i ../disable-werror.patch
|
||||
make CXFLAGS="$CFLAGS"
|
||||
# build static mdassemble for initramfs
|
||||
make MDASSEMBLE_AUTO=1 mdassemble
|
||||
|
||||
}
|
||||
|
||||
package() {
|
||||
cd $srcdir/$pkgname-$pkgver
|
||||
make INSTALL=/bin/install DESTDIR=$pkgdir install
|
||||
install -D -m755 mdassemble $pkgdir/sbin/mdassemble
|
||||
install -D -m644 ../mdadm.conf $pkgdir/etc/mdadm.conf
|
||||
install -D -m755 ../mdadm $pkgdir/etc/rc.d/mdadm
|
||||
install -D -m644 ../mdadm_install $pkgdir/lib/initcpio/install/mdadm
|
||||
install -D -m644 ../mdadm_hook $pkgdir/lib/initcpio/hooks/mdadm
|
||||
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
|
||||
# symlink for backward compatibility
|
||||
ln -sf /lib/initcpio/hooks/mdadm $pkgdir/lib/initcpio/hooks/raid
|
||||
# build static mdassemble for Arch's initramfs
|
||||
make MDASSEMBLE_AUTO=1 mdassemble
|
||||
install -D -m755 mdassemble $pkgdir/sbin/mdassemble
|
||||
ln -sf /usr/lib/initcpio/hooks/mdadm $pkgdir/usr/lib/initcpio/hooks/raid
|
||||
# move /lib/* to /usr/lib/
|
||||
mv $pkgdir/lib/udev $pkgdir/usr/lib/
|
||||
rm -rf $pkgdir/lib
|
||||
# systemd service file
|
||||
install -D -m644 $srcdir/mdadm.service $pkgdir/usr/lib/systemd/system/mdadm.service
|
||||
}
|
||||
|
11
mdadm/disable-werror.patch
Normal file
11
mdadm/disable-werror.patch
Normal file
@ -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 -O
|
||||
endif
|
31
mdadm/mdadm
31
mdadm/mdadm
@ -3,28 +3,33 @@
|
||||
. /etc/rc.conf
|
||||
. /etc/rc.d/functions
|
||||
|
||||
PID=`pidof -o %PPID /sbin/mdadm`
|
||||
case "$1" in
|
||||
pidfile=/run/mdadm.pid
|
||||
if [[ -r $pidfile ]]; then
|
||||
read -r PID <"$pidfile"
|
||||
if [[ $PID && ! -d /proc/$PID ]]; then
|
||||
# stale pidfile
|
||||
unset PID
|
||||
rm -f "$pidfile"
|
||||
fi
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
start)
|
||||
stat_busy "Starting mdadm RAID Monitor"
|
||||
if [ -z "$PID" ]; then
|
||||
/sbin/mdadm --monitor --scan -i /var/run/mdadm.pid -f
|
||||
fi
|
||||
if [ ! -z "$PID" -o $? -gt 0 ]; then
|
||||
stat_fail
|
||||
else
|
||||
if [[ -z $PID ]] && mdadm --monitor --scan -i "$pidfile" -f; then
|
||||
add_daemon mdadm
|
||||
stat_done
|
||||
else
|
||||
stat_fail
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
stat_busy "Stopping mdadm RAID Monitor"
|
||||
[ ! -z "$PID" ] && kill $PID &>/dev/null
|
||||
if [ $? -gt 0 ]; then
|
||||
stat_fail
|
||||
else
|
||||
if [[ $PID ]] && kill "$PID" &>/dev/null; then
|
||||
rm_daemon mdadm
|
||||
stat_done
|
||||
else
|
||||
stat_fail
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
@ -33,5 +38,5 @@ case "$1" in
|
||||
$0 start
|
||||
;;
|
||||
*)
|
||||
echo "usage: $0 {start|stop|restart}"
|
||||
echo "usage: $0 {start|stop|restart}"
|
||||
esac
|
||||
|
@ -1,10 +0,0 @@
|
||||
# arg 1: the new package version
|
||||
# arg 2: the old package version
|
||||
|
||||
post_upgrade() {
|
||||
if [ "$(vercmp $2 2.6.8-2)" -lt 0 -a "$(grep raid_partitions /etc/mkinitcpio.conf)" ]; then
|
||||
echo "Attention mdadm update:"
|
||||
echo "raid_partitions hook has been replaced by the more powerfull mdadm hook."
|
||||
echo "Please update your /etc/mkinitcpio.conf accordingly."
|
||||
fi
|
||||
}
|
8
mdadm/mdadm.service
Normal file
8
mdadm/mdadm.service
Normal file
@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=MDADM Event Monitor
|
||||
|
||||
[Service]
|
||||
ExecStart=/sbin/mdadm --monitor --scan
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,44 +1,47 @@
|
||||
# vim: set ft=sh:
|
||||
run_hook ()
|
||||
{
|
||||
input="$(cat /proc/cmdline)"
|
||||
mdconfig="/etc/mdadm.conf"
|
||||
#!/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 md is specified on commandline, create config file from those parameters.
|
||||
if [ "$(echo $input | grep "md=")" ]; then
|
||||
#Create initial mdadm.conf
|
||||
# scan all devices in /proc/partitions
|
||||
echo DEVICE partitions > $mdconfig
|
||||
for i in $input; do
|
||||
|
||||
if [ -n "$md" ]; then
|
||||
echo 'DEVICE partitions' >"$mdconfig"
|
||||
for i in $(cat /proc/cmdline); do
|
||||
case $i in
|
||||
# raid
|
||||
# raid
|
||||
md=[0-9]*,/*)
|
||||
device="$(echo "$i" | sed -e 's|,/.*||g' -e 's|=||g')"
|
||||
array="$(echo $i | cut -d, -f2-)"
|
||||
echo "ARRAY /dev/$device devices=$array" >> $mdconfig
|
||||
device=${i%%,*}
|
||||
device=${device/=/}
|
||||
array=${i#*,}
|
||||
echo "ARRAY /dev/$device devices=$array"
|
||||
;;
|
||||
# partitionable raid
|
||||
md=d[0-9]*,/*)
|
||||
device="$(echo "$i" | sed -e 's|,/.*||g' -e 's|=|_|g')"
|
||||
array="$(echo $i | cut -d, -f2-)"
|
||||
echo "ARRAY /dev/$device devices=$array" >> $mdconfig
|
||||
device=${i%%,*}
|
||||
device=${device/=/_}
|
||||
array=${i#*,}
|
||||
echo "ARRAY /dev/$device devices=$array"
|
||||
;;
|
||||
# raid UUID
|
||||
md=[0-9]*,[0-9,a-z]*)
|
||||
device="$(echo "$i" | sed -e 's|,.*||g' -e 's|=||g')"
|
||||
array="$(echo $i | cut -d, -f2-)"
|
||||
echo "ARRAY /dev/$device UUID=$array" >> $mdconfig
|
||||
# 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-z]*)
|
||||
device="$(echo "$i" | sed -e 's|,.*||g' -e 's|=|_|g')"
|
||||
array="$(echo $i | cut -d, -f2-)"
|
||||
echo "ARRAY /dev/$device UUID=$array" >> $mdconfig
|
||||
md=d[0-9]*,[0-9,a-fA-F]*)
|
||||
device=${i%%,*}
|
||||
device=${device/=/_}
|
||||
array=${i#*,}
|
||||
echo "ARRAY /dev/$device UUID=$array"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
esac
|
||||
done >>"$mdconfig"
|
||||
fi
|
||||
|
||||
# assemble everything
|
||||
[ -e $mdconfig ] && /sbin/mdassemble
|
||||
}
|
||||
[ -s "$mdconfig" ] && /sbin/mdassemble
|
||||
}
|
||||
|
@ -1,46 +1,43 @@
|
||||
# vim: set ft=sh:
|
||||
#!/bin/bash
|
||||
|
||||
build() {
|
||||
add_checked_modules -f 'dm-' 'drivers/md/*'
|
||||
|
||||
install ()
|
||||
{
|
||||
MODULES=" $(checked_modules "drivers/md/*" | grep -v "dm-") "
|
||||
BINARIES=""
|
||||
FILES=""
|
||||
SCRIPT="mdadm"
|
||||
# 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 "/sbin/mdassemble"
|
||||
add_file "/lib/udev/rules.d/64-md-raid.rules"
|
||||
|
||||
add_runscript
|
||||
}
|
||||
|
||||
help ()
|
||||
{
|
||||
cat<<HELPEOF
|
||||
This hook loads the necessary modules for any raid root device,
|
||||
and assembles the raid device when run.
|
||||
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
|
||||
If arrays are defined in /etc/mdadm.conf, the file will be used instead
|
||||
of command line assembling.
|
||||
|
||||
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.
|
||||
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
|
||||
}
|
||||
|
22
mdadm/mdadm_udev_install
Normal file
22
mdadm/mdadm_udev_install
Normal file
@ -0,0 +1,22 @@
|
||||
#!/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 "mdadm"
|
||||
add_file "/usr/lib/udev/rules.d/64-md-raid.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 with NOT work
|
||||
without the udev hook included on the image.
|
||||
HELPEOF
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
From 4019ad07013a5d8618b867f724d1c4a13c5cb05d Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Liu <net147@gmail.com>
|
||||
Date: Tue, 12 Apr 2011 18:28:01 +1000
|
||||
Subject: [PATCH] Monitor: avoid NULL dereference with 0.90 metadata
|
||||
|
||||
0.90 array do not report the metadata type in /proc/mdstat, so
|
||||
we cannot assume that mse->metadata_version is non-NULL.
|
||||
|
||||
So add an appropriate check.
|
||||
|
||||
This adds an additional check missed by commit
|
||||
eb28e119b03fd5149886ed516fa4bb006ad3602e.
|
||||
|
||||
Signed-off-by: NeilBrown <neilb@suse.de>
|
||||
---
|
||||
Monitor.c | 3 ++-
|
||||
1 files changed, 2 insertions(+), 1 deletions(-)
|
||||
|
||||
diff --git a/Monitor.c b/Monitor.c
|
||||
index a3ea724..55aebeb 100644
|
||||
--- a/Monitor.c
|
||||
+++ b/Monitor.c
|
||||
@@ -577,7 +577,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
|
||||
info[i].major = info[i].minor = 0;
|
||||
}
|
||||
|
||||
- if (strncmp(mse->metadata_version, "external:", 9) == 0 &&
|
||||
+ if (mse->metadata_version &&
|
||||
+ strncmp(mse->metadata_version, "external:", 9) == 0 &&
|
||||
is_subarray(mse->metadata_version+9))
|
||||
st->parent_dev =
|
||||
devname2devnum(mse->metadata_version+10);
|
||||
--
|
||||
1.7.2.3
|
||||
|
||||
From eb28e119b03fd5149886ed516fa4bb006ad3602e Mon Sep 17 00:00:00 2001
|
||||
From: NeilBrown <neilb@suse.de>
|
||||
Date: Tue, 5 Apr 2011 09:16:57 +1000
|
||||
Subject: [PATCH] Monitor: avoid NULL dereference with 0.90 metadata
|
||||
|
||||
0.90 array do not report the metadata type in /proc/mdstat, so
|
||||
we cannot assume that mse->metadata_version is non-NULL.
|
||||
|
||||
So add an appropriate check.
|
||||
|
||||
Reported-by: Eugene <hdejin@yahoo.com>
|
||||
Signed-off-by: NeilBrown <neilb@suse.de>
|
||||
---
|
||||
Monitor.c | 3 ++-
|
||||
1 files changed, 2 insertions(+), 1 deletions(-)
|
||||
|
||||
diff --git a/Monitor.c b/Monitor.c
|
||||
index 291e465..337785d 100644
|
||||
--- a/Monitor.c
|
||||
+++ b/Monitor.c
|
||||
@@ -688,7 +688,8 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
|
||||
st->devnum = mse->devnum;
|
||||
st->percent = -2;
|
||||
st->expected_spares = -1;
|
||||
- if (strncmp(mse->metadata_version, "external:", 9) == 0 &&
|
||||
+ if (mse->metadata_version &&
|
||||
+ strncmp(mse->metadata_version, "external:", 9) == 0 &&
|
||||
is_subarray(mse->metadata_version+9))
|
||||
st->parent_dev =
|
||||
devname2devnum(mse->metadata_version+10);
|
||||
--
|
||||
1.7.2.3
|
||||
|
Loading…
Reference in New Issue
Block a user