From 5f4d31dfd0eb71c4001afcc6d32a610060901c04 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Mon, 6 Feb 2012 08:05:54 +0000 Subject: [PATCH] copy_binaries, multipath: refactor for ease of use and readability. Signed-off-by: Robin H. Johnson --- ChangeLog | 3 +++ gen_initramfs.sh | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0dec7c5..6c2a7d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ # Distributed under the GPL v2 # $Id$ + 06 Feb 2012; Robin H. Johnson gen_initramfs.sh: + Refactor copy_binaries and multipath slightly for ease of usage and readability. + 06 Feb 2012: Richard Yao gen_initramfs.sh: Refactor multipath initramfs generation using copy_binaries. diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 02e6554..43fd77f 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -4,11 +4,14 @@ CPIO_ARGS="--quiet -o -H newc" copy_binaries() { - - local destdir=$1 files=$2 - - # Copy files - lddtree $files | tr ')(' '\n' |awk '/=>/{ if($3 ~ /^\//){print $3}}' | sort | uniq | cpio -p --make-directories --dereference --quiet $destdir + local destdir=$1 + shift + lddtree "$@" \ + | tr ')(' '\n' \ + | awk '/=>/{ if($3 ~ /^\//){print $3}}' \ + | sort \ + | uniq \ + | cpio -p --make-directories --dereference --quiet $destdir } @@ -159,13 +162,10 @@ append_multipath(){ rm -r "${TEMP}/initramfs-multipath-temp" fi print_info 1 ' Multipath support being added' - mkdir -p "${TEMP}/initramfs-multipath-temp/bin/" - mkdir -p "${TEMP}/initramfs-multipath-temp/etc/" - mkdir -p "${TEMP}/initramfs-multipath-temp/sbin/" - mkdir -p "${TEMP}/initramfs-multipath-temp/lib/" + mkdir -p "${TEMP}"/initramfs-multipath-temp/{bin,etc,sbin,lib}/ # Copy files - copy_binaries "${TEMP}/initramfs-multipath-temp" "$(echo /sbin/{multipath,kpartx,mpath_prio_*,devmap_name,dmsetup} /lib64/udev/scsi_id /bin/mountpoint)" + copy_binaries "${TEMP}/initramfs-multipath-temp" /sbin/{multipath,kpartx,mpath_prio_*,devmap_name,dmsetup} /lib64/udev/scsi_id /bin/mountpoint if [ -x /sbin/multipath ] then -- 2.26.2