sys-kernel/genkernel: add mdadm
git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/genlink@2588 6952d904-891a-0410-993b-d76249ca496b
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
From f01e862b38b3219252ee76f7a20179a20a97a0fb Mon Sep 17 00:00:00 2001
|
||||
From: Matthias Dahl <ua_bugz_gentoo@mortal-soul.de>
|
||||
Date: Fri, 27 Aug 2010 17:26:52 +0200
|
||||
Subject: [PATCH] use mdadm instead of bundled stripped down mdassemble (v2)
|
||||
|
||||
mdassemble can't handle newer metadata formats and fails for partitioned
|
||||
arrays, among other things.
|
||||
|
||||
This...
|
||||
|
||||
- replaces the bundled mdassemble with proper support for mdadm
|
||||
- fixes raid autodetection/assemble when no mdadm.conf is available
|
||||
- fixes a compilation failure for newer mdadm versions
|
||||
|
||||
Tested w/ genkernel 3.4.10.907 and mdadm 3.1.3.
|
||||
---
|
||||
defaults/initrd.scripts | 5 +++--
|
||||
gen_compile.sh | 35 +++++++++++++++++++++++++++++++++++
|
||||
gen_determineargs.sh | 2 ++
|
||||
gen_initramfs.sh | 12 ++++++++++++
|
||||
genkernel.conf | 5 +++++
|
||||
5 files changed, 57 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
|
||||
index e0710c4..531d2bd 100755
|
||||
--- a/defaults/initrd.scripts
|
||||
+++ b/defaults/initrd.scripts
|
||||
@@ -608,9 +608,10 @@ startVolumes() {
|
||||
then
|
||||
if [ ! -e '/etc/mdadm.conf' ]
|
||||
then
|
||||
- /sbin/mdadm --examine > /etc/mdadm.conf
|
||||
+ echo "DEVICE /dev/sd[a-z]* /dev/hd[a-z]*" >/etc/mdadm.conf
|
||||
+ /sbin/mdadm --examine --scan >>/etc/mdadm.conf
|
||||
fi
|
||||
- /sbin/mdadm --assemble
|
||||
+ /sbin/mdadm -A --scan
|
||||
fi
|
||||
|
||||
if [ "${USE_DMRAID_NORMAL}" = '1' ]
|
||||
diff --git a/gen_compile.sh b/gen_compile.sh
|
||||
index 7bab9e1..ec5df4b 100755
|
||||
--- a/gen_compile.sh
|
||||
+++ b/gen_compile.sh
|
||||
@@ -444,6 +444,41 @@ compile_lvm() {
|
||||
fi
|
||||
}
|
||||
|
||||
+compile_mdadm() {
|
||||
+ if [ ! -f "${MDADM_BINCACHE}" ]
|
||||
+ then
|
||||
+ [ -f "${MDADM_SRCTAR}" ] ||
|
||||
+ gen_die "Could not find MDADM source tarball: ${MDADM_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
|
||||
+ cd "${TEMP}"
|
||||
+ rm -rf "${MDADM_DIR}" > /dev/null
|
||||
+ /bin/tar -jxpf "${MDADM_SRCTAR}" ||
|
||||
+ gen_die 'Could not extract MDADM source tarball!'
|
||||
+ [ -d "${MDADM_DIR}" ] ||
|
||||
+ gen_die 'MDADM directory ${MDADM_DIR} is invalid!'
|
||||
+
|
||||
+ cd "${MDADM_DIR}"
|
||||
+ sed -i "/^CFLAGS = /s:^CFLAGS = \(.*\)$:CFLAGS = -Os:" Makefile
|
||||
+ sed -i "/^CXFLAGS = /s:^CXFLAGS = \(.*\)$:CXFLAGS = -Os:" Makefile
|
||||
+ sed -i "/^CWFLAGS = /s:^CWFLAGS = \(.*\)$:CWFLAGS = -Wall:" Makefile
|
||||
+ sed -i "s/^# LDFLAGS = -static/LDFLAGS = -static/" Makefile
|
||||
+
|
||||
+ print_info 1 'mdadm: >> Compiling...'
|
||||
+ compile_generic 'mdadm' utils
|
||||
+
|
||||
+ mkdir -p "${TEMP}/mdadm/sbin"
|
||||
+ install -m 0755 -s mdadm "${TEMP}/mdadm/sbin/mdadm"
|
||||
+ print_info 1 ' >> Copying to bincache...'
|
||||
+ cd "${TEMP}/mdadm"
|
||||
+ strip "sbin/mdadm" ||
|
||||
+ gen_die 'Could not strip mdadm!'
|
||||
+ /bin/tar -cjf "${MDADM_BINCACHE}" sbin/mdadm ||
|
||||
+ gen_die 'Could not create binary cache'
|
||||
+
|
||||
+ cd "${TEMP}"
|
||||
+ rm -rf "${MDADM_DIR}" mdadm
|
||||
+ fi
|
||||
+}
|
||||
+
|
||||
compile_dmraid() {
|
||||
compile_device_mapper
|
||||
if [ ! -f "${DMRAID_BINCACHE}" ]
|
||||
diff --git a/gen_determineargs.sh b/gen_determineargs.sh
|
||||
index d911f07..b4b31fb 100755
|
||||
--- a/gen_determineargs.sh
|
||||
+++ b/gen_determineargs.sh
|
||||
@@ -128,6 +128,7 @@ determine_real_args() {
|
||||
BUSYBOX_BINCACHE=`cache_replace "${BUSYBOX_BINCACHE}"`
|
||||
DEVICE_MAPPER_BINCACHE=`cache_replace "${DEVICE_MAPPER_BINCACHE}"`
|
||||
LVM_BINCACHE=`cache_replace "${LVM_BINCACHE}"`
|
||||
+ MDADM_BINCACHE=`cache_replace "${MDADM_BINCACHE}"`
|
||||
DMRAID_BINCACHE=`cache_replace "${DMRAID_BINCACHE}"`
|
||||
ISCSI_BINCACHE=`cache_replace "${ISCSI_BINCACHE}"`
|
||||
BLKID_BINCACHE=`cache_replace "${BLKID_BINCACHE}"`
|
||||
@@ -139,6 +140,7 @@ determine_real_args() {
|
||||
BUSYBOX_BINCACHE=`arch_replace "${BUSYBOX_BINCACHE}"`
|
||||
DEVICE_MAPPER_BINCACHE=`arch_replace "${DEVICE_MAPPER_BINCACHE}"`
|
||||
LVM_BINCACHE=`arch_replace "${LVM_BINCACHE}"`
|
||||
+ MDADM_BINCACHE=`arch_replace "${MDADM_BINCACHE}"`
|
||||
DMRAID_BINCACHE=`arch_replace "${DMRAID_BINCACHE}"`
|
||||
ISCSI_BINCACHE=`arch_replace "${ISCSI_BINCACHE}"`
|
||||
BLKID_BINCACHE=`arch_replace "${BLKID_BINCACHE}"`
|
||||
diff --git a/gen_initramfs.sh b/gen_initramfs.sh
|
||||
index 231411e..2400b75 100755
|
||||
--- a/gen_initramfs.sh
|
||||
+++ b/gen_initramfs.sh
|
||||
@@ -328,10 +328,22 @@ append_mdadm(){
|
||||
fi
|
||||
cd ${TEMP}
|
||||
mkdir -p "${TEMP}/initramfs-mdadm-temp/etc/"
|
||||
+ mkdir -p "${TEMP}/initramfs-mdadm-temp/sbin/"
|
||||
if [ "${MDADM}" -eq '1' ]
|
||||
then
|
||||
cp -a /etc/mdadm.conf "${TEMP}/initramfs-mdadm-temp/etc" \
|
||||
|| gen_die "Could not copy mdadm.conf!"
|
||||
+ if [ -e '/sbin/mdadm' ] && LC_ALL="C" ldd /sbin/mdadm|grep -q 'not a dynamic executable'
|
||||
+ then
|
||||
+ print_info 1 ' MDADM: Adding support (using local static binaries)...'
|
||||
+ cp /sbin/mdadm "${TEMP}/initramfs-mdadm-temp/sbin/mdadm" ||
|
||||
+ gen_die 'Could not copy over mdadm!'
|
||||
+ else
|
||||
+ print_info 1 ' MDADM: Adding support (compiling binaries)...'
|
||||
+ compile_mdadm
|
||||
+ /bin/tar -jxpf "${MDADM_BINCACHE}" -C "${TEMP}/initramfs-mdadm-temp" ||
|
||||
+ gen_die "Could not extract mdadm binary cache!";
|
||||
+ fi
|
||||
fi
|
||||
cd "${TEMP}/initramfs-mdadm-temp/"
|
||||
find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
|
||||
diff --git a/genkernel.conf b/genkernel.conf
|
||||
index a71ce69..62b7801 100644
|
||||
--- a/genkernel.conf
|
||||
+++ b/genkernel.conf
|
||||
@@ -162,6 +162,11 @@ LVM_DIR="LVM2.${LVM_VER}"
|
||||
LVM_SRCTAR="${DISTDIR}/LVM2.${LVM_VER}.tgz"
|
||||
LVM_BINCACHE="%%CACHE%%/LVM2.${LVM_VER}-%%ARCH%%.tar.bz2"
|
||||
|
||||
+MDADM_VER="VERSION_MDADM"
|
||||
+MDADM_DIR="mdadm-${MDADM_VER}"
|
||||
+MDADM_SRCTAR="${DISTDIR}/mdadm-${MDADM_VER}.tar.bz2"
|
||||
+MDADM_BINCACHE="%%CACHE%%/mdadm-${MDADM_VER}-%%ARCH%%.tar.bz2"
|
||||
+
|
||||
DMRAID_VER="VERSION_DMRAID"
|
||||
DMRAID_DIR="dmraid/${DMRAID_VER}"
|
||||
DMRAID_SRCTAR="${DISTDIR}/dmraid-${DMRAID_VER}.tar.bz2"
|
||||
--
|
||||
1.7.2.2
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
Index: genkernel.8
|
||||
===================================================================
|
||||
--- genkernel.8 (.../3.4.10.907-jrg-mod2) (revision 974)
|
||||
+++ genkernel.8 (.../3.4.10.907-jrg-mod3) (revision 974)
|
||||
@@ -47,7 +47,7 @@
|
||||
behaviour. Certain options have ``\fB--no-\fR'' variants which
|
||||
do the opposite thing. You can specify your options in any order.
|
||||
.PP
|
||||
-.BR Debugging \ Options
|
||||
+.BR Debugging\ Options
|
||||
.TP
|
||||
\fB\-\-loglevel=\fR<0-5>
|
||||
This controls the out verbosity level of genkernel output - if this is set
|
||||
@@ -61,7 +61,7 @@
|
||||
\fB\-\-\fR[no\-]\fBcolor\fR
|
||||
Turns on, or off, output in color using escape sequences.
|
||||
.PP
|
||||
-.BR Kernel \ Configuration
|
||||
+.BR Kernel\ Configuration
|
||||
.TP
|
||||
\fB\-\-\fR[no\-]\fBmenuconfig\fR
|
||||
Runs, or does not run "make menuconfig" after running "make oldconfig".
|
||||
@@ -79,7 +79,7 @@
|
||||
.I /etc/kernels
|
||||
if the kernel is successfully compiled.
|
||||
.PP
|
||||
-.BR Kernel \ Compilation
|
||||
+.BR Kernel\ Compilation
|
||||
.TP
|
||||
\fB\-\-\fR[no\-]\fBclean\fR
|
||||
Runs, or does not run, "make clean" before compilation - this erases any
|
||||
@@ -129,11 +129,21 @@
|
||||
Implies \fB\-\-no\-clean\fR, and thus \fB\-\-no\-mrproper\fR, running a
|
||||
"make oldconfig".
|
||||
.TP
|
||||
+\fB\-\-makeopts=\fR<makeopts>
|
||||
+GNU Make options such as \fB\-j2\fR, etc.
|
||||
+.TP
|
||||
+\fB\-\-\fR[no\-]\fBnice\fR
|
||||
+Runs the kernel make at the default niceness (reduction in priority) of 10, or
|
||||
+in the case of --no-nice, runs the kernel make at normal priority.
|
||||
+.TP
|
||||
+\fB\-\-nice=\fR<niceness>
|
||||
+Runs the kernel make at the specified niceness (reduction in priority).
|
||||
+.TP
|
||||
\fB\-\-callback=\fR<...>
|
||||
Run the specified arguments in the current environment after the kernel and
|
||||
modules have been compiled.
|
||||
.PP
|
||||
-.BR Kernel \ Locations
|
||||
+.BR Kernel\ Locations
|
||||
.TP
|
||||
\fB\-\-kerneldir=\fR<dir>
|
||||
This specifies the location of the kernel sources; the default is
|
||||
@@ -144,7 +154,7 @@
|
||||
default genkernel uses the config from the previous build of the same kernel
|
||||
version or a default kernel config if there isn't a previous config.
|
||||
.PP
|
||||
-.BR Low-Level \ Compilation \ Options
|
||||
+.BR Low-Level\ Compilation\ Options
|
||||
.TP
|
||||
\fB\-\-kernel\-cc=\fR<compiler>
|
||||
Compiler to use for the kernel compilation (e.g. distcc).
|
||||
@@ -169,9 +179,6 @@
|
||||
.TP
|
||||
\fB\-\-utils\-make=\fR<makeprog>
|
||||
GNU Make to use for utilities.
|
||||
-.TP
|
||||
-\fB\-\-makeopts=\fR<makeopts>
|
||||
-GNU Make options such as \fB\-j2\fR, etc.
|
||||
.PP
|
||||
.BR Initialization
|
||||
.TP
|
||||
@@ -225,7 +232,7 @@
|
||||
\fB\-\-tempdir=\fR<dir>
|
||||
Sets genkernel's temporary working directory to <dir>.
|
||||
.PP
|
||||
-.BR Output \ Settings
|
||||
+.BR Output\ Settings
|
||||
.TP
|
||||
\fB\-\-kernname=\fR<...>
|
||||
Tag the kernel and initrd with a name, if not defined this option defaults to genkernel
|
||||
Index: gen_compile.sh
|
||||
===================================================================
|
||||
--- gen_compile.sh (.../3.4.10.907-jrg-mod2) (revision 974)
|
||||
+++ gen_compile.sh (.../3.4.10.907-jrg-mod3) (revision 974)
|
||||
@@ -244,24 +244,31 @@
|
||||
esac
|
||||
shift 2
|
||||
|
||||
+ if [ ${NICE} -ne 0 ]
|
||||
+ then
|
||||
+ NICEOPTS="nice -n${NICE} "
|
||||
+ else
|
||||
+ NICEOPTS=""
|
||||
+ fi
|
||||
+
|
||||
# the eval usage is needed in the next set of code
|
||||
# as ARGS can contain spaces and quotes, eg:
|
||||
# ARGS='CC="ccache gcc"'
|
||||
if [ "${argstype}" == 'runtask' ]
|
||||
then
|
||||
- print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS/-j?/-j1} ${ARGS} ${target} $*" 1 0 1
|
||||
- eval ${MAKE} -s ${MAKEOPTS/-j?/-j1} "${ARGS}" ${target} $*
|
||||
+ print_info 2 "COMMAND: ${NICEOPTS}${MAKE} ${MAKEOPTS/-j?/-j1} ${ARGS} ${target} $*" 1 0 1
|
||||
+ eval ${NICEOPTS}${MAKE} -s ${MAKEOPTS/-j?/-j1} "${ARGS}" ${target} $*
|
||||
RET=$?
|
||||
elif [ "${LOGLEVEL}" -gt "1" ]
|
||||
then
|
||||
# Output to stdout and logfile
|
||||
- print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $*" 1 0 1
|
||||
- eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* 2>&1 | tee -a ${LOGFILE}
|
||||
+ print_info 2 "COMMAND: ${NICEOPTS}${MAKE} ${MAKEOPTS} ${ARGS} ${target} $*" 1 0 1
|
||||
+ eval ${NICEOPTS}${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* 2>&1 | tee -a ${LOGFILE}
|
||||
RET=${PIPESTATUS[0]}
|
||||
else
|
||||
# Output to logfile only
|
||||
- print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${1} $*" 1 0 1
|
||||
- eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* >> ${LOGFILE} 2>&1
|
||||
+ print_info 2 "COMMAND: ${NICEOPTS}${MAKE} ${MAKEOPTS} ${ARGS} ${1} $*" 1 0 1
|
||||
+ eval ${NICEOPTS}${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* >> ${LOGFILE} 2>&1
|
||||
RET=$?
|
||||
fi
|
||||
[ "${RET}" -ne '0' ] &&
|
||||
Index: genkernel
|
||||
===================================================================
|
||||
--- genkernel (.../3.4.10.907-jrg-mod2) (revision 974)
|
||||
+++ genkernel (.../3.4.10.907-jrg-mod3) (revision 974)
|
||||
@@ -4,10 +4,6 @@
|
||||
PATH="${PATH}:/sbin:/usr/sbin"
|
||||
GK_V='3.4.10.907'
|
||||
|
||||
-# Set the default for TMPDIR. May be modified by genkernel.conf or the
|
||||
-# --tempdir command line option.
|
||||
-TMPDIR='/var/tmp/genkernel'
|
||||
-
|
||||
TODEBUGCACHE=1 # Until an error occurs or LOGFILE is fully qualified.
|
||||
|
||||
small_die() {
|
||||
@@ -53,8 +49,8 @@
|
||||
}
|
||||
|
||||
cleanup(){
|
||||
- if [ -n "$TEMP" -a -d "$TEMP" ]; then
|
||||
- rm -rf "$TEMP"
|
||||
+ if [ -n "${TEMP}" -a -d "${TEMP}" ]; then
|
||||
+ rm -rf "${TEMP}"
|
||||
fi
|
||||
|
||||
if isTrue ${POSTCLEAR}
|
||||
Index: gen_cmdline.sh
|
||||
===================================================================
|
||||
--- gen_cmdline.sh (.../3.4.10.907-jrg-mod2) (revision 974)
|
||||
+++ gen_cmdline.sh (.../3.4.10.907-jrg-mod3) (revision 974)
|
||||
@@ -47,6 +47,10 @@
|
||||
echo " --static Build a static (monolithic kernel)"
|
||||
echo " --genzimage Build zImage.initrd for PowerPC arch"
|
||||
echo " --no-genzimage Do not build zImage.initrd"
|
||||
+ echo " --nice Run the kernel make at the default nice level (10)."
|
||||
+ echo " --nice=<0-19> Run the kernel make at the selected nice level."
|
||||
+ echo " --no-nice Don't be nice while running the kernel make."
|
||||
+
|
||||
echo " Kernel settings"
|
||||
echo " --kerneldir=<dir> Location of the kernel sources"
|
||||
echo " --kernel-config=<file> Kernel configuration file to use for compilation"
|
||||
@@ -595,6 +599,23 @@
|
||||
--config=*)
|
||||
print_info 2 "CMD_GK_CONFIG: `parse_opt "$*"`"
|
||||
;;
|
||||
+ --nice)
|
||||
+ CMD_NICE=10
|
||||
+ print_info 2 "CMD_NICE: ${CMD_NICE}"
|
||||
+ ;;
|
||||
+ --nice=*)
|
||||
+ CMD_NICE=`parse_opt "$*"`
|
||||
+ if [ ${CMD_NICE} -lt 0 -o ${CMD_NICE} -gt 19 ]
|
||||
+ then
|
||||
+ echo "Error: Illegal value specified for --nice= parameter."
|
||||
+ exit 1
|
||||
+ fi
|
||||
+ print_info 2 "CMD_NICE: ${CMD_NICE}"
|
||||
+ ;;
|
||||
+ --no-nice)
|
||||
+ CMD_NICE=0
|
||||
+ print_info 2 "CMD_NICE: ${CMD_NICE}"
|
||||
+ ;;
|
||||
all)
|
||||
BUILD_KERNEL=1
|
||||
BUILD_MODULES=1
|
||||
Index: gen_determineargs.sh
|
||||
===================================================================
|
||||
--- gen_determineargs.sh (.../3.4.10.907-jrg-mod2) (revision 974)
|
||||
+++ gen_determineargs.sh (.../3.4.10.907-jrg-mod3) (revision 974)
|
||||
@@ -133,6 +133,7 @@
|
||||
set_config_with_override 1 SLOWUSB CMD_SLOWUSB
|
||||
set_config_with_override 2 UTILS_ARCH CMD_UTILS_ARCH
|
||||
set_config_with_override 2 TMPDIR CMD_TMPDIR "/var/tmp/genkernel"
|
||||
+ set_config_with_override 2 NICE CMD_NICE "10"
|
||||
|
||||
BOOTDIR=`arch_replace "${BOOTDIR}"`
|
||||
BOOTDIR=${BOOTDIR%/} # Remove any trailing slash
|
||||
Index: genkernel.conf
|
||||
===================================================================
|
||||
--- genkernel.conf (.../3.4.10.907-jrg-mod2) (revision 974)
|
||||
+++ genkernel.conf (.../3.4.10.907-jrg-mod3) (revision 974)
|
||||
@@ -61,6 +61,9 @@
|
||||
# argument is: <number of processors>*<number of cores per processor>+1
|
||||
# MAKEOPTS="-j2"
|
||||
|
||||
+# Run the kernel make at the following NICE level. Default is 10.
|
||||
+# NICE=10
|
||||
+
|
||||
# Add in LVM support from static binaries if they exist on the system, or
|
||||
# compile static LVM binaries if static ones do not exist.
|
||||
# LVM="no"
|
||||
Reference in New Issue
Block a user