git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Warn instead of dying if grub refers to non-existent kernel
[libguestfs.git]
/
perl
/
lib
/
Sys
/
Guestfs
/
Lib.pm
diff --git
a/perl/lib/Sys/Guestfs/Lib.pm
b/perl/lib/Sys/Guestfs/Lib.pm
index
b5b3906
..
8ec487d
100644
(file)
--- 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") {
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/^(.*) (.*) (.*) (.*) (.*)$/) {
@lines = sort @lines;
foreach (@lines) {
if (m/^(.*) (.*) (.*) (.*) (.*)$/) {
@@
-1483,10
+1489,16
@@
sub _check_for_applications
}
}
} elsif (defined $package_format && $package_format eq "deb") {
}
}
} 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/^(.*) (.*) (.*) (.*) (.*) (.*)$/) {
@lines = sort @lines;
foreach (@lines) {
if (m/^(.*) (.*) (.*) (.*) (.*) (.*)$/) {
@@
-1631,8
+1643,14
@@
sub _check_for_kernels
}
$config{cmdline} = join(' ', @args) if(scalar(@args) > 0);
}
$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)) {
# Check the kernel was recognised
if(defined($kernel)) {