Enhance of initrd hack: Additional drivers loading from osdistroupdate and support the --noupdateinitrd for nodeset command to avoid the initrd hack
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@16873 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
1dd5758ff7
commit
acc28bb0ed
@ -933,9 +933,11 @@ sub mkinstall
|
||||
my $callback = shift;
|
||||
my $doreq = shift;
|
||||
my @nodes = @{$request->{node}};
|
||||
my $noupdateinitrd = $request->{'noupdateinitrd'};
|
||||
#my $sitetab = xCAT::Table->new('site');
|
||||
my $linuximagetab;
|
||||
my $osimagetab;
|
||||
my $osdistrouptab;
|
||||
my %img_hash=();
|
||||
|
||||
my $installroot;
|
||||
@ -1014,6 +1016,7 @@ sub mkinstall
|
||||
my $partfile;
|
||||
my $netdrivers;
|
||||
my $driverupdatesrc;
|
||||
my $osupdir;
|
||||
|
||||
my $ient = $rents{$node}->[0];
|
||||
if ($ient and $ient->{xcatmaster})
|
||||
@ -1037,7 +1040,7 @@ sub mkinstall
|
||||
if (!$osimagetab) {
|
||||
$osimagetab=xCAT::Table->new('osimage', -create=>1);
|
||||
}
|
||||
(my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile', 'provmethod');
|
||||
(my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile', 'provmethod', 'osupdatename');
|
||||
if ($ref) {
|
||||
$img_hash{$imagename}->{osver}=$ref->{'osvers'};
|
||||
$img_hash{$imagename}->{osarch}=$ref->{'osarch'};
|
||||
@ -1093,6 +1096,32 @@ sub mkinstall
|
||||
$img_hash{$imagename}->{pkglist}=$pkglistfile;
|
||||
}
|
||||
}
|
||||
|
||||
# get the path list of the osdistroupdate
|
||||
if ($ref->{'osupdatename'}) {
|
||||
my $osdisupdir;
|
||||
my @osupdatenames = split (/,/, $ref->{'osupdatename'});
|
||||
|
||||
unless ($osdistrouptab) {
|
||||
$osdistrouptab=xCAT::Table->new('osdistroupdate', -create=>1);
|
||||
unless ($osdistrouptab) {
|
||||
$callback->({ error => ["Cannot open the table osdistroupdate."], errorcode => [1] });
|
||||
next;
|
||||
}
|
||||
}
|
||||
my @osdup = $osdistrouptab->getAllAttribs("osupdatename", "dirpath");
|
||||
foreach my $upname (@osupdatenames) {
|
||||
foreach my $upref (@osdup) {
|
||||
if ($upref->{'osupdatename'} eq $upname) {
|
||||
$osdisupdir .= ",$upref->{'dirpath'}";
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$osdisupdir =~ s/^,//;
|
||||
$img_hash{$imagename}->{'osupdir'} = $osdisupdir;
|
||||
}
|
||||
} else {
|
||||
$callback->(
|
||||
{error => ["The os image $imagename does not exists on the osimage table for $node"],
|
||||
@ -1108,7 +1137,7 @@ sub mkinstall
|
||||
$platform=xCAT_plugin::anaconda::getplatform($os);
|
||||
|
||||
$tmplfile=$ph->{template};
|
||||
$pkgdir=$ph->{pkgdir};
|
||||
$pkgdir=$ph->{pkgdir};
|
||||
if (!$pkgdir) {
|
||||
$pkgdir="$installroot/$os/$arch";
|
||||
}
|
||||
@ -1116,6 +1145,7 @@ sub mkinstall
|
||||
|
||||
$netdrivers = $ph->{netdrivers};
|
||||
$driverupdatesrc = $ph->{driverupdatesrc};
|
||||
$osupdir = $ph->{'osupdir'};
|
||||
}
|
||||
else {
|
||||
$os = $ent->{os};
|
||||
@ -1314,8 +1344,10 @@ sub mkinstall
|
||||
copyesxiboot($pkgdir, "$tftppath", osver=>$os);
|
||||
}else{
|
||||
copy($kernpath,"$tftppath");
|
||||
copy($initrdpath,"$tftppath/initrd.img");
|
||||
&insert_dd($callback, $os, $arch, "$tftppath/initrd.img", $driverupdatesrc, $netdrivers);
|
||||
unless ($noupdateinitrd) {
|
||||
copy($initrdpath,"$tftppath/initrd.img");
|
||||
&insert_dd($callback, $os, $arch, "$tftppath/initrd.img", $driverupdatesrc, $netdrivers, $osupdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2379,6 +2411,7 @@ sub insert_dd {
|
||||
my $img = shift;
|
||||
my $driverupdatesrc = shift;
|
||||
my $drivers = shift;
|
||||
my $osupdirlist = shift;
|
||||
|
||||
my $install_dir = xCAT::TableUtils->getInstallDir();
|
||||
|
||||
@ -2394,6 +2427,21 @@ sub insert_dd {
|
||||
|
||||
my @rpm_drivers;
|
||||
|
||||
# since the all rpms for drivers searching will be extracted to one dir, the newer rpm should be
|
||||
# extracted later so that the newer drivers will overwirte the older one if certain drvier is included
|
||||
# in multiple rpms
|
||||
#
|
||||
# The order of rpm list in the @rpm_list should be: osdistroupdate1, osdistroupdate2, driverupdatesrc
|
||||
#
|
||||
# get the kernel-*.rpm from the dirpath of osdistroupdate
|
||||
if ($osupdirlist) {
|
||||
my @osupdirs = split (/,/, $osupdirlist);
|
||||
foreach my $osupdir (@osupdirs) {
|
||||
# find all the rpms start with kernel.*
|
||||
my @kernel_rpms = `find $osupdir -name kernel-*.rpm`;
|
||||
push @rpm_list, @kernel_rpms;
|
||||
}
|
||||
}
|
||||
# Parse the parameters to the the source of Driver update disk and Driver rpm, and driver list as well
|
||||
if ($driverupdatesrc) {
|
||||
my @srcs = split(',', $driverupdatesrc);
|
||||
@ -2514,25 +2562,26 @@ sub insert_dd {
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not read the rpm $rpm.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
|
||||
# To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver
|
||||
# Change it back to xxx.ko here
|
||||
$driver_name = "\*ko.new";
|
||||
@all_real_path = ();
|
||||
find(\&get_all_path, <$dd_dir/rpm/*>);
|
||||
foreach my $file (@all_real_path) {
|
||||
print "$file\n";
|
||||
my $newname = $file;
|
||||
$newname =~ s/\.new$//;
|
||||
$cmd = "mv -f $file $newname";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not move $file.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
|
||||
# To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver
|
||||
# Change it back to xxx.ko here
|
||||
$driver_name = "\*ko.new";
|
||||
@all_real_path = ();
|
||||
find(\&get_all_path, <$dd_dir/rpm/*>);
|
||||
foreach my $file (@all_real_path) {
|
||||
my $newname = $file;
|
||||
$newname =~ s/\.new$//;
|
||||
$cmd = "mv -f $file $newname";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not move $file.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
# The rh6 has different initrd format with old version (rh 5.x)
|
||||
@ -2548,10 +2597,10 @@ print "$file\n";
|
||||
if (@rpm_list && ($Injectalldriver || @driver_list)) {
|
||||
# Copy the firmware to the rootimage
|
||||
if (-d "$dd_dir/rpm/lib/firmware") {
|
||||
if (! -d "$dd_dir/initrd_img/lib") {
|
||||
mkpath "$dd_dir/initrd_img/lib";
|
||||
if (! -d "$dd_dir/initrd_img/lib/firmware") {
|
||||
mkpath "$dd_dir/initrd_img/lib/firmware";
|
||||
}
|
||||
$cmd = "cp -rf $dd_dir/rpm/lib/firmware $dd_dir/initrd_img/lib";
|
||||
$cmd = "/bin/cp -rf $dd_dir/rpm/lib/firmware/* $dd_dir/initrd_img/lib/firmware";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
@ -2571,30 +2620,35 @@ print "$file\n";
|
||||
}
|
||||
|
||||
foreach my $kernelver (@kernelvers) {
|
||||
unless (-d "$dd_dir/rpm/lib/modules/$kernelver") {
|
||||
next;
|
||||
}
|
||||
if (@driver_list) {
|
||||
foreach my $driver (@driver_list) {
|
||||
$driver_name = $driver;
|
||||
$real_path = "";
|
||||
find(\&get_path, <$dd_dir/rpm/lib/modules/$kernelver/*>);
|
||||
if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) {
|
||||
if (! -d "$dd_dir/initrd_img$1") {
|
||||
mkpath "$dd_dir/initrd_img$1";
|
||||
}
|
||||
$cmd = "cp -rf $real_path $dd_dir/initrd_img$1";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not copy driver $driver to the initrd.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
} else {
|
||||
push @rpm_drivers, $driver;
|
||||
@all_real_path = ();
|
||||
find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>);
|
||||
foreach my $real_path (@all_real_path) {
|
||||
if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) {
|
||||
if (! -d "$dd_dir/initrd_img$1") {
|
||||
mkpath "$dd_dir/initrd_img$1";
|
||||
}
|
||||
$cmd = "/bin/cp -rf $real_path $dd_dir/initrd_img$1";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not copy driver $driver to the initrd.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
} else {
|
||||
push @rpm_drivers, $driver;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# copy all the drviers to the rootimage
|
||||
if (-d "$dd_dir/rpm/lib/modules/$kernelver") {
|
||||
$cmd = "cp -rf $dd_dir/rpm/lib/modules/$kernelver $dd_dir/initrd_img/lib/modules/";
|
||||
$cmd = "/bin/cp -rf $dd_dir/rpm/lib/modules/$kernelver $dd_dir/initrd_img/lib/modules/";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
@ -2662,12 +2716,12 @@ print "$file\n";
|
||||
}
|
||||
|
||||
# Copy all the driver files out
|
||||
$cmd = "cp -rf $dd_dir/dd_modules/* $dd_dir/modules";
|
||||
$cmd = "/bin/cp -rf $dd_dir/dd_modules/* $dd_dir/modules";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
|
||||
# Copy the firmware into the initrd
|
||||
mkpath "$dd_dir/initrd_img/firmware";
|
||||
$cmd = "cp -rf $dd_dir/dd_modules/firmware/* $dd_dir/initrd_img/firmware";
|
||||
$cmd = "/bin/cp -rf $dd_dir/dd_modules/firmware/* $dd_dir/initrd_img/firmware";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
|
||||
my $drivername;
|
||||
@ -2739,7 +2793,7 @@ print "$file\n";
|
||||
if (! -d "$dd_dir/initrd_img/lib") {
|
||||
mkpath "$dd_dir/initrd_img/lib";
|
||||
}
|
||||
$cmd = "cp -rf $dd_dir/rpm/lib/firmware $dd_dir/initrd_img";
|
||||
$cmd = "/bin/cp -rf $dd_dir/rpm/lib/firmware $dd_dir/initrd_img";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
@ -2757,6 +2811,9 @@ print "$file\n";
|
||||
}
|
||||
|
||||
foreach my $kernelver (@kernelvers) {
|
||||
unless (-d "$dd_dir/rpm/lib/modules/$kernelver") {
|
||||
next;
|
||||
}
|
||||
# find the $kernelver/$arch dir in the $dd_dir/modules
|
||||
my $arch4modules;
|
||||
foreach (<$dd_dir/modules/$kernelver/*>) {
|
||||
@ -2774,11 +2831,10 @@ print "$file\n";
|
||||
# copy all the specific drviers to the initrd
|
||||
foreach my $driver (@driver_list) {
|
||||
$driver_name = $driver;
|
||||
$real_path = "";
|
||||
find(\&get_path, <$dd_dir/rpm/lib/modules/$kernelver/*>);
|
||||
if ($real_path ) {
|
||||
|
||||
$cmd = "cp -rf $real_path $dd_dir/modules/$kernelver/$arch4modules/";
|
||||
@all_real_path = ();
|
||||
find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>);
|
||||
foreach my $real_path (@all_real_path) {
|
||||
$cmd = "/bin/cp -rf $real_path $dd_dir/modules/$kernelver/$arch4modules/";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
@ -2792,9 +2848,11 @@ print "$file\n";
|
||||
} elsif ($Injectalldriver) {
|
||||
# copy all the drviers to the initrd
|
||||
if (-d "$dd_dir/rpm/lib/modules/$kernelver") {
|
||||
$driver_name = "\*\.ko";
|
||||
@all_real_path = ();
|
||||
find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>);
|
||||
foreach my $driverpath (@all_real_path) {
|
||||
$cmd = "cp -rf $driverpath $dd_dir/modules/$kernelver/$arch4modules/";
|
||||
$cmd = "/bin/cp -rf $driverpath $dd_dir/modules/$kernelver/$arch4modules/";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
@ -2830,7 +2888,7 @@ print "$file\n";
|
||||
$ma = <$dd_dir/modules/$mk/*>;
|
||||
if (-d $ma) {
|
||||
mkpath "$dd_dir/depmod/lib/modules/$mk";
|
||||
xCAT::Utils->runcmd("cp -rf $ma/* $dd_dir/depmod/lib/modules/$mk", -1);
|
||||
xCAT::Utils->runcmd("/bin/cp -rf $ma/* $dd_dir/depmod/lib/modules/$mk", -1);
|
||||
$cmd = "depmod -b $dd_dir/depmod/";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
@ -2941,7 +2999,7 @@ print "$file\n";
|
||||
mkpath("$dd_dir/tmpddmnt");
|
||||
foreach my $dd (@dd_list) {
|
||||
xCAT::Utils->runcmd("mount -o loop $dd $dd_dir/tmpddmnt",-1);
|
||||
xCAT::Utils->runcmd("cp -a $dd_dir/tmpddmnt/* $dd_dir/newddimg",-1);
|
||||
xCAT::Utils->runcmd("/bin/cp -a $dd_dir/tmpddmnt/* $dd_dir/newddimg",-1);
|
||||
xCAT::Utils->runcmd("umount $dd_dir/tmpddmnt",-1);
|
||||
}
|
||||
foreach my $repodir (<$dd_dir/newddimg/*/*/repodata>) {
|
||||
|
@ -699,12 +699,14 @@ sub mkinstall
|
||||
my $doreq = shift;
|
||||
my $globaltftpdir = xCAT::TableUtils->getTftpDir();
|
||||
|
||||
my $noupdateinitrd = $request->{'noupdateinitrd'};
|
||||
my @nodes = @{$request->{node}};
|
||||
my $node;
|
||||
my $ostab = xCAT::Table->new('nodetype');
|
||||
#my $sitetab = xCAT::Table->new('site');
|
||||
my $linuximagetab;
|
||||
my $osimagetab;
|
||||
my $osdistrouptab;
|
||||
|
||||
my $ntents = $ostab->getNodesAttribs($request->{node}, ['os', 'arch', 'profile', 'provmethod']);
|
||||
my %img_hash=();
|
||||
@ -776,6 +778,7 @@ sub mkinstall
|
||||
my $partfile;
|
||||
my $netdrivers;
|
||||
my $driverupdatesrc;
|
||||
my $osupdir;
|
||||
my $imagename; # set it if running of 'nodeset osimage=xxx'
|
||||
if ($resents->{$node} and $resents->{$node}->[0]->{tftpdir}) {
|
||||
$tftpdir = $resents->{$node}->[0]->{tftpdir};
|
||||
@ -789,7 +792,7 @@ sub mkinstall
|
||||
if (!$osimagetab) {
|
||||
$osimagetab=xCAT::Table->new('osimage', -create=>1);
|
||||
}
|
||||
(my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile', 'provmethod');
|
||||
(my $ref) = $osimagetab->getAttribs({imagename => $imagename}, 'osvers', 'osarch', 'profile', 'provmethod', 'osupdatename');
|
||||
if ($ref) {
|
||||
$img_hash{$imagename}->{osver}=$ref->{'osvers'};
|
||||
$img_hash{$imagename}->{osarch}=$ref->{'osarch'};
|
||||
@ -825,6 +828,32 @@ sub mkinstall
|
||||
errorcode => [1]});
|
||||
next;
|
||||
}
|
||||
|
||||
# get the path list of the osdistroupdate
|
||||
if ($ref->{'osupdatename'}) {
|
||||
my $osdisupdir;
|
||||
my @osupdatenames = split (/,/, $ref->{'osupdatename'});
|
||||
|
||||
unless ($osdistrouptab) {
|
||||
$osdistrouptab=xCAT::Table->new('osdistroupdate', -create=>1);
|
||||
unless ($osdistrouptab) {
|
||||
$callback->({ error => ["Cannot open the table osdistroupdate."], errorcode => [1] });
|
||||
next;
|
||||
}
|
||||
}
|
||||
my @osdup = $osdistrouptab->getAllAttribs("osupdatename", "dirpath");
|
||||
foreach my $upname (@osupdatenames) {
|
||||
foreach my $upref (@osdup) {
|
||||
if ($upref->{'osupdatename'} eq $upname) {
|
||||
$osdisupdir .= ",$upref->{'dirpath'}";
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$osdisupdir =~ s/^,//;
|
||||
$img_hash{$imagename}->{'osupdir'} = $osdisupdir;
|
||||
}
|
||||
}
|
||||
my $ph=$img_hash{$imagename};
|
||||
$os = $ph->{osver};
|
||||
@ -840,6 +869,7 @@ sub mkinstall
|
||||
$partfile=$ph->{partitionfile};
|
||||
$netdrivers = $ph->{netdrivers};
|
||||
$driverupdatesrc = $ph->{driverupdatesrc};
|
||||
$osupdir = $ph->{'osupdir'};
|
||||
}
|
||||
else {
|
||||
$os = $ent->{os};
|
||||
@ -996,17 +1026,23 @@ sub mkinstall
|
||||
if ($arch =~ /x86_64/)
|
||||
{
|
||||
copy("$pkgdir/1/boot/$arch/loader/linux", "$tftppath");
|
||||
copy("$pkgdir/1/boot/$arch/loader/initrd", "$tftppath");
|
||||
@dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/initrd", $driverupdatesrc, $netdrivers);
|
||||
unless ($noupdateinitrd) {
|
||||
copy("$pkgdir/1/boot/$arch/loader/initrd", "$tftppath");
|
||||
@dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/initrd", $driverupdatesrc, $netdrivers, $osupdir);
|
||||
}
|
||||
} elsif ($arch =~ /x86/) {
|
||||
copy("$pkgdir/1/boot/i386/loader/linux", "$tftppath");
|
||||
copy("$pkgdir/1/boot/i386/loader/initrd", "$tftppath");
|
||||
@dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/initrd", $driverupdatesrc, $netdrivers);
|
||||
unless ($noupdateinitrd) {
|
||||
copy("$pkgdir/1/boot/i386/loader/initrd", "$tftppath");
|
||||
@dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/initrd", $driverupdatesrc, $netdrivers, $osupdir);
|
||||
}
|
||||
}
|
||||
elsif ($arch =~ /ppc/)
|
||||
{
|
||||
copy("$pkgdir/1/suseboot/inst64", "$tftppath");
|
||||
@dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/inst64", $driverupdatesrc, $netdrivers);
|
||||
unless ($noupdateinitrd) {
|
||||
copy("$pkgdir/1/suseboot/inst64", "$tftppath");
|
||||
@dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/inst64", $driverupdatesrc, $netdrivers, $osupdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1639,6 +1675,7 @@ sub insert_dd () {
|
||||
my $img = shift;
|
||||
my $driverupdatesrc = shift;
|
||||
my $drivers = shift;
|
||||
my $osupdirlist = shift;
|
||||
|
||||
my $install_dir = xCAT::TableUtils->getInstallDir();
|
||||
|
||||
@ -1651,6 +1688,22 @@ sub insert_dd () {
|
||||
|
||||
my @rpm_drivers;
|
||||
|
||||
# since the all rpms for drivers searching will be extracted to one dir, the newer rpm should be
|
||||
# extracted later so that the newer drivers will overwirte the older one if certain drvier is included
|
||||
# in multiple rpms
|
||||
#
|
||||
# The order of rpm list in the @rpm_list should be: osdistroupdate1, osdistroupdate2, driverupdatesrc
|
||||
#
|
||||
# get the kernel-*.rpm from the dirpath of osdistroupdate
|
||||
if ($osupdirlist) {
|
||||
my @osupdirs = split (/,/, $osupdirlist);
|
||||
foreach my $osupdir (@osupdirs) {
|
||||
# find all the rpms start with kernel.*
|
||||
my @kernel_rpms = `find $osupdir -name kernel-*.rpm`;
|
||||
push @rpm_list, @kernel_rpms;
|
||||
}
|
||||
}
|
||||
|
||||
# Parse the parameters to the the source of Driver update disk and Driver rpm, and driver list as well
|
||||
if ($driverupdatesrc) {
|
||||
my @srcs = split(',', $driverupdatesrc);
|
||||
@ -1742,32 +1795,31 @@ sub insert_dd () {
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not read the rpm $rpm.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
|
||||
# To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver
|
||||
# Change it back to xxx.ko here
|
||||
$driver_name = "\*ko.new";
|
||||
@all_real_path = ();
|
||||
find(\&get_all_path, <$dd_dir/rpm/*>);
|
||||
foreach my $file (@all_real_path) {
|
||||
my $newname = $file;
|
||||
$newname =~ s/\.new$//;
|
||||
$cmd = "mv -f $file $newname";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not rename $file.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
# To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver
|
||||
# Change it back to xxx.ko here
|
||||
$driver_name = "\*ko.new";
|
||||
@all_real_path = ();
|
||||
find(\&get_all_path, <$dd_dir/rpm/*>);
|
||||
foreach my $file (@all_real_path) {
|
||||
my $newname = $file;
|
||||
$newname =~ s/\.new$//;
|
||||
$cmd = "mv -f $file $newname";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not rename $file.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Copy the firmware to the rootimage
|
||||
if (-d "$dd_dir/rpm/lib/firmware") {
|
||||
if (! -d "$dd_dir/initrd_img/lib") {
|
||||
mkpath "$dd_dir/initrd_img/lib";
|
||||
}
|
||||
$cmd = "cp -rf $dd_dir/rpm/lib/firmware $dd_dir/initrd_img/lib";
|
||||
$cmd = "/bin/cp -rf $dd_dir/rpm/lib/firmware $dd_dir/initrd_img/lib";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
@ -1785,26 +1837,31 @@ sub insert_dd () {
|
||||
}
|
||||
|
||||
foreach my $kernelver (@kernelvers) {
|
||||
unless (-d "$dd_dir/rpm/lib/modules/$kernelver") {
|
||||
next;
|
||||
}
|
||||
if (@driver_list) {
|
||||
# copy the specific drivers to initrd
|
||||
foreach my $driver (@driver_list) {
|
||||
$driver_name = $driver;
|
||||
$real_path = "";
|
||||
find(\&get_path, <$dd_dir/rpm/lib/modules/$kernelver/*>);
|
||||
@all_real_path = ();
|
||||
find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>);
|
||||
#if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) {
|
||||
# NOTE: for the initrd of sles that the drivers are put in the /lib/modules/$kernelver/initrd/
|
||||
if ($real_path && $real_path =~ m!$dd_dir/rpm/lib/modules/$kernelver/!) {
|
||||
if (! -d "$dd_dir/initrd_img/lib/modules/$kernelver/initrd") {
|
||||
mkpath "$dd_dir/initrd_img/lib/modules/$kernelver/initrd";
|
||||
}
|
||||
$cmd = "cp -rf $real_path $dd_dir/initrd_img/lib/modules/$kernelver/initrd";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not copy driver $driver to the initrd.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
} else {
|
||||
push @rpm_drivers, $driver;
|
||||
foreach my $real_path (@all_real_path) {
|
||||
if ($real_path && $real_path =~ m!$dd_dir/rpm/lib/modules/$kernelver/!) {
|
||||
if (! -d "$dd_dir/initrd_img/lib/modules/$kernelver/initrd") {
|
||||
mkpath "$dd_dir/initrd_img/lib/modules/$kernelver/initrd";
|
||||
}
|
||||
$cmd = "/bin/cp -rf $real_path $dd_dir/initrd_img/lib/modules/$kernelver/initrd";
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Handle the driver update failed. Could not copy driver $driver to the initrd.";
|
||||
xCAT::MsgUtils->message("I", $rsp, $callback);
|
||||
} else {
|
||||
push @rpm_drivers, $driver;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1820,7 +1877,7 @@ sub insert_dd () {
|
||||
if (! -d "$dd_dir/initrd_img/lib/modules/$kernelver/initrd") {
|
||||
mkpath "$dd_dir/initrd_img/lib/modules/$kernelver/initrd";
|
||||
}
|
||||
$cmd = "cp -rf $real_path $dd_dir/initrd_img/lib/modules/$kernelver/initrd";
|
||||
$cmd = "/bin/cp -rf $real_path $dd_dir/initrd_img/lib/modules/$kernelver/initrd";
|
||||
my $driver = basename($real_path);
|
||||
xCAT::Utils->runcmd($cmd, -1);
|
||||
if ($::RUNCMD_RC != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user