Skip to content

Commit

Permalink
Merge pull request quattor#1578 from duncanatwork/issue-1577
Browse files Browse the repository at this point in the history
ncm-modprobe: Change mkinitrd references to dracut
  • Loading branch information
jrha committed Mar 10, 2023
2 parents 5995f2e + 2d7ee85 commit e0300c4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions ncm-modprobe/src/main/perl/modprobe.pm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ foreach my $method (qw(alias options install remove blacklist)) {
use strict 'refs';

# Re-generates the initrds, if needed.
sub mkinitrd
sub dracut
{
my ($self) = @_;

Expand All @@ -60,7 +60,7 @@ sub mkinitrd
my $rl = $1;
my $target = "/boot/initrd-$rl.img";
$target = "/boot/initramfs-$rl.img" if -f "/boot/initramfs-$rl.img";
CAF::Process->new(["mkinitrd", "-f", $target, $rl], log => $self)->run();
CAF::Process->new(["dracut", "-f", $target, $rl], log => $self)->run();
$self->error("Unable to build the initrd for $rl") if $?;
}
}
Expand All @@ -83,7 +83,7 @@ sub Configure
$self->process_remove($t, $fh);
$self->process_blacklist($t, $fh);

$self->mkinitrd($fh) if $fh->close();
$self->dracut($fh) if $fh->close();
return 1;
}

Expand Down
6 changes: 3 additions & 3 deletions ncm-modprobe/src/test/perl/configure.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $cmp = Test::MockObject::Extends->new($cmp);

no warnings 'redefine';

my @methods = grep($_ =~ m{^process|mkinitr},
my @methods = grep($_ =~ m{^process|dracut},
@{Class::Inspector->functions("NCM::Component::modprobe")});

foreach my $method (@methods) {
Expand All @@ -49,8 +49,8 @@ foreach my $i (@methods) {

$cmp->Configure($cfg);
foreach my $method (@methods) {
if ($method =~ m{mkinitrd}) {
is($cmp->{uc($method)}, 1, "mkinitrd is not called if there are no changes");
if ($method =~ m{dracut}) {
is($cmp->{uc($method)}, 1, "dracut is not called if there are no changes");
} else {
is($cmp->{uc($method)}, 2, "Method $method is called inconditionally");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
=head1 DESCRIPTION
Test the C<mkinitrd> method.
Test the C<dracut> method.
Ensures the C<mkinitrd> command will be executed for all the
Ensures the C<dracut> command will be executed for all the
C<System.map> files present in a directory.
=cut
Expand All @@ -24,7 +24,7 @@ use NCM::Component::modprobe;
use CAF::FileWriter;
use CAF::Object;

use constant MKINITRD => "mkinitrd -f /boot/initrd-2.6.35.img 2.6.35";
use constant DRACUT => "dracut -f /boot/initrd-2.6.35.img 2.6.35";


my $mock = Test::MockModule->new('NCM::Component::modprobe');
Expand All @@ -36,15 +36,15 @@ $CAF::Object::NoAction = 1;
my $cmp = NCM::Component::modprobe->new("modprobe");


$cmp->mkinitrd();
$cmp->dracut();

my $cmd = get_command(MKINITRD);
ok(defined($cmd), "mkinitrd was called");
my $cmd = get_command(DRACUT);
ok(defined($cmd), "dracut was called");

set_command_status(MKINITRD, 1);
set_command_status(DRACUT, 1);

$cmp->mkinitrd();
is($cmp->{ERROR}, 1, "Errors in mkinitrd are reported");
$cmp->dracut();
is($cmp->{ERROR}, 1, "Errors in dracut are reported");


done_testing();

0 comments on commit e0300c4

Please sign in to comment.