From 9799071116ef3e599f09bbf35185b75821d0d46c Mon Sep 17 00:00:00 2001
From: Jarrod Johnson <jbjohnso@us.ibm.com>
Date: Mon, 18 Nov 2013 16:31:15 -0500
Subject: [PATCH] Fix SLES driver update media injection that is not rpm based

---
 xCAT-server/lib/xcat/plugins/sles.pm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm
index f362b6d2d..3392a63af 100644
--- a/xCAT-server/lib/xcat/plugins/sles.pm
+++ b/xCAT-server/lib/xcat/plugins/sles.pm
@@ -2282,6 +2282,25 @@ sub insert_dd () {
             copy ("$dd_dir/initrd.gz", "$img");
         }
     } elsif ($arch =~ /x86/) {
+        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");
+        }
+        # 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 ();
+        }
+        $cmd = "gzip -f $dd_dir/initrd";
+        xCAT::Utils->runcmd($cmd, -1);
         my $rdhandle;
         my $ddhandle;
         open($rdhandle,">>",$img);