X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=perl%2Flib%2FSys%2FGuestfs%2FLib.pm;h=b6c4a31f436681c1374df98b4055febe786f6e12;hp=5428b104741e610e2e4ef01d807fef85023cc535;hb=39416cdb11bb2005915ed293eafb3cc6d714416d;hpb=3765f97898a1194d96ab4124e1eb46e25701b3b2 diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm index 5428b10..b6c4a31 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/^(.*) (.*) (.*) (.*) (.*) (.*)$/) { @@ -1825,7 +1837,7 @@ sub _inspect_initrd # Disregard old-style compressed ext2 files and only work with real # compressed cpio files, since cpio takes ages to (fail to) process anything # else. - if ($g->file ($path) =~ /cpio/) { + if ($g->exists($path) && $g->file($path) =~ /cpio/) { eval { @modules = $g->initrd_list ($path); };