+sub add_kernel +{ + my $self = shift; + my $kernel_arch = "i386"; # XXX: Need to get this from inspection! + + my $g = $self->{g}; + + my $filename = $self->match_file('kernel', $kernel_arch); + + # Inspect the rpm to work out what kernel version it contains + my $version; + foreach my $file ($g->command_lines(["rpm", "-qlp", $filename])) {
Hi Matthew, not that I'm qualified to comment on this but it seems this is very rpm/RedHat specific. Would it make sense to abstrǎct the package format from the very beginning by introducing some thin wrappers: On Fri, Jul 24, 2009 at 10:34:21PM +0100, Matthew Booth wrote: [..snip..] list_pkg
+ if($file =~ m{^/boot/vmlinuz-(.*)$}) { + $version = $1; + last; + } + } + + die(__x"{filename} doesn't contain a valid kernel\n", + filename => $filename) if(!defined($version)); + + $self->install_rpm($filename); + + # Make augeas reload so it'll find the new kernel + $g->aug_load(); + + return $version; +} + +sub remove_kernel +{ + my $self = shift; + my $version = shift; + + my $g = $self->{g}; + eval { + # Work out which rpm contains the kernel + my $rpm = $g->command(["rpm", "-qf", "/boot/vmlinuz-".$version]); grep_pkg
+ + $g->command(["rpm", "-e", $rpm]); + }; + + die($@) if($@); +} + +sub add_application +{ + my $self = shift; + my $label = shift; + my $user_arch = "i386"; # XXX: Need to get this from inspection! + + my $filename = $self->match_file($label, $user_arch); + $self->install_rpm($filename); install_pkg
+} + +sub remove_application +{ + my $self = shift; + my $name = shift; + + my $g = $self->{g}; + eval { + $g->command(["rpm", "-e", $name]); remove_pkg
We could then hook in deb based distros more easily by looking at $desc->{package_format}. Cheers, -- Guido