commit:     1d0c43bedc00e3365b9e972a91dac11a2c04285c
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 09:41:39 2019 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Sun Jul 14 11:58:16 2019 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=1d0c43be

Rework --mdadm support

Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 defaults/software.sh   | 12 ++++++----
 gen_compile.sh         | 43 ---------------------------------
 gen_initramfs.sh       | 64 ++++++++++++++++++++++++--------------------------
 gkbuilds/mdadm.gkbuild | 35 +++++++++++++++++++++++++++
 4 files changed, 73 insertions(+), 81 deletions(-)

diff --git a/defaults/software.sh b/defaults/software.sh
index 532c520..5df1c0c 100644
--- a/defaults/software.sh
+++ b/defaults/software.sh
@@ -16,11 +16,6 @@ 
GKPKG_BUSYBOX_SRCTAR="${GKPKG_BUSYBOX_SRCTAR:-${DISTDIR}/busybox-${GKPKG_BUSYBOX
 GKPKG_BUSYBOX_SRCDIR="${GKPKG_BUSYBOX_SRCDIR:-busybox-${GKPKG_BUSYBOX_PV}}"
 
GKPKG_BUSYBOX_BINPKG="${GKPKG_BUSYBOX_BINPKG:-%%CACHE%%/busybox-${GKPKG_BUSYBOX_PV}-%%ARCH%%.tar.xz}"
 
-MDADM_VER="${MDADM_VER:-VERSION_MDADM}"
-MDADM_DIR="${MDADM_DIR:-mdadm-${MDADM_VER}}"
-MDADM_SRCTAR="${MDADM_SRCTAR:-${DISTDIR}/mdadm-${MDADM_VER}.tar.xz}"
-MDADM_BINCACHE="${MDADM_BINCACHE:-%%CACHE%%/mdadm-${MDADM_VER}-%%ARCH%%.tar.bz2}"
-
 GKPKG_DMRAID_PN="dmraid"
 GKPKG_DMRAID_PV="${GKPKG_DMRAID_PV:-VERSION_DMRAID}"
 GKPKG_DMRAID_DEPS="lvm"
@@ -77,6 +72,13 @@ GKPKG_LVM_SRCDIR="${GKPKG_LVM_SRCDIR:-LVM2.${GKPKG_LVM_PV}}"
 GKPKG_LVM_SRCTAR="${GKPKG_LVM_SRCTAR:-${DISTDIR}/LVM2.${GKPKG_LVM_PV}.tgz}"
 
GKPKG_LVM_BINPKG="${GKPKG_LVM_BINPKG:-%%CACHE%%/LVM2.${GKPKG_LVM_PV}-%%ARCH%%.tar.xz}"
 
+GKPKG_MDADM_PN="mdadm"
+GKPKG_MDADM_PV="${GKPKG_MDADM_PV:-VERSION_MDADM}"
+GKPKG_MDADM_DEPS=""
+GKPKG_MDADM_SRCDIR="${GKPKG_MDADM_SRCDIR:-mdadm-${GKPKG_MDADM_PV}}"
+GKPKG_MDADM_SRCTAR="${GKPKG_MDADM_SRCTAR:-${DISTDIR}/mdadm-${GKPKG_MDADM_PV}.tar.xz}"
+GKPKG_MDADM_BINPKG="${GKPKG_MDADM_BINPKG:-%%CACHE%%/mdadm-${GKPKG_MDADM_PV}-%%ARCH%%.tar.xz}"
+
 GKPKG_UNIONFS_FUSE_PN="unionfs-fuse"
 GKPKG_UNIONFS_FUSE_PV="${GKPKG_UNIONFS_FUSE_PV:-VERSION_UNIONFS_FUSE}"
 GKPKG_UNIONFS_FUSE_DEPS="fuse"

diff --git a/gen_compile.sh b/gen_compile.sh
index 1c096cb..92efaa0 100755
--- a/gen_compile.sh
+++ b/gen_compile.sh
@@ -529,49 +529,6 @@ compile_kernel() {
        fi
 }
 
