Ignore basename failures

Commit 0210be22ae introduced the
possibility of basename being called on an empty string.  Because
that can happen in normal operation (such as an x86_64 kernel,
in which case the PAE check will find nothing), don't allow the
basename error to kill the script.  Also ignore failures in the
second basename call so the proper error message is echoed.

Change-Id: I38a18af09ab24fda9c98cbf3ace8fd7acc6faef5
This commit is contained in:
Ben Nemec 2013-10-17 22:32:22 +00:00
parent 53cc353717
commit 237fd64b47

View File

@ -87,9 +87,9 @@ 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`)
KERNEL=$(basename `ls -1rv $BOOTDIR/vmlinuz* | grep PAE | grep -v debug | head -1` || /bin/true)
if [ ! $KERNEL ]; then
KERNEL=$(basename `ls -1rv $BOOTDIR/vmlinuz* | grep -v debug | head -1`)
KERNEL=$(basename `ls -1rv $BOOTDIR/vmlinuz* | grep -v debug | head -1` || /bin/true)
if [ ! $KERNEL ]; then
echo "No suitable kernel found."
exit 1