diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index d65c32763..28078bae4 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -1489,9 +1489,32 @@ sub insert_dd { # Create the tmp dir for dd hack my $dd_dir = mkdtemp("/tmp/ddtmpXXXXXXX"); if (<$install_dir/$os/$arch/Packages/dracut*>) { #new style, skip the fanagling, copy over the dds and append them... + mkpath("$dd_dir/dd"); if (scalar(@dd_list) == 1) { #only one, just append it.. - mkpath("$dd_dir/dd"); copy($dd_list[0],"$dd_dir/dd/dd.img"); + } elsif (scalar(@dd_list) > 1) { + unless (-x "/usr/bin/createrepo" and -x "/usr/bin/mkisofs") { + my $rsp; + push @{$rsp->{data}}, "Merging multiple driver disks requires createrepo and mkisofs utilities"; + xCAT::MsgUtils->message("E", $rsp, $callback); + return undef; + } + mkpath("$dd_dir/newddimg"); + 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("umount $dd_dir/tmpddmnt",-1); + } + foreach my $repodir (<$dd_dir/newddimg/*/*/repodata>) { + $repodir =~ s/\/repodata\z//; + xCAT::Utils->runcmd("createrepo $repodir",-1); + } + chdir("$dd_dir/newddimg"); + xCAT::Utils->runcmd("mkisofs -J -R -o $dd_dir/dd/dd.img .",-1); + } else { #there should be no else... + die "This should never occur"; + } chdir($dd_dir."/dd"); $cmd = "find .|cpio -H newc -o|gzip -9 -c - > ../dd.gz"; xCAT::Utils->runcmd($cmd, -1); @@ -1508,10 +1531,9 @@ sub insert_dd { local $/ = \32768; while (my $block = <$ddhdl>) { print $inithdl $block; } } + chdir("/"); + xCAT::Utils->runcmd("rm -rf $dd_dir"); return; - } else { - die "TODO: multiple driver disk combination"; - } } mkpath "$dd_dir/initrd_img"; # The dir for the new initrd