Change the insert_dd function for handling the initrd hacking.
This commit is contained in:
parent
6588a4e05f
commit
cc888734aa
@ -2492,19 +2492,26 @@ sub insert_dd {
|
||||
} elsif ( grep (/LZMA compressed data/, @format)) {
|
||||
$initrdfmt = "lzma";
|
||||
} else {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Could not handle the format of the initrd.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
return ();
|
||||
# check whether it can be handled by xz
|
||||
$cmd = "xz -t $img";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Could not handle the format of the initrd.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
return ();
|
||||
} else {
|
||||
$initrdfmt = "lzma";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($initrdfmt eq "gzip") {
|
||||
$cmd = "gunzip -c $img > $dd_dir/initrd";
|
||||
} elsif ($initrdfmt eq "lzma") {
|
||||
if (! -x "/usr/bin/lzma") {
|
||||
if (! -x "/usr/bin/xz") {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "The format of initrd for the target node is \'lzma\', but this management node has not lzma command.";
|
||||
push @{$rsp->{data}}, "The format of initrd for the target node is \'lzma\', but this management node has not xz command.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
return ();
|
||||
}
|
||||
@ -2678,7 +2685,7 @@ sub insert_dd {
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not generate the depdency for the drivers in the initrd.";
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not generate the drivers depdency for $kernelver in the initrd.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
@ -2984,7 +2991,7 @@ sub insert_dd {
|
||||
if ($initrdfmt eq "gzip") {
|
||||
$cmd = "cd $dd_dir/initrd_img; find .|cpio -H newc -o|gzip -9 -c - > $dd_dir/initrd.img";
|
||||
} elsif ($initrdfmt eq "lzma") {
|
||||
$cmd = "cd $dd_dir/initrd_img; find .|cpio -H newc -o|lzma -C crc32 -9 > $dd_dir/initrd.img";
|
||||
$cmd = "cd $dd_dir/initrd_img; find .|cpio -H newc -o|xz --format=lzma -C crc32 -9 > $dd_dir/initrd.img";
|
||||
}
|
||||
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
@ -3052,13 +3059,23 @@ sub insert_dd {
|
||||
|
||||
my $rsp;
|
||||
if (@dd_list) {
|
||||
push @{$rsp->{data}}, "Inserted the driver update disk:".join(',',@inserted_dd).".";
|
||||
push @{$rsp->{data}}, "The driver update disk:".join(',',@inserted_dd)." have been injected to initrd.";
|
||||
}
|
||||
if (@driver_list) {
|
||||
push @{$rsp->{data}}, "Inserted the drivers:".join(',', sort(@rpm_drivers))." from driver packages.";
|
||||
} elsif (@rpm_list && ($Injectalldriver || @driver_list)) {
|
||||
push @{$rsp->{data}}, "Inserted the drivers from driver packages:".join(',', sort(@rpm_list)).".";
|
||||
# remove the duplicated names
|
||||
my %dnhash;
|
||||
foreach (@rpm_drivers) {
|
||||
$dnhash{$_} = 1;
|
||||
}
|
||||
@rpm_drivers = keys %dnhash;
|
||||
|
||||
if (@rpm_list) {
|
||||
if (@driver_list) {
|
||||
push @{$rsp->{data}}, "The drivers:".join(',', sort(@rpm_drivers))." from ".join(',', sort(@rpm_list))." have been injected to initrd.";
|
||||
} elsif ($Injectalldriver) {
|
||||
push @{$rsp->{data}}, "All the drivers from :".join(',', sort(@rpm_list))." have been injected to initrd.";
|
||||
}
|
||||
}
|
||||
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
|
||||
return @inserted_dd;
|
||||
|
@ -7,6 +7,7 @@ BEGIN
|
||||
|
||||
use strict;
|
||||
use lib "$::XCATROOT/lib/perl";
|
||||
use File::Path;
|
||||
use File::Copy;
|
||||
use xCAT::MsgUtils;
|
||||
use xCAT::TableUtils;
|
||||
@ -127,6 +128,9 @@ sub geninitrd {
|
||||
$tftpdir = $t_entry;
|
||||
}
|
||||
my $tftppath = "$tftpdir/xcat/osimage/$osimage";
|
||||
unless (-d $tftppath) {
|
||||
mkpath $tftppath;
|
||||
}
|
||||
if ($arch =~ /x86/) {
|
||||
if ($osvers =~ /(^ol[0-9].*)|(centos.*)|(rh.*)|(fedora.*)|(SL.*)/) {
|
||||
$kernelpath = "$tftppath/vmlinuz";
|
||||
|
@ -1783,9 +1783,9 @@ sub insert_dd () {
|
||||
}
|
||||
|
||||
# get the new kernel if it exists in the update distro
|
||||
my @new_kernels = <$dd_dir/rpm/boot/vmlinuz*>;
|
||||
my @new_kernels = <$dd_dir/rpm/boot/vmlinu*>;
|
||||
foreach my $new_kernel (@new_kernels) {
|
||||
if (-r $new_kernel && $new_kernel =~ /\/vmlinuz-(.*(x86_64|ppc64))$/) {
|
||||
if (-r $new_kernel && $new_kernel =~ /\/vmlinu[zx]-(.*(x86_64|ppc64|default))$/) {
|
||||
$new_kernel_ver = $1;
|
||||
$cmd = "/bin/mv -f $new_kernel $dd_dir/rpm/newkernel";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
@ -1909,34 +1909,32 @@ sub insert_dd () {
|
||||
}
|
||||
}
|
||||
} # end of loading drivers from rpm packages
|
||||
}
|
||||
|
||||
# Create the dir for driver update disk
|
||||
mkpath("$dd_dir/initrd_img/cus_driverdisk");
|
||||
# Create the dir for driver update disk
|
||||
mkpath("$dd_dir/initrd_img/cus_driverdisk");
|
||||
|
||||
# insert the driver update disk into the cus_driverdisk dir
|
||||
foreach my $dd (@dd_list) {
|
||||
copy($dd, "$dd_dir/initrd_img/cus_driverdisk");
|
||||
}
|
||||
# insert the driver update disk into the cus_driverdisk dir
|
||||
foreach my $dd (@dd_list) {
|
||||
copy($dd, "$dd_dir/initrd_img/cus_driverdisk");
|
||||
}
|
||||
|
||||
# Repack the initrd
|
||||
# In order to avoid the runcmd add the '2>&1' at end of the cpio
|
||||
# cmd, the echo cmd is added at the end
|
||||
$cmd = "cd $dd_dir/initrd_img; find . -print | cpio -H newc -o > $dd_dir/initrd | echo";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Handle the driver update disk failed. Could not pack the hacked initrd.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
return ();
|
||||
}
|
||||
# Repack the initrd
|
||||
# In order to avoid the runcmd add the '2>&1' at end of the cpio
|
||||
# cmd, the echo cmd is added at the end
|
||||
$cmd = "cd $dd_dir/initrd_img; find . -print | cpio -H newc -o > $dd_dir/initrd | echo";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Handle the driver update disk failed. Could not pack the hacked initrd.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
return ();
|
||||
}
|
||||
|
||||
# zip the initrd
|
||||
#move ("$dd_dir/initrd.new", "$dd_dir/initrd");
|
||||
$cmd = "gzip -f $dd_dir/initrd";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
# zip the initrd
|
||||
#move ("$dd_dir/initrd.new", "$dd_dir/initrd");
|
||||
$cmd = "gzip -f $dd_dir/initrd";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
|
||||
if ($arch =~/ppc/ || (@rpm_list && ($Injectalldriver || @driver_list))) {
|
||||
if ($arch =~/ppc/) {
|
||||
if (-r "$dd_dir/rpm/newkernel") {
|
||||
# if there's new kernel from update distro, then use it
|
||||
@ -1980,12 +1978,21 @@ sub insert_dd () {
|
||||
|
||||
my $rsp;
|
||||
if (@dd_list) {
|
||||
push @{$rsp->{data}}, "Inserted the driver update disk:".join(',', sort(@dd_list)).".";
|
||||
push @{$rsp->{data}}, "The driver update disk:".join(',',@dd_list)." have been injected to initrd.";
|
||||
}
|
||||
if (@driver_list) {
|
||||
push @{$rsp->{data}}, "Inserted the drivers:".join(',', sort(@rpm_drivers))." from driver packages.";
|
||||
} elsif (@rpm_list && ($Injectalldriver || @driver_list)) {
|
||||
push @{$rsp->{data}}, "Inserted the drivers from driver packages:".join(',', sort(@rpm_list)).".";
|
||||
# remove the duplicated names
|
||||
my %dnhash;
|
||||
foreach (@rpm_drivers) {
|
||||
$dnhash{$_} = 1;
|
||||
}
|
||||
@rpm_drivers = keys %dnhash;
|
||||
|
||||
if (@rpm_list) {
|
||||
if (@driver_list) {
|
||||
push @{$rsp->{data}}, "The drivers:".join(',', sort(@rpm_drivers))." from ".join(',', sort(@rpm_list))." have been injected to initrd.";
|
||||
} elsif ($Injectalldriver) {
|
||||
push @{$rsp->{data}}, "All the drivers from :".join(',', sort(@rpm_list))." have been injected to initrd.";
|
||||
}
|
||||
}
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user