From f3f5a30ac97a64305922376c380685609060db8c Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Mon, 18 May 2009 01:16:41 +0000 Subject: [PATCH] Adding functionality to mkdumprd2 --- kdump_build_helpers/generate_module_list | 2 +- kdump_build_helpers/populate_kdump_std_files | 36 ++++++++++ mkdumprd2 | 75 +------------------- mkdumprd2_functions | 48 +++++++++++++ 4 files changed, 87 insertions(+), 74 deletions(-) create mode 100755 kdump_build_helpers/populate_kdump_std_files create mode 100755 mkdumprd2_functions diff --git a/kdump_build_helpers/generate_module_list b/kdump_build_helpers/generate_module_list index 62ff5e3..e8b9a32 100755 --- a/kdump_build_helpers/generate_module_list +++ b/kdump_build_helpers/generate_module_list @@ -14,7 +14,7 @@ do do bname=$(basename $j) cp $j $STAGE_DIR/modules - grep -q $bname $STAGE_DIR/modules 2>/dev/null + grep -q $bname $STAGE_DIR/etc/module_load_list 2>/dev/null # Add the module to the list if its not already there # or if the list doesn't yet exist diff --git a/kdump_build_helpers/populate_kdump_std_files b/kdump_build_helpers/populate_kdump_std_files new file mode 100755 index 0000000..0e92943 --- /dev/null +++ b/kdump_build_helpers/populate_kdump_std_files @@ -0,0 +1,36 @@ +#!/bin/sh + + +. /etc/kdump-adv-conf/mkdumprd2_functions + +STAGE_DIR=$1/stage + +# We of course need busybox +install_with_deps /sbin/busybox 755 + +# And we need to link all the apps busybox provides in +for i in `/sbin/busybox | + awk 'BEGIN {found=0} /.*/ { if (found) print $0 } /Currently/ {found=1}' | + sed -e's/,//g' -e's/busybox//g'` +do + ln -s busybox $STAGE_DIR/sbin/$i +done + +# We always get kpartx, dmsetup, lvm and mdadm +for i in /sbin/lvm /sbin/kpartx /sbin/mdadm /sbin/dmsetup +do + install_with_deps $i 755 +done + +# We also want to suck in all the runtime scripts +# that make life easier inside the initramfs +# These don't need deps, because they're all msh scripts +for i in `ls /etc/kdump-adv-conf/kdump_build_helpers/` +do + if [ -f $i ] + then + install --mode=755 $i $STAGE_DIR/bin + fi +done + +exit 0 diff --git a/mkdumprd2 b/mkdumprd2 index 5d76963..e21f449 100755 --- a/mkdumprd2 +++ b/mkdumprd2 @@ -8,7 +8,7 @@ # initramfs files for use with kdump ######################################################### - +. /etc/kdump-adv-conf/mkdumprd2_functions ######################################################## #Global Variables @@ -72,7 +72,7 @@ cleanup_and_exit() ######################################################### setup_env() { - PATH=$PATH:/etc/kdump-adv-conf/kdump_build_helpers + PATH=/etc/kdump-adv-conf/kdump_build_helpers:$PATH } @@ -141,74 +141,6 @@ create_initramfs_dirs() $(cd $STAGE_DIR; ln -s bin sbin) } -load_dependent_libs() -{ - local BIN=$1 - ldd $BIN | grep -q "not a dynamic executable" - if [ $? == 0 ] - then - #There are no dependencies, we're done - return - fi - - ldd $BIN | grep -q "statically linked" - if [ $? == 0 ] - then - #There are no dependencies, we're done - return - fi - - for LIB in `ldd $BIN | awk '/\// {if ($2 == "=>") { print $3} else {print $1}}'` - do - load_dependent_libs $LIB - if [ ! -f $STAGE_DIR/$LIB ] - then - install --mode=755 $LIB $STAGE_DIR/$LIB - fi - done - return -} - -install_with_deps() -{ - local BIN=$1 - local MODE=$2 - - install --mode=$MODE $BIN $STAGE_DIR/bin - load_dependent_libs $BIN -} - -populate_std_files() -{ - # We of course need busybox - install_with_deps /sbin/busybox 755 - - # And we need to link all the apps busybox provides in - for i in `/sbin/busybox | - awk 'BEGIN {found=0} /.*/ { if (found) print $0 } /Currently/ {found=1}' | - sed -e's/,//g' -e's/busybox//g'` - do - ln -s busybox $STAGE_DIR/sbin/$i - done - - # We always get kpartx, dmsetup, lvm and mdadm - for i in /sbin/lvm /sbin/kpartx /sbin/mdadm /sbin/dmsetup - do - install_with_deps $i 755 - done - - # We also want to suck in all the runtime scripts - # that make life easier inside the initramfs - # These don't need deps, because they're all msh scripts - for i in `ls /etc/kdump-adv-conf/kdump_build_helpers/` - do - if [ -f $i ] - then - install --mode=755 $i $STAGE_DIR/bin - fi - done - -} ######################################################### #This function is the recepie for populating our initramfs @@ -220,9 +152,6 @@ prep_std_initramfs() { #start by creating the directories we need create_initramfs_dirs - - #copy in the standard included files - populate_std_files } diff --git a/mkdumprd2_functions b/mkdumprd2_functions new file mode 100755 index 0000000..00a82da --- /dev/null +++ b/mkdumprd2_functions @@ -0,0 +1,48 @@ +#!/bin/sh + +########################################################## +#File: mkdumprd2 +#Author: Neil Horman +#Copyright 2009 Red Hat, Inc. +#Summary: A vastly simplified infrastructure for creating +# initramfs files for use with kdump +######################################################### + +load_dependent_libs() +{ + local BIN=$1 + local LIB="" + + ldd $BIN | grep -q "not a dynamic executable" + if [ $? == 0 ] + then + #There are no dependencies, we're done + return + fi + + ldd $BIN | grep -q "statically linked" + if [ $? == 0 ] + then + #There are no dependencies, we're done + return + fi + + for LIB in `ldd $BIN | awk '/\// {if ($2 == "=>") { print $3} else {print $1}}'` + do + load_dependent_libs $LIB + if [ ! -e $STAGE_DIR/$LIB ] + then + install --mode=755 $LIB $STAGE_DIR/$LIB + fi + done + return +} + +install_with_deps() +{ + local BIN=$1 + local MODE=$2 + + install --mode=$MODE $BIN $STAGE_DIR/bin + load_dependent_libs $BIN +}