mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-11-04 05:12:30 +00:00 
			
		
		
		
	Changed the insert_dd that the kernel will be updated from the new update distro.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@16961 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		@@ -1343,10 +1343,10 @@ sub mkinstall
 | 
			
		||||
                if($esxi){
 | 
			
		||||
                    copyesxiboot($pkgdir, "$tftppath", osver=>$os);		
 | 
			
		||||
                }else{
 | 
			
		||||
                    copy($kernpath,"$tftppath");
 | 
			
		||||
                    unless ($noupdateinitrd) {
 | 
			
		||||
                        copy($kernpath,"$tftppath");
 | 
			
		||||
                        copy($initrdpath,"$tftppath/initrd.img");
 | 
			
		||||
                        &insert_dd($callback, $os, $arch, "$tftppath/initrd.img", $driverupdatesrc, $netdrivers, $osupdir);
 | 
			
		||||
                        &insert_dd($callback, $os, $arch, "$tftppath/initrd.img", "$tftppath/vmlinuz", $driverupdatesrc, $netdrivers, $osupdir);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@@ -2406,9 +2406,13 @@ sub get_all_path ()
 | 
			
		||||
 | 
			
		||||
sub insert_dd {
 | 
			
		||||
    my $callback = shift;
 | 
			
		||||
    if ($callback eq "xCAT_plugin::anaconda") {
 | 
			
		||||
        $callback = shift;
 | 
			
		||||
    }
 | 
			
		||||
    my $os = shift;
 | 
			
		||||
    my $arch = shift;
 | 
			
		||||
    my $img = shift;
 | 
			
		||||
    my $kernelpath = shift;
 | 
			
		||||
    my $driverupdatesrc = shift;
 | 
			
		||||
    my $drivers = shift;
 | 
			
		||||
    my $osupdirlist = shift;
 | 
			
		||||
@@ -2544,6 +2548,7 @@ sub insert_dd {
 | 
			
		||||
            return ();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        my $new_kernel_ver;
 | 
			
		||||
        if (@rpm_list && ($Injectalldriver || @driver_list)) {
 | 
			
		||||
            # Extract the files from rpm to the tmp dir
 | 
			
		||||
            mkpath "$dd_dir/rpm";
 | 
			
		||||
@@ -2562,6 +2567,22 @@ sub insert_dd {
 | 
			
		||||
                    push @{$rsp->{data}}, "Handle the driver update failed. Could not read the rpm $rpm.";
 | 
			
		||||
                    xCAT::MsgUtils->message("I", $rsp, $callback);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                # get the new kernel if it exists in the update distro
 | 
			
		||||
                # and copy it to the /tftpboot
 | 
			
		||||
                my @new_kernels = <$dd_dir/rpm/boot/vmlinuz*>;
 | 
			
		||||
                foreach my $new_kernel (@new_kernels) {
 | 
			
		||||
                if (-r $new_kernel && $new_kernel =~ /\/vmlinuz-(.*(x86_64|ppc64))$/) {
 | 
			
		||||
                    $new_kernel_ver = $1;
 | 
			
		||||
                    $cmd = "/bin/mv -f $new_kernel $kernelpath";
 | 
			
		||||
                    xCAT::Utils->runcmd($cmd, -1);
 | 
			
		||||
                    if ($::RUNCMD_RC != 0) {
 | 
			
		||||
                        my $rsp;
 | 
			
		||||
                        push @{$rsp->{data}}, "Handle the driver update failed. Could not move $new_kernel to $kernelpath.";
 | 
			
		||||
                        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
 | 
			
		||||
@@ -2571,7 +2592,7 @@ sub insert_dd {
 | 
			
		||||
                foreach my $file (@all_real_path) {
 | 
			
		||||
                    my $newname = $file;
 | 
			
		||||
                    $newname =~ s/\.new$//;
 | 
			
		||||
                    $cmd = "mv -f $file $newname";
 | 
			
		||||
                    $cmd = "/bin/mv -f $file $newname";
 | 
			
		||||
                    xCAT::Utils->runcmd($cmd, -1);
 | 
			
		||||
                    if ($::RUNCMD_RC != 0) {
 | 
			
		||||
                        my $rsp;
 | 
			
		||||
@@ -2580,8 +2601,6 @@ sub insert_dd {
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        # The rh6 has different initrd format with old version (rh 5.x)
 | 
			
		||||
@@ -2605,7 +2624,18 @@ sub insert_dd {
 | 
			
		||||
                    if ($::RUNCMD_RC != 0) {
 | 
			
		||||
                        my $rsp;
 | 
			
		||||
                        push @{$rsp->{data}}, "Handle the driver update failed. Could not copy firmware to the initrd.";
 | 
			
		||||
                        xCAT::MsgUtils->message("I", $rsp, $callback);
 | 
			
		||||
                        xCAT::MsgUtils->message("E", $rsp, $callback);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                # if the new kernel from update distro is not existed in initrd, copy all the modules for the new kernel to initrd
 | 
			
		||||
                if ((! -r "$dd_dir/initrd_img/lib/modules/$new_kernel_ver") && (-r "$dd_dir/rpm/lib/modules/$new_kernel_ver")) {
 | 
			
		||||
                    $cmd = "/bin/cp -rf $dd_dir/rpm/lib/modules/$new_kernel_ver $dd_dir/initrd_img/lib/modules/";
 | 
			
		||||
                    xCAT::Utils->runcmd($cmd, -1);
 | 
			
		||||
                    if ($::RUNCMD_RC != 0) {
 | 
			
		||||
                        my $rsp;
 | 
			
		||||
                        push @{$rsp->{data}}, "Handle the driver update failed. Could not copy $dd_dir/rpm/lib/modules/$new_kernel_ver to $dd_dir/initrd_img/lib/modules.";
 | 
			
		||||
                        xCAT::MsgUtils->message("E", $rsp, $callback);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
@@ -2802,6 +2832,11 @@ sub insert_dd {
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                # if the new kernel from update distro is not existed in initrd, create the path for it
 | 
			
		||||
                if (! -r "$dd_dir/modules/$new_kernel_ver/$arch/") {
 | 
			
		||||
                    mkpath ("$dd_dir/modules/$new_kernel_ver/$arch/");
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                # Copy the drivers to the initrd
 | 
			
		||||
                # Figure out the kernel version
 | 
			
		||||
                my @kernelpaths = <$dd_dir/modules/*>;
 | 
			
		||||
 
 | 
			
		||||
@@ -1025,23 +1025,23 @@ sub mkinstall
 | 
			
		||||
                mkpath("$tftppath");
 | 
			
		||||
                if ($arch =~ /x86_64/)
 | 
			
		||||
                {
 | 
			
		||||
                    copy("$pkgdir/1/boot/$arch/loader/linux", "$tftppath");
 | 
			
		||||
                    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", $driverupdatesrc, $netdrivers, $osupdir);
 | 
			
		||||
                        @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/initrd", "$tftppath/linux", $driverupdatesrc, $netdrivers, $osupdir);
 | 
			
		||||
                    }
 | 
			
		||||
                } elsif ($arch =~ /x86/) {
 | 
			
		||||
                    copy("$pkgdir/1/boot/i386/loader/linux", "$tftppath");
 | 
			
		||||
                    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", $driverupdatesrc, $netdrivers, $osupdir);
 | 
			
		||||
                        @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/initrd", "$tftppath/linux", $driverupdatesrc, $netdrivers, $osupdir);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                elsif ($arch =~ /ppc/)
 | 
			
		||||
                {
 | 
			
		||||
                    unless ($noupdateinitrd) {
 | 
			
		||||
                        copy("$pkgdir/1/suseboot/inst64", "$tftppath");
 | 
			
		||||
                        @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/inst64", $driverupdatesrc, $netdrivers, $osupdir);
 | 
			
		||||
                        @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/inst64", undef, $driverupdatesrc, $netdrivers, $osupdir);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@@ -1670,9 +1670,13 @@ sub get_all_path ()
 | 
			
		||||
 | 
			
		||||
sub insert_dd () {
 | 
			
		||||
    my $callback = shift;
 | 
			
		||||
    if ($callback eq "xCAT_plugin::sles") {
 | 
			
		||||
        $callback = shift;
 | 
			
		||||
    }
 | 
			
		||||
    my $os = shift;
 | 
			
		||||
    my $arch = shift;
 | 
			
		||||
    my $img = shift;
 | 
			
		||||
    my $kernelpath = shift;
 | 
			
		||||
    my $driverupdatesrc = shift;
 | 
			
		||||
    my $drivers = shift;
 | 
			
		||||
    my $osupdirlist = shift;
 | 
			
		||||
@@ -1781,6 +1785,7 @@ sub insert_dd () {
 | 
			
		||||
        if (@rpm_list && ($Injectalldriver || @driver_list)) {
 | 
			
		||||
            # Extract the files from rpm to the tmp dir
 | 
			
		||||
            mkpath "$dd_dir/rpm";
 | 
			
		||||
            my $new_kernel_ver;
 | 
			
		||||
            foreach my $rpm (@rpm_list) {
 | 
			
		||||
                if (-r $rpm) {
 | 
			
		||||
                    $cmd = "cd $dd_dir/rpm; rpm2cpio $rpm | cpio -idum";
 | 
			
		||||
@@ -1796,6 +1801,21 @@ sub insert_dd () {
 | 
			
		||||
                    xCAT::MsgUtils->message("I", $rsp, $callback);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                # get the new kernel if it exists in the update distro
 | 
			
		||||
                my @new_kernels = <$dd_dir/rpm/boot/vmlinuz*>;
 | 
			
		||||
                foreach my $new_kernel (@new_kernels) {
 | 
			
		||||
                if (-r $new_kernel && $new_kernel =~ /\/vmlinuz-(.*(x86_64|ppc64))$/) {
 | 
			
		||||
                    $new_kernel_ver = $1;
 | 
			
		||||
                    $cmd = "/bin/mv -f $new_kernel $dd_dir/rpm/newkernel";
 | 
			
		||||
                    xCAT::Utils->runcmd($cmd, -1);
 | 
			
		||||
                    if ($::RUNCMD_RC != 0) {
 | 
			
		||||
                        my $rsp;
 | 
			
		||||
                        push @{$rsp->{data}}, "Handle the driver update failed. Could not move $new_kernel to $dd_dir/rpm/newkernel.";
 | 
			
		||||
                        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";
 | 
			
		||||
@@ -1827,6 +1847,11 @@ sub insert_dd () {
 | 
			
		||||
                    xCAT::MsgUtils->message("I", $rsp, $callback);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            # if the new kernel from update distro is not existed in initrd, create the path for it
 | 
			
		||||
            if (! -r "$dd_dir/initrd_img/lib/modules/$new_kernel_ver/") {
 | 
			
		||||
                mkpath ("$dd_dir/initrd_img/lib/modules/$new_kernel_ver/");
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            # Copy the drivers to the rootimage
 | 
			
		||||
            # Figure out the kernel version
 | 
			
		||||
@@ -1932,9 +1957,14 @@ sub insert_dd () {
 | 
			
		||||
 | 
			
		||||
    if ($arch =~/ppc/ || (@rpm_list && ($Injectalldriver || @driver_list))) {
 | 
			
		||||
        if ($arch =~/ppc/) {
 | 
			
		||||
            # make sure the src kernel existed
 | 
			
		||||
            $cmd = "gunzip -c $pkgdir/1/suseboot/linux64.gz > $dd_dir/kernel";
 | 
			
		||||
            xCAT::Utils->runcmd($cmd, -1);
 | 
			
		||||
            if (-r "$dd_dir/rpm/newkernel") {
 | 
			
		||||
                # if there's new kernel from update distro, then use it
 | 
			
		||||
                copy ("$dd_dir/rpm/newkernel", "$dd_dir/kernel");
 | 
			
		||||
            } else {
 | 
			
		||||
                # make sure the src kernel existed
 | 
			
		||||
                $cmd = "gunzip -c $pkgdir/1/suseboot/linux64.gz > $dd_dir/kernel";
 | 
			
		||||
                xCAT::Utils->runcmd($cmd, -1);
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            # create the zimage
 | 
			
		||||
            $cmd = "env -u POSIXLY_CORRECT /lib/lilo/scripts/make_zimage_chrp.sh --vmlinux $dd_dir/kernel --initrd $dd_dir/initrd.gz --output $img";
 | 
			
		||||
@@ -1946,6 +1976,10 @@ sub insert_dd () {
 | 
			
		||||
                return ();
 | 
			
		||||
            }
 | 
			
		||||
        } elsif ($arch =~/x86/) {
 | 
			
		||||
            if (-r "$dd_dir/rpm/newkernel") {
 | 
			
		||||
                # if there's new kernel from update distro, then use it
 | 
			
		||||
                copy ("$dd_dir/rpm/newkernel", $kernelpath);
 | 
			
		||||
            }
 | 
			
		||||
            copy ("$dd_dir/initrd.gz", "$img");
 | 
			
		||||
        }
 | 
			
		||||
    } elsif ($arch =~ /x86/) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user