Update kdump dracut module to use the latest dracut feature
This commit is contained in:
parent
1c07d2c26b
commit
005c06fa9f
@ -10,48 +10,6 @@ check() {
|
||||
return 0
|
||||
}
|
||||
|
||||
is_lvm() { [[ $(get_fs_type /dev/block/$1) = LVM2_member ]]; }
|
||||
is_mdraid() { [[ -d "/sys/dev/block/$1/md" ]]; }
|
||||
is_btrfs() { get_fs_type /dev/block/$1 | grep -q btrfs; }
|
||||
is_mpath() {
|
||||
[ -e /sys/dev/block/$1/dm/uuid ] || return 1
|
||||
[[ $(cat /sys/dev/block/$1/dm/uuid) =~ ^mpath- ]] && return 0
|
||||
return 1
|
||||
}
|
||||
is_dmraid() { get_fs_type /dev/block/$1 |grep -v linux_raid_member | \
|
||||
grep -q _raid_member; }
|
||||
|
||||
is_iscsi() (
|
||||
[[ -L /sys/dev/block/$1 ]] || return
|
||||
cd "$(readlink -f /sys/dev/block/$1)"
|
||||
until [[ -d sys || -d iscsi_session ]]; do
|
||||
cd ..
|
||||
done
|
||||
[[ -d iscsi_session ]]
|
||||
)
|
||||
|
||||
pull_dracut_modules() {
|
||||
local _dev=$1
|
||||
local _is_uuid=`echo $1 | grep UUID`
|
||||
local _is_label=`echo $1 | grep LABEL`
|
||||
|
||||
if [ -n "$_is_uuid" -o -n "$_is_label" ]
|
||||
then
|
||||
_dev=`findfs $1`
|
||||
fi
|
||||
|
||||
. $dracutfunctions
|
||||
unset MAJOR MINOR
|
||||
eval $(udevadm info --query=env --name="$_dev" | egrep '^(MAJOR|MINOR)')
|
||||
check_block_and_slaves is_btrfs "$MAJOR:$MINOR" && echo -n "btrfs "
|
||||
check_block_and_slaves is_lvm "$MAJOR:$MINOR" && echo -n "lvm "
|
||||
check_block_and_slaves is_mdraid "$MAJOR:$MINOR" && echo -n "mdraid "
|
||||
check_block_and_slaves is_mpath "$MAJOR:$MINOR" && echo -n "multipath "
|
||||
check_block_and_slaves is_iscsi "$MAJOR:$MINOR" && echo -n "iscsi "
|
||||
check_block_and_slaves is_dmraid "$MAJOR:$MINOR" && echo -n "dmraid "
|
||||
unset MAJOR MINOR
|
||||
}
|
||||
|
||||
to_udev_name() {
|
||||
local dev="$1"
|
||||
|
||||
@ -66,31 +24,6 @@ to_udev_name() {
|
||||
echo ${dev#/dev/}
|
||||
}
|
||||
|
||||
add_lvm_code() {
|
||||
local dev="/dev/$(to_udev_name $1)"
|
||||
local lv
|
||||
printf "lvm lvchange -ay --sysinit ">> $moddir/kdump-prepare.sh
|
||||
lv=$(lvm lvdisplay $dev | awk '/LV Name/ {print $3}')
|
||||
echo ${lv#/dev/} >> $moddir/kdump-prepare.sh
|
||||
}
|
||||
|
||||
udevmatch() {
|
||||
case "$1" in
|
||||
UUID=????????-????-????-????-????????????|LABEL=*)
|
||||
printf 'ENV{ID_FS_%s}=="%s"' "${1%%=*}" "${1#*=}"
|
||||
;;
|
||||
UUID=*)
|
||||
printf 'ENV{ID_FS_UUID}=="%s*"' "${1#*=}"
|
||||
;;
|
||||
/dev/?*) printf 'KERNEL=="%s"' "${1#/dev/}" ;;
|
||||
esac
|
||||
printf ', SYMLINK+="'$(to_udev_name $1)'"\n'
|
||||
}
|
||||
|
||||
add_udev_rules() {
|
||||
udevmatch $1 >> $moddir/90-localfs.rules
|
||||
}
|
||||
|
||||
gen_new_conf () {
|
||||
if [ ! -f $2 ]
|
||||
then
|
||||
@ -100,30 +33,15 @@ gen_new_conf () {
|
||||
}
|
||||
|
||||
depends() {
|
||||
local _deps="base shutdown"
|
||||
while read config_opt config_val;
|
||||
do
|
||||
case "$config_opt" in
|
||||
ext[234]|xfs|btrfs|minix|raw)
|
||||
_deps="$_deps `pull_dracut_modules "$config_val"`"
|
||||
;;
|
||||
esac
|
||||
done < /etc/kdump.conf
|
||||
echo $_deps
|
||||
echo "base shutdown"
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
echo -n "" > $moddir/90-localfs.rules
|
||||
printf '#!/bin/sh\n' > $moddir/kdump-prepare.sh
|
||||
chmod +x $moddir/kdump-prepare.sh
|
||||
|
||||
while read config_opt config_val;
|
||||
do
|
||||
case "$config_opt" in
|
||||
ext[234]|xfs|btrfs|minix|raw)
|
||||
add_udev_rules $config_val
|
||||
add_lvm_code $config_val
|
||||
gen_new_conf $config_val /tmp/$$-kdump.conf
|
||||
;;
|
||||
esac
|
||||
@ -133,8 +51,6 @@ install() {
|
||||
inst "/bin/sync" "/bin/sync"
|
||||
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
|
||||
inst "/tmp/$$-kdump.conf" "/etc/kdump.conf"
|
||||
inst_hook pre-pivot 01 "$moddir/kdump-prepare.sh"
|
||||
inst_hook pre-pivot 02 "$moddir/kdump.sh"
|
||||
inst_rules "$moddir/90-localfs.rules"
|
||||
inst_hook pre-pivot 01 "$moddir/kdump.sh"
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
Name: kexec-tools
|
||||
Version: 2.0.2
|
||||
Release: 29%{?dist}
|
||||
Release: 30%{?dist}
|
||||
License: GPLv2
|
||||
Group: Applications/System
|
||||
Summary: The kexec/kdump userspace component.
|
||||
@ -21,7 +21,6 @@ Source13: kexec-tools-po.tar.gz
|
||||
Source14: 98-kexec.rules
|
||||
Source15: kdump.conf.5
|
||||
Source16: kdump.service
|
||||
Source17: mkdumpramfs
|
||||
|
||||
#######################################
|
||||
# These are sources for mkdumpramfs
|
||||
@ -152,7 +151,6 @@ SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu}
|
||||
install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump
|
||||
|
||||
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/sbin/mkdumprd
|
||||
install -m 755 %{SOURCE17} $RPM_BUILD_ROOT/sbin/mkdumpramfs
|
||||
install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf
|
||||
install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8
|
||||
install -m 755 %{SOURCE11} $RPM_BUILD_ROOT%{_datadir}/kdump/firstboot_kdump.py
|
||||
@ -168,6 +166,7 @@ install -m 644 makedumpfile-1.3.5/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/m
|
||||
make -C kexec-tools-po install DESTDIR=$RPM_BUILD_ROOT
|
||||
%find_lang %{name}
|
||||
|
||||
|
||||
# untar the dracut package
|
||||
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf
|
||||
tar -C $RPM_BUILD_ROOT/etc/kdump-adv-conf -jxvf %{SOURCE100}
|
||||
@ -175,9 +174,10 @@ chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/mo
|
||||
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/kdump.sh
|
||||
|
||||
|
||||
%define dracutlibdir %{_prefix}/lib/dracut
|
||||
#and move the custom dracut modules to the dracut directory
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/share/dracut/modules.d/
|
||||
mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/usr/share/dracut/modules.d/
|
||||
mkdir -p $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/
|
||||
mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/
|
||||
|
||||
%post
|
||||
if [ $1 -eq 1 ] ; then
|
||||
@ -285,7 +285,7 @@ done
|
||||
%config(noreplace,missingok) %{_sysconfdir}/sysconfig/kdump
|
||||
%config(noreplace,missingok) %{_sysconfdir}/kdump.conf
|
||||
%config %{_sysconfdir}/udev/rules.d/*
|
||||
%{_datadir}/dracut/modules.d/*
|
||||
%{dracutlibdir}/modules.d/*
|
||||
%dir %{_localstatedir}/crash
|
||||
%{_mandir}/man8/*
|
||||
%{_mandir}/man5/*
|
||||
@ -297,6 +297,9 @@ done
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Dec 16 2011 Cong Wang <xiyou.wangcong@gmail.com> - 2.0.2-30
|
||||
- Update kdump dracut module to use the latest dracut feature.
|
||||
|
||||
* Fri Sep 9 2011 Tom Callaway <spot@fedoraproject.org> - 2.0.2-29
|
||||
- fix systemd scriptlets
|
||||
|
||||
|
31
mkdumprd
31
mkdumprd
@ -10,7 +10,7 @@ export IN_KDUMP=1
|
||||
|
||||
conf_file="/etc/kdump.conf"
|
||||
extra_modules=""
|
||||
dracut_args="-m kdumpbase --add dash -c /dev/null"
|
||||
dracut_args="-m kdumpbase --add dash --add fstab-sys -c /dev/null"
|
||||
|
||||
add_dracut_arg() {
|
||||
dracut_args="$dracut_args $*"
|
||||
@ -40,10 +40,21 @@ while [ $# -gt 0 ]; do
|
||||
esac
|
||||
done
|
||||
|
||||
# $1 target device
|
||||
# $2 if this is a raw dump
|
||||
check_local() {
|
||||
return
|
||||
# Generic substring function. If $2 is in $1, return 0.
|
||||
strstr() { [[ $1 =~ $2 ]]; }
|
||||
|
||||
to_udev_name() {
|
||||
local dev="$1"
|
||||
|
||||
case "$dev" in
|
||||
UUID=*)
|
||||
dev=`blkid -U "${dev#UUID=}"`
|
||||
;;
|
||||
LABEL=*)
|
||||
dev=`blkid -L "${dev#LABEL=}"`
|
||||
;;
|
||||
esac
|
||||
echo ${dev#/dev/}
|
||||
}
|
||||
|
||||
# $1 remote target
|
||||
@ -59,14 +70,20 @@ if [ -n "$conf_file" ]; then
|
||||
extra_modules="$extra_modules $config_val"
|
||||
;;
|
||||
ext[234]|xfs|btrfs|minix)
|
||||
check_local "$config_val" 0
|
||||
add_dracut_arg "--mount $(to_udev_name $config_val)"
|
||||
;;
|
||||
raw)
|
||||
check_local "$config_val" 1
|
||||
#TODO
|
||||
;;
|
||||
net)
|
||||
check_remote "$config_val"
|
||||
if strstr "$config_val" "@";
|
||||
then
|
||||
add_dracut_module "scp"
|
||||
else
|
||||
add_dracut_module "nfs"
|
||||
add_dracut_arg "--mount $config_val"
|
||||
fi
|
||||
;;
|
||||
core_collector)
|
||||
add_dracut_arg "-I ${config_val% *}"
|
||||
|
2
sources
2
sources
@ -2,4 +2,4 @@ d9f2ecd3c3307905f24130a25816e6cc kexec-tools-2.0.0.tar.bz2
|
||||
3e802d638dce0080b910f15908c04a24 kexec-tools-po.tar.gz
|
||||
e3a813bd6d7dace903a05c1296e20d57 makedumpfile-1.3.5.tar.gz
|
||||
8e359dd03731b93a2082bd37cc2a4a4c kexec-tools-2.0.2.tar.bz2
|
||||
ee3ecd074481933b8674d4e2163cd2fb dracut-files.tbz2
|
||||
8b9e1ac8304c1f47f239a6225421ec4e dracut-files.tbz2
|
||||
|
Loading…
Reference in New Issue
Block a user