From 9574253194c744f84ca5f8309e7858f279a97366 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 19 Nov 2013 05:48:40 -0500 Subject: [PATCH] Code drop for new requirement: Add a new flag --ignorekernelchk for nodeset, geninitrd and genimage commands to skip the kernel version checking when injecting drivers from osimage.driverupdatesrc --- xCAT-client/bin/genimage | 8 +- xCAT-server/lib/xcat/plugins/anaconda.pm | 97 +++++++++++++++++--- xCAT-server/lib/xcat/plugins/destiny.pm | 7 +- xCAT-server/lib/xcat/plugins/genimage.pm | 3 + xCAT-server/lib/xcat/plugins/geninitrd.pm | 23 +++-- xCAT-server/lib/xcat/plugins/sles.pm | 81 ++++++++++++---- xCAT-server/share/xcat/netboot/rh/genimage | 20 ++++ xCAT-server/share/xcat/netboot/sles/genimage | 20 ++++ 8 files changed, 219 insertions(+), 40 deletions(-) diff --git a/xCAT-client/bin/genimage b/xCAT-client/bin/genimage index a3c48af57..c1adb296e 100755 --- a/xCAT-client/bin/genimage +++ b/xCAT-client/bin/genimage @@ -42,6 +42,7 @@ my $mode; my $interactive; my $onlyinitrd; my $dryrun; +my $ignorekernelchk; #----------------------------------------------------------------------------- =head3 print_usage - usage message @@ -55,7 +56,7 @@ sub print_usage print " genimage\n\n"; print " genimage --dryrun\n\n"; print ' genimage -o [-a ] -p -i -n [--onlyinitrd] [-r ] [-k ] [-g ] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission ] [--interactive] [--dryrun]'."\n\n"; - print ' genimage [-o ] [-a ] [-p ] [-i ] [-n ] [--onlyinitrd] [-r ] [-k ] [-g ] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission ] [--interactive] [--dryrun] '."\n\n"; + print ' genimage [-o ] [-a ] [-p ] [-i ] [-n ] [--onlyinitrd] [-r ] [-k ] [-g ] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission ] [--interactive] [--dryrun] [--ignorekernelchk] '."\n\n"; print " --permission is used for statelite only\n"; print " -g is used for SLES only\n\n"; print " -m is used for urbuntu, debian and fedora12 only\n\n"; @@ -88,6 +89,7 @@ if (!GetOptions( 'interactive' => \$interactive, 'onlyinitrd' => \$onlyinitrd, 'dryrun' => \$dryrun, + 'ignorekernelchk' => \$ignorekernelchk, 'h|help' => \$help, 'v|version' => \$version, )) { @@ -404,6 +406,10 @@ if ($dryrun) { push @arg, "--dryrun"; } +if ($ignorekernelchk) { + push @arg, "--ignorekernelchk"; +} + my $cmdref; push (@{$cmdref->{arg}}, @arg); $cmdref->{command}->[0] = "genimage"; diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 3b637c0c2..1ca7040aa 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -173,6 +173,7 @@ sub mknetboot my @args = @{$req->{arg}} if(exists($req->{arg})); my @nodes = @{$req->{node}}; my $noupdateinitrd = $req->{'noupdateinitrd'}; + my $ignorekernelchk = $req->{'ignorekernelchk'}; my $ostab = xCAT::Table->new('nodetype'); #my $sitetab = xCAT::Table->new('site'); my $linuximagetab; @@ -935,6 +936,7 @@ sub mkinstall my $doreq = shift; my @nodes = @{$request->{node}}; my $noupdateinitrd = $request->{'noupdateinitrd'}; + my $ignorekernelchk = $request->{'ignorekernelchk'}; #my $sitetab = xCAT::Table->new('site'); my $linuximagetab; my $osimagetab; @@ -1347,7 +1349,7 @@ sub mkinstall unless ($noupdateinitrd) { copy($kernpath,"$tftppath"); copy($initrdpath,"$tftppath/initrd.img"); - &insert_dd($callback, $os, $arch, "$tftppath/initrd.img", "$tftppath/vmlinuz", $driverupdatesrc, $netdrivers, $osupdir); + &insert_dd($callback, $os, $arch, "$tftppath/initrd.img", "$tftppath/vmlinuz", $driverupdatesrc, $netdrivers, $osupdir, $ignorekernelchk); } } } @@ -2418,6 +2420,7 @@ sub insert_dd { my $driverupdatesrc = shift; my $drivers = shift; my $osupdirlist = shift; + my $ignorekernelchk = shift; my $install_dir = xCAT::TableUtils->getInstallDir(); @@ -2428,6 +2431,7 @@ sub insert_dd { my @dd_list; my @rpm_list; + my @vendor_rpm; # the rpms from driverupdatesrc attribute my @driver_list; my $Injectalldriver; my $updatealldriver; @@ -2457,8 +2461,10 @@ sub insert_dd { push @dd_list, $1; } elsif ($src =~ /rpm:(.*)/i) { push @rpm_list, $1; + push @vendor_rpm, $1; } else { push @rpm_list, $src; + push @vendor_rpm, $src; } } } @@ -2487,6 +2493,7 @@ sub insert_dd { chomp(@dd_list); chomp(@rpm_list); + chomp(@vendor_rpm); unless (@dd_list || (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list))) { return (); @@ -2595,24 +2602,48 @@ sub insert_dd { } } } - - # 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 = "/bin/mv -f $file $newname"; - xCAT::Utils->runcmd($cmd, -1); - if ($::RUNCMD_RC != 0) { + } + + # Extract files from vendor rpm when $ignorekernelchk is specified + if ($ignorekernelchk) { + mkpath "$dd_dir/vendor_rpm"; + foreach my $rpm (@vendor_rpm) { + if (-r $rpm) { + $cmd = "cd $dd_dir/vendor_rpm; rpm2cpio $rpm | cpio -idum"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not extract files from the rpm $rpm."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } else { my $rsp; - push @{$rsp->{data}}, "Handle the driver update failed. Could not move $file."; + 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 = (); + my @rpmfiles = <$dd_dir/rpm/*>; + if ($ignorekernelchk) { + push @rpmfiles, <$dd_dir/vendor_rpm/*>; + } + find(\&get_all_path, @rpmfiles); + foreach my $file (@all_real_path) { + my $newname = $file; + $newname =~ s/\.new$//; + $cmd = "/bin/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) @@ -2673,9 +2704,27 @@ sub insert_dd { } foreach my $kernelver (@kernelvers) { + # if $ignorekernelchk is specified, copy all files from vendor_rpm dir to target kernel dir + if ($ignorekernelchk) { + my @kernelpath4vrpm = <$dd_dir/vendor_rpm/lib/modules/*>; + foreach my $path (@kernelpath4vrpm) { + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { + mkpath "$dd_dir/rpm/lib/modules/$kernelver"; + } + $cmd = "/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not copy driver $path from vendor rpm."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } + } + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { next; } + if (@driver_list) { foreach my $driver (@driver_list) { $driver =~ s/\.gz$//; @@ -2892,9 +2941,27 @@ sub insert_dd { } foreach my $kernelver (@kernelvers) { + # if $ignorekernelchk is specified, copy all files from vendor_rpm dir to target kernel dir + if ($ignorekernelchk) { + my @kernelpath4vrpm = <$dd_dir/vendor_rpm/lib/modules/*>; + foreach my $path (@kernelpath4vrpm) { + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { + mkpath "$dd_dir/rpm/lib/modules/$kernelver"; + } + $cmd = "/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not copy driver $path from vendor rpm."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } + } + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { next; } + # create path for the new kernel in the modules package unless (-d "$dd_dir/modules/$kernelver") { mkpath ("$dd_dir/modules/$kernelver/$arch/"); @@ -3145,7 +3212,7 @@ sub insert_dd { if (@rpm_drivers) { 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."; + push @{$rsp->{data}}, "All the drivers from: ".join(',', sort(@rpm_list))." have been injected to initrd."; } else { push @{$rsp->{data}}, "No driver was injected to initrd."; } diff --git a/xCAT-server/lib/xcat/plugins/destiny.pm b/xCAT-server/lib/xcat/plugins/destiny.pm index 71cc52fa2..bcc75b2cc 100644 --- a/xCAT-server/lib/xcat/plugins/destiny.pm +++ b/xCAT-server/lib/xcat/plugins/destiny.pm @@ -93,7 +93,9 @@ sub setdestiny { @ARGV = @{$req->{arg}}; my $noupdateinitrd; - GetOptions('noupdateinitrd' => \$noupdateinitrd,); + my $ignorekernelchk; + GetOptions('noupdateinitrd' => \$noupdateinitrd, + 'ignorekernelchk' => \$ignorekernelchk,); my $state = $ARGV[0]; my $reststates; @@ -304,7 +306,8 @@ sub setdestiny { $errored=0; $subreq->({command=>["mk$tempstate"], node=>$samestatenodes, - noupdateinitrd=>$noupdateinitrd}, \&relay_response); + noupdateinitrd=>$noupdateinitrd, + ignorekernelchk=>$ignorekernelchk,}, \&relay_response); if ($errored) { $callback->({error=>"Some nodes failed to set up $state resources, aborting"}); return; diff --git a/xCAT-server/lib/xcat/plugins/genimage.pm b/xCAT-server/lib/xcat/plugins/genimage.pm index 9108dec90..aa700a737 100644 --- a/xCAT-server/lib/xcat/plugins/genimage.pm +++ b/xCAT-server/lib/xcat/plugins/genimage.pm @@ -69,6 +69,7 @@ sub process_request { my $onlyinitrd; my $tempfile; my $dryrun; + my $ignorekernelchk; GetOptions( 'a=s' => \$arch, @@ -88,6 +89,7 @@ sub process_request { 'onlyinitrd' => \$onlyinitrd, 'tempfile=s' => \$tempfile, 'dryrun' => \$dryrun, + 'ignorekernelchk' => \$ignorekernelchk, ); my $osimagetab; @@ -306,6 +308,7 @@ sub process_request { if (!$dryrun) { $cmd .= " --tempfile $tempfile"; } } if ($driverupdatesrc) { $cmd .= " --driverupdatesrc $driverupdatesrc"; } + if ($ignorekernelchk) { $cmd .= " --ignorekernelchk $ignorekernelchk"; } if($osfamily eq "sles") { my @entries = xCAT::TableUtils->get_site_attribute("timezone"); diff --git a/xCAT-server/lib/xcat/plugins/geninitrd.pm b/xCAT-server/lib/xcat/plugins/geninitrd.pm index 18782cb99..5e499ba25 100644 --- a/xCAT-server/lib/xcat/plugins/geninitrd.pm +++ b/xCAT-server/lib/xcat/plugins/geninitrd.pm @@ -28,15 +28,20 @@ sub preprocess_request my $usage = sub { my $callback = shift; - xCAT::MsgUtils->message("I", {data=>["Usage: geninitrd [-h | --help]"]}, $callback); + xCAT::MsgUtils->message("I", {data=>["Usage: geninitrd [--ignorekernelchk] [-h | --help]"]}, $callback); }; my $osimage; + my $ignorekernelchk; if (defined ($req->{arg})) { foreach (@{$req->{arg}}) { if (/^-/) { - $usage->($callback); - return; + if (/--ignorekernelchk/) { + $ignorekernelchk = 1; + } else { + $usage->($callback); + return; + } }else { $osimage = $_; } @@ -51,11 +56,13 @@ sub preprocess_request return; } + $req->{'ignorekernelchk'} = [$ignorekernelchk]; + #if tftpshared is not set, dispatch this command to all the service nodes my @entries = xCAT::TableUtils->get_site_attribute("sharedtftp"); my $t_entry = $entries[0]; if ( defined($t_entry) and ($t_entry == 0 or $t_entry =~ /no/i)) { - $req->{'_disparatetftp'}=[1]; + $req->{'_disparatetftp'} = [1]; return xCAT::Scope->get_broadcast_scope($req,@_); } return [$req]; @@ -81,6 +88,10 @@ sub geninitrd { my $doreq = shift; my $osimage = $req->{arg}->[0]; + my $ignorekernelchk; + if (defined ($req->{'ignorekernelchk'}) && $req->{'ignorekernelchk'}->[0]) { + $ignorekernelchk = $req->{'ignorekernelchk'}->[0]; + } my ($osvers, $arch, $pkgdir, $driverupdatesrc, $netdrivers, $osdisupdir); @@ -218,10 +229,10 @@ sub geninitrd { # 2. Inject the drivers to initrd in /tftpboot base on the new kernel ver if ($osvers =~ /(^ol[0-9].*)|(centos.*)|(rh.*)|(fedora.*)|(SL.*)/) { require xCAT_plugin::anaconda; - xCAT_plugin::anaconda->insert_dd($callback, $osvers, $arch, $initrdpath, $kernelpath, $driverupdatesrc, $netdrivers, $osdisupdir); + xCAT_plugin::anaconda->insert_dd($callback, $osvers, $arch, $initrdpath, $kernelpath, $driverupdatesrc, $netdrivers, $osdisupdir, $ignorekernelchk); } elsif ($osvers =~ /(sles.*)|(suse.*)/) { require xCAT_plugin::sles; - xCAT_plugin::sles->insert_dd($callback, $osvers, $arch, $initrdpath, $kernelpath, $driverupdatesrc, $netdrivers, $osdisupdir); + xCAT_plugin::sles->insert_dd($callback, $osvers, $arch, $initrdpath, $kernelpath, $driverupdatesrc, $netdrivers, $osdisupdir, $ignorekernelchk); } } diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index febea7b88..85f4bd297 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -56,6 +56,7 @@ sub mknetboot my $nodes = @{$req->{node}}; my @nodes = @{$req->{node}}; my $noupdateinitrd = $req->{'noupdateinitrd'}; + my $ignorekernelchk = $req->{'ignorekernelchk'}; my $ostab = xCAT::Table->new('nodetype'); #my $sitetab = xCAT::Table->new('site'); my $linuximagetab; @@ -701,6 +702,7 @@ sub mkinstall my $globaltftpdir = xCAT::TableUtils->getTftpDir(); my $noupdateinitrd = $request->{'noupdateinitrd'}; + my $ignorekernelchk = $request->{'ignorekernelchk'}; my @nodes = @{$request->{node}}; my $node; my $ostab = xCAT::Table->new('nodetype'); @@ -1029,20 +1031,20 @@ sub mkinstall unless ($noupdateinitrd) { 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", "$tftppath/linux", $driverupdatesrc, $netdrivers, $osupdir); + @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/initrd", "$tftppath/linux", $driverupdatesrc, $netdrivers, $osupdir, $ignorekernelchk); } } elsif ($arch =~ /x86/) { unless ($noupdateinitrd) { 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", "$tftppath/linux", $driverupdatesrc, $netdrivers, $osupdir); + @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/initrd", "$tftppath/linux", $driverupdatesrc, $netdrivers, $osupdir, $ignorekernelchk); } } elsif ($arch =~ /ppc/) { unless ($noupdateinitrd) { copy("$pkgdir/1/suseboot/inst64", "$tftppath"); - @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/inst64", undef, $driverupdatesrc, $netdrivers, $osupdir); + @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/inst64", undef, $driverupdatesrc, $netdrivers, $osupdir, $ignorekernelchk); } } } @@ -1681,6 +1683,7 @@ sub insert_dd () { my $driverupdatesrc = shift; my $drivers = shift; my $osupdirlist = shift; + my $ignorekernelchk = shift; my $install_dir = xCAT::TableUtils->getInstallDir(); @@ -1688,6 +1691,7 @@ sub insert_dd () { my @dd_list; my @rpm_list; + my @vendor_rpm; # the rpms from driverupdatesrc attribute my @driver_list; my $Injectalldriver; my $updatealldriver; @@ -1718,8 +1722,10 @@ sub insert_dd () { push @dd_list, $1; } elsif ($src =~ /rpm:(.*)/i) { push @rpm_list, $1; + push @vendor_rpm, $1; } else { push @rpm_list, $src; + push @vendor_rpm, $src; } } } @@ -1748,6 +1754,7 @@ sub insert_dd () { chomp(@dd_list); chomp(@rpm_list); + chomp(@vendor_rpm); unless (@dd_list || (@rpm_list && ($Injectalldriver || $updatealldriver || @driver_list))) { return (); @@ -1819,26 +1826,50 @@ sub insert_dd () { 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) { + # Extract files from vendor rpm when $ignorekernelchk is specified + if ($ignorekernelchk) { + mkpath "$dd_dir/vendor_rpm"; + foreach my $rpm (@vendor_rpm) { + if (-r $rpm) { + $cmd = "cd $dd_dir/vendor_rpm; rpm2cpio $rpm | cpio -idum"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not extract files from the rpm $rpm."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } else { my $rsp; - push @{$rsp->{data}}, "Handle the driver update failed. Could not rename $file."; + 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 = (); + my @rpmfiles = <$dd_dir/rpm/*>; + if ($ignorekernelchk) { + push @rpmfiles, <$dd_dir/vendor_rpm/*>; + } + find(\&get_all_path, @rpmfiles); + 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") { @@ -1898,9 +1929,27 @@ sub insert_dd () { } foreach my $kernelver (@kernelvers) { + # if $ignorekernelchk is specified, copy all files from vendor_rpm dir to target kernel dir + if ($ignorekernelchk) { + my @kernelpath4vrpm = <$dd_dir/vendor_rpm/lib/modules/*>; + foreach my $path (@kernelpath4vrpm) { + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { + mkpath "$dd_dir/rpm/lib/modules/$kernelver"; + } + $cmd = "/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"; + xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + my $rsp; + push @{$rsp->{data}}, "Handle the driver update failed. Could not copy driver $path from vendor rpm."; + xCAT::MsgUtils->message("I", $rsp, $callback); + } + } + } + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { next; } + if (@driver_list) { # copy the specific drivers to initrd foreach my $driver (@driver_list) { diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index aca1fc013..e9eed2333 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -62,6 +62,7 @@ my $rootimg_dir; my $permission; # the permission works only for statelite mode currently my $tempfile; my $prompt; +my $ignorekernelchk; sub xdie { @@ -92,6 +93,7 @@ GetOptions( 'driverupdatesrc=s' => \$driverupdatesrc, #internal flag 'interactive' =>\$prompt, 'onlyinitrd' =>\$onlyinitrd, + 'ignorekernelchk' => \$ignorekernelchk, ); if (@ARGV > 0) { @@ -1866,6 +1868,22 @@ sub load_dd () if (-d "$dd_dir/rpm/lib/firmware") { system ("cp -rf $dd_dir/rpm/lib/firmware $rootimg_dir/lib"); } + + # if $ignorekernelchk is specified, copy all driver files to target kernel dir + if ($ignorekernelchk) { + my @kernelpath4vrpm = <$dd_dir/rpm/lib/modules/*>; + foreach my $path (@kernelpath4vrpm) { + if ($path eq "$dd_dir/rpm/lib/modules/$kernelver") { + next; + } + + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { + mkpath "$dd_dir/rpm/lib/modules/$kernelver"; + } + system ("/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"); + } + } + # Copy the drivers to the rootimage if (-d "$dd_dir/rpm/lib/modules/$kernelver") { if (@driver_list) { @@ -1894,6 +1912,8 @@ sub load_dd () } } elsif ($Injectalldriver) { # copy all the drviers to the rootimage + $driver_name = "\*\.ko"; + @all_real_path = (); find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); my @all_drivers = @all_real_path; foreach my $new_driver (@all_drivers) { diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 603dfea8a..880852b73 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -60,6 +60,7 @@ my $krpmver; my $tempfile; my $prompt; my $timezone; #the TIMEZONE of the stateless and statelite node +my $ignorekernelchk; sub xdie { system("rm -rf /tmp/xcatinitrd.$$"); @@ -106,6 +107,7 @@ GetOptions( 'driverupdatesrc=s' => \$driverupdatesrc, #internal flag 'interactive' =>\$prompt, 'onlyinitrd' =>\$onlyinitrd, + 'ignorekernelchk' => \$ignorekernelchk, ); if (@ARGV > 0) { @@ -1970,6 +1972,22 @@ sub load_dd() if (-d "$dd_dir/rpm/lib/firmware") { system ("cp -rf $dd_dir/rpm/lib/firmware $rootimg_dir/lib"); } + + # if $ignorekernelchk is specified, copy all driver files to target kernel dir + if ($ignorekernelchk) { + my @kernelpath4vrpm = <$dd_dir/rpm/lib/modules/*>; + foreach my $path (@kernelpath4vrpm) { + if ($path eq "$dd_dir/rpm/lib/modules/$kernelver") { + next; + } + + unless (-d "$dd_dir/rpm/lib/modules/$kernelver") { + mkpath "$dd_dir/rpm/lib/modules/$kernelver"; + } + system ("/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver"); + } + } + # Copy the drivers to the rootimage if (-d "$dd_dir/rpm/lib/modules/$kernelver") { #mkpath "$rootimg_dir/lib/modules/$kernelver/updates/"; @@ -1999,6 +2017,8 @@ sub load_dd() } } elsif ($Injectalldriver) { # copy all the drviers to the rootimage + $driver_name = "\*\.ko"; + @all_real_path = (); find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>); my @all_drivers = @all_real_path; foreach my $new_driver (@all_drivers) {