-compile_mdadm() {
-       if [ -f "${MDADM_BINCACHE}" ]
-       then
-               print_info 1 "$(getIndent 2)mdadm: >> Using cache ..."
-       else
-               [ -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 -xpf "${MDADM_SRCTAR}" ||
-                       gen_die 'Could not extract MDADM source tarball!'
-               [ -d "${MDADM_DIR}" ] ||
-                       gen_die "MDADM directory ${MDADM_DIR} is invalid!"
-
-               cd "${MDADM_DIR}"
-               apply_patches mdadm ${MDADM_VER}
-               defs='-DNO_DLM -DNO_COROSYNC'
-               sed -i \
-                       -e "/^CFLAGS = /s:^CFLAGS = \(.*\)$:CFLAGS = -Os 
${defs}:" \
-                       -e "/^CXFLAGS = /s:^CXFLAGS = \(.*\)$:CXFLAGS = -Os 
${defs}:" \
-                       -e "/^CWFLAGS = /s:^CWFLAGS = \(.*\)$:CWFLAGS = -Wall:" 
\
-                       -e "s/^# LDFLAGS = -static/LDFLAGS = -static/" \
-                       Makefile || gen_die "Failed to sed mdadm Makefile"
-
-               print_info 1 "$(getIndent 2)mdadm: >> Compiling ..."
-               compile_generic 'mdadm mdmon' utils
-
-               mkdir -p "${TEMP}/mdadm/sbin"
-               install -m 0755 -s mdadm "${TEMP}/mdadm/sbin/mdadm" || gen_die 
"Failed mdadm install"
-               install -m 0755 -s mdmon "${TEMP}/mdadm/sbin/mdmon" || gen_die 
"Failed mdmon install"
-               print_info 1 "$(getIndent 2)mdadm: >> Copying to bincache ..."
-               cd "${TEMP}/mdadm"
-               ${UTILS_CROSS_COMPILE}strip "sbin/mdadm" "sbin/mdmon" ||
-                       gen_die 'Could not strip mdadm binaries!'
-               /bin/tar -cjf "${MDADM_BINCACHE}" sbin/mdadm sbin/mdmon ||
-                       gen_die 'Could not create binary cache'
-
-               cd "${TEMP}"
-               isTrue "${CMD_DEBUGCLEANUP}" && rm -rf "${MDADM_DIR}" mdadm
-               return 0
-       fi
-}
-
 determine_busybox_config_file() {
        print_info 2 "$(get_indent 3)busybox: >> Checking for suitable busybox 
configuration ..."
 

diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index fc756d0..3971fd7 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -508,48 +508,46 @@ append_lvm() {
                || gen_die "Failed to append lvm to cpio!"
 }
 
-append_mdadm(){
-       if [ -d "${TEMP}/initramfs-mdadm-temp" ]
+append_mdadm() {
+       local PN=mdadm
+       local TDIR="${TEMP}/initramfs-${PN}-temp"
+       if [ -d "${TDIR}" ]
        then
-               rm -r "${TEMP}/initramfs-mdadm-temp/"
+               rm -r "${TDIR}" || gen_die "Failed to clean out existing 
'${TDIR}'!"
        fi
-       cd ${TEMP}
-       mkdir -p "${TEMP}/initramfs-mdadm-temp/etc/"
-       mkdir -p "${TEMP}/initramfs-mdadm-temp/sbin/"
-       if isTrue "${MDADM}"
-       then
-               if [ -n "${MDADM_CONFIG}" ]
-               then
-                       if [ -f "${MDADM_CONFIG}" ]
-                       then
-                               cp -a "${MDADM_CONFIG}" 
"${TEMP}/initramfs-mdadm-temp/etc/mdadm.conf" \
-                               || gen_die "Could not copy mdadm.conf!"
-                       else
-                               gen_die "${MDADM_CONFIG} does not exist!"
-                       fi
-               else
-                       print_info 1 "$(getIndent 2)MDADM: Skipping inclusion 
of mdadm.conf"
-               fi
 
-               if [ -e '/sbin/mdadm' ] && LC_ALL="C" ldd /sbin/mdadm | grep -q 
'not a dynamic executable' \
-               && [ -e '/sbin/mdmon' ] && LC_ALL="C" ldd /sbin/mdmon | grep -q 
'not a dynamic executable'
+       populate_binpkg ${PN}
+
+       mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!"
+       cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
+
+       local mydir=
+       for mydir in \
+               etc \
+               sbin \
+       ; do
+               mkdir -p "${TDIR}"/${mydir} || gen_die "Failed to create 
'${TDIR}/${mydir}'!"
+       done
+
+       unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}"
+
+       if [ -n "${MDADM_CONFIG}" ]
+       then
+               if [ -f "${MDADM_CONFIG}" ]
                then
-                       print_info 1 "$(getIndent 2)MDADM: Adding support 
(using local static binaries /sbin/mdadm and /sbin/mdmon)..."
-                       cp /sbin/mdadm /sbin/mdmon 
"${TEMP}/initramfs-mdadm-temp/sbin/" ||
-                               gen_die 'Could not copy over mdadm!'
+                       cp -aL "${MDADM_CONFIG}" "${TDIR}"/etc/mdadm.conf 
2>/dev/null \
+                               || gen_die "Failed to copy '${MDADM_CONFIG}'!"
                else
-                       print_info 1 "$(getIndent 2)MDADM: Adding support 
(compiling binaries)..."
-                       compile_mdadm
-                       /bin/tar -xpf "${MDADM_BINCACHE}" -C 
"${TEMP}/initramfs-mdadm-temp" ||
-                               gen_die "Could not extract mdadm binary cache!";
+                       gen_die "Specified '${MDADM_CONFIG}' does not exist!"
                fi
+       else
+               print_info 2 "$(get_indent 2)${PN}: >> --mdadm-config not set; 
Skipping inclusion of mdadm.conf ..."
        fi
-       cd "${TEMP}/initramfs-mdadm-temp/"
+
+       cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
        log_future_cpio_content
        find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
-                       || gen_die "compressing mdadm cpio"
-       cd "${TEMP}"
-       rm -rf "${TEMP}/initramfs-mdadm-temp" > /dev/null
+               || gen_die "Failed to append ${PN} to cpio!"
 }
 
 append_zfs(){

diff --git a/gkbuilds/mdadm.gkbuild b/gkbuilds/mdadm.gkbuild
new file mode 100644
index 0000000..504a905
--- /dev/null
+++ b/gkbuilds/mdadm.gkbuild
@@ -0,0 +1,35 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+src_prepare() {
+       default
+
+       local defs='-DNO_DLM -DNO_COROSYNC'
+       sed -i \
+               -e "/^CFLAGS = /s:^CFLAGS = \(.*\)$:CFLAGS = -Os ${defs}:" \
+               -e "/^CXFLAGS = /s:^CXFLAGS = \(.*\)$:CXFLAGS = -Os ${defs}:" \
+               -e "/^CWFLAGS = /s:^CWFLAGS = \(.*\)$:CWFLAGS = -Wall:" \
+               -e "s/^# LDFLAGS = -static/LDFLAGS = -static/" \
+               Makefile \
+               || die "Failed to sed mdadm Makefile"
+}
+
+src_compile() {
+       gkmake V=1 mdadm mdmon
+}
+
+src_install() {
+       mkdir -p "${D}"/sbin || die "Failed to create '${D}/sbin'!"
+
+       cp -a mdadm "${D}"/sbin/ \
+               || die "Failed to copy '${S}/mdadm' to '${D}/sbin/'!"
+
+       "${STRIP}" --strip-all "${D}"/sbin/mdadm \
+               || die "Failed to strip '${D}/sbin/mdadm'!"
+
+       cp -a mdmon "${D}"/sbin/ \
+               || die "Failed to copy '${D}/sbin/mdmon' to '${D}/sbin/'!"
+
+       "${STRIP}" --strip-all "${D}"/sbin/mdmon \
+               || die "Failed to strip '${D}/sbin/mdmon'!"
+}

Reply via email to