Merge "Quieten disk-image-get-kernel"

This commit is contained in:
Jenkins 2013-12-12 16:31:54 +00:00 committed by Gerrit Code Review
commit 37f3c4fe90
3 changed files with 7 additions and 9 deletions

View File

@ -42,7 +42,6 @@ function show_options () {
} }
TEMP=`getopt -o hd:i:o:x -n $SCRIPTNAME -- "$@"` TEMP=`getopt -o hd:i:o:x -n $SCRIPTNAME -- "$@"`
echo "XXX $TEMP"
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential! # Note the quotes around `$TEMP': they are essential!
@ -73,7 +72,7 @@ source $_LIB/img-defaults
source $_LIB/common-functions source $_LIB/common-functions
source $_LIB/img-functions source $_LIB/img-functions
echo "Extracting kernel + ramdisk from $IMAGE_FILE and writing them to $OUT_DIR" echo "Extracting kernel + ramdisk from $IMAGE_FILE to $OUT_PFX-vmlinuz and $OUT_PFX-initrd in $OUT_DIR"
ensure_nbd ensure_nbd
@ -87,15 +86,16 @@ RAMDISK=
if [ -f $WORK_DIR/etc/redhat-release ]; then if [ -f $WORK_DIR/etc/redhat-release ]; then
# Prioritize PAE if present # Prioritize PAE if present
KERNEL=$(basename `ls -1rv $BOOTDIR/vmlinuz* | grep PAE | grep -v debug | head -1` || /bin/true) KERNEL=$(ls -1rv $BOOTDIR/vmlinuz* | grep PAE | grep -v debug | head -1)
if [ ! $KERNEL ]; then if [ ! $KERNEL ]; then
KERNEL=$(basename `ls -1rv $BOOTDIR/vmlinuz* | grep -v debug | head -1` || /bin/true) KERNEL=$(ls -1rv $BOOTDIR/vmlinuz* | grep -v debug | head -1)
if [ ! $KERNEL ]; then if [ ! $KERNEL ]; then
echo "No suitable kernel found." echo "No suitable kernel found."
exit 1 exit 1
fi fi
fi fi
KERNEL=$(basename $KERNEL)
KERNEL_VERSION=`echo $KERNEL | sed 's/vmlinuz-//g'` KERNEL_VERSION=`echo $KERNEL | sed 's/vmlinuz-//g'`
RAMDISK=$(basename `ls $BOOTDIR/initramfs-$KERNEL_VERSION.img`) RAMDISK=$(basename `ls $BOOTDIR/initramfs-$KERNEL_VERSION.img`)
@ -118,5 +118,3 @@ sudo chmod a+r $OUT_DIR/$OUT_PFX-vmlinuz
sudo chmod a+r $OUT_DIR/$OUT_PFX-initrd sudo chmod a+r $OUT_DIR/$OUT_PFX-initrd
unmount_qcow_image unmount_qcow_image
echo "$OUT_PFX-vmlinuz,$OUT_PFX-initrd"

View File

@ -131,7 +131,7 @@ function eval_run_d () {
# Usage: map_nbd $image # Usage: map_nbd $image
# Returns nbd device path # Returns nbd device path
function map_nbd { function map_nbd {
(lsmod | grep '^nbd ') || sudo modprobe nbd max_part=16 (lsmod | grep '^nbd ' >/dev/null) || sudo modprobe nbd max_part=16
if [[ $(qemu-nbd --help | grep cache) == *writeback* ]] ; then if [[ $(qemu-nbd --help | grep cache) == *writeback* ]] ; then
CACHE="--cache=writeback" CACHE="--cache=writeback"
@ -161,7 +161,7 @@ function map_nbd {
# Delete and unmount the working dir used in extracting kernel/initrd # Delete and unmount the working dir used in extracting kernel/initrd
function unmount_qcow_image () { function unmount_qcow_image () {
sudo umount $WORK_DIR || true sudo umount $WORK_DIR || true
sudo qemu-nbd -d $NBD_DEV || true sudo qemu-nbd -d $NBD_DEV >/dev/null || true
sudo rm -rf $WORK_DIR sudo rm -rf $WORK_DIR
trap - SIGHUP SIGINT SIGTERM EXIT trap - SIGHUP SIGINT SIGTERM EXIT

View File

@ -45,7 +45,7 @@ function ensure_nbd () {
exit 1 exit 1
fi fi
# prep nbd for mounting # prep nbd for mounting
(lsmod | grep '^nbd ') || sudo modprobe nbd max_part=16 (lsmod | grep '^nbd ' >/dev/null) || sudo modprobe nbd max_part=16
} }
function ensure_sudo () { function ensure_sudo () {