X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=perl%2Flib%2FSys%2FGuestfs%2FLib.pm;h=8ec487dcd30499e9d9c795b06264c20caff2810f;hb=a57f15a0c434797c45b334f9ace5f18a3bef610a;hp=b5b3906c8fc49d2d077906888fbdf754001f8d0a;hpb=9ac07ee0c28fdd75e0a7393c69374ddff3a40ac9;p=libguestfs.git diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm index b5b3906..8ec487d 100644 --- a/perl/lib/Sys/Guestfs/Lib.pm +++ b/perl/lib/Sys/Guestfs/Lib.pm @@ -1463,10 +1463,16 @@ sub _check_for_applications if ($osn eq "linux") { my $package_format = $os->{package_format}; if (defined $package_format && $package_format eq "rpm") { - my @lines = $g->command_lines - (["rpm", - "-q", "-a", - "--qf", "%{name} %{epoch} %{version} %{release} %{arch}\n"]); + my @lines = (); + eval { + @lines = $g->command_lines + (["rpm", + "-q", "-a", "--qf", + "%{name} %{epoch} %{version} %{release} %{arch}\n"]); + }; + + warn(__x("Error running rpm -qa: {error}", error => $@)) if ($@); + @lines = sort @lines; foreach (@lines) { if (m/^(.*) (.*) (.*) (.*) (.*)$/) { @@ -1483,10 +1489,16 @@ sub _check_for_applications } } } elsif (defined $package_format && $package_format eq "deb") { - my @lines = $g->command_lines - (["dpkg-query", - "-f", '${Package} ${Version} ${Architecture} ${Status}\n', - "-W"]); + my @lines = (); + eval { + @lines = $g->command_lines + (["dpkg-query", + "-f", '${Package} ${Version} ${Architecture} ${Status}\n', + "-W"]); + }; + + warn(__x("Error running dpkg-query: {error}", error => $@)) if ($@); + @lines = sort @lines; foreach (@lines) { if (m/^(.*) (.*) (.*) (.*) (.*) (.*)$/) { @@ -1631,8 +1643,14 @@ sub _check_for_kernels } $config{cmdline} = join(' ', @args) if(scalar(@args) > 0); - my $kernel = - inspect_linux_kernel($g, $path, $os->{package_format}); + my $kernel; + if ($g->exists($path)) { + $kernel = + inspect_linux_kernel($g, $path, $os->{package_format}); + } else { + warn __x("grub refers to {path}, which doesn't exist\n", + path => $path); + } # Check the kernel was recognised if(defined($kernel)) {