Quieten disk-image-get-kernel

disk-image-get-kernel is pretty noisy and you see e.g.:

  $> load-image overcloud-compute.qcow2
  XXX  -d '/tmp/image.lWGCgPoj' -o 'tmp' -i '/home/stack/overcloud-compute.qcow2' --
  Extracting kernel + ramdisk from /home/stack/overcloud-compute.qcow2 and writing them to /tmp/image.lWGCgPoj
  nbd                    17554  0
  nbd                    17554  0
  basename: missing operand
  Try 'basename --help' for more information.
  /dev/nbd0 disconnected
  tmp-vmlinuz,tmp-initrd

Clean all this up so we just get:

  $> load-image overcloud-compute.qcow2
  Extracting kernel + ramdisk from /home/stack/overcloud-compute.qcow2 to tmp-vmlinuz and tmp-initrd in /tmp/image.g6b0lG88

Change-Id: I8971ec0bbcd87157b07fc17254c56bb9f9f2a597
This commit is contained in:
Mark McLoughlin 2013-12-09 12:58:25 +00:00
parent 54c8508d45
commit af8b7f05a1
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 -- "$@"`
echo "XXX $TEMP"
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
@ -73,7 +72,7 @@ source $_LIB/img-defaults
source $_LIB/common-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
@ -87,15 +86,16 @@ RAMDISK=
if [ -f $WORK_DIR/etc/redhat-release ]; then
# 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
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
echo "No suitable kernel found."
exit 1
fi
fi
KERNEL=$(basename $KERNEL)
KERNEL_VERSION=`echo $KERNEL | sed 's/vmlinuz-//g'`
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
unmount_qcow_image
echo "$OUT_PFX-vmlinuz,$OUT_PFX-initrd"

View File

@ -131,7 +131,7 @@ function eval_run_d () {
# Usage: map_nbd $image
# Returns nbd device path
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
CACHE="--cache=writeback"
@ -161,7 +161,7 @@ function map_nbd {
# Delete and unmount the working dir used in extracting kernel/initrd
function unmount_qcow_image () {
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
trap - SIGHUP SIGINT SIGTERM EXIT

View File

@ -45,7 +45,7 @@ function ensure_nbd () {
exit 1
fi
# 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 () {