On Wed, Nov 25, 2009 at 09:25:37AM +0100, Jim Meyering wrote:
kernels=$(ls -1vr /boot/vmlinuz-*.$arch* 2>/dev/null | grep -v
xen; ls -1vr /boot/vmlinuz-* 2>/dev/null | grep -v xen)
if you add ls' -d option, that will prevent a false-positive match
if /boot/vmlinuz-* ever matches a directory containing something whose
name includes "xen".
Also, you can avoid duplicating the "2>/dev/null | grep -v xen" part
by using a single invocatin of ls, and then I noticed that the expansion
of the second glob, /boot/vmlinuz-*, would include anything matched by
the first one, so this is adequate:
kernels=$(ls -1dvr /boot/vmlinuz-* 2>/dev/null | grep -v xen)
diff --git a/appliance/libguestfs-supermin-helper.in
b/appliance/libguestfs-supermin-helper.in
index 69f22e4..a24d905 100755
--- a/appliance/libguestfs-supermin-helper.in
+++ b/appliance/libguestfs-supermin-helper.in
@@ -38,7 +38,8 @@ initrd="$3"
# without arch second.
arch=$(echo "@host_cpu@" | sed 's/^i.86$/i?86/')
-kernels=$(ls -1vr /boot/vmlinuz-*.$arch* 2>/dev/null | grep -v xen; ls -1vr
/boot/vmlinuz-* 2>/dev/null | grep -v xen)
+kernels=$(ls -1dvr /boot/vmlinuz-* 2>/dev/null | grep -v xen)
OK - but we need to keep $arch in there otherwise it would
select the wrong arch kernel ...
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v