From 43fe7cd3eec70c700552ab1514047341d2ec24ac Mon Sep 17 00:00:00 2001
From: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Date: Wed, 19 Nov 2014 15:11:21 -0600
Subject: [PATCH] cobbler: add little-endian powerpc support

Power systems now can run in little-endian or big-endian mode, depending
on the support from the OS. Add "ppc64le" and "ppc64el" as valid
architecture names. Generally, LE power is the same as BE, just with a
different architecture string. Update the signature file appropriately:

 - SLES is ppc64le only, Ubuntu/Debian is ppc64el.
 - On Ubuntu ppc64el, the kernel is named vmlinux not linux.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
---
 cobbler/item_repo.py                        |  2 +-
 cobbler/modules/manage_import_signatures.py |  2 +-
 cobbler/utils.py                            |  6 ++++--
 config/cobbler/distro_signatures.json       | 14 ++++++++------
 web/templates/import.tmpl                   |  2 ++
 5 files changed, 16 insertions(+), 10 deletions(-)

Index: cobbler-2.6.6/cobbler/item_repo.py
===================================================================
--- cobbler-2.6.6.orig/cobbler/item_repo.py
+++ cobbler-2.6.6/cobbler/item_repo.py
@@ -32,7 +32,7 @@ import codes
 FIELDS = [
   ["apt_components","",0,"Apt Components (apt only)",True,"ex: main restricted universe",[],"list"],
   ["apt_dists","",0,"Apt Dist Names (apt only)",True,"ex: precise precise-updates",[],"list"],
-  ["arch","",0,"Arch",True,"ex: i386, x86_64",['i386','x86_64','ia64','ppc','ppc64','s390', "arm", 'noarch', 'src'],"str"],
+  ["arch","",0,"Arch",True,"ex: i386, x86_64",['i386','x86_64','ia64','ppc','ppc64', 'ppc64le', 'ppc64el', 's390', "arm", 'noarch', 'src'],"str"],
   ["breed","",0,"Breed",True,"",codes.VALID_REPO_BREEDS,"str"],
   ["comment","",0,"Comment",True,"Free form text description",0,"str"],
   ["ctime",0,0,"",False,"",0,"float"],
Index: cobbler-2.6.6/cobbler/modules/manage_import_signatures.py
===================================================================
--- cobbler-2.6.6.orig/cobbler/modules/manage_import_signatures.py
+++ cobbler-2.6.6/cobbler/modules/manage_import_signatures.py
@@ -443,7 +443,7 @@ class ImportSignatureManager:
         # remove any architecture name related string, as real arch will be appended later
         name = name.replace("chrp","ppc64")
         for separator in [ '-' , '_'  , '.' ] :
-            for arch in ["i386","x86_64","ia64","ppc64","ppc32","ppc","x86","s390x","s390","386","amd"]:
+            for arch in ["i386","x86_64","ia64","ppc64le","ppc64el","ppc64","ppc32","ppc","x86","s390x","s390","386","amd"]:
                 name = name.replace("%s%s" % (separator,arch),"")
 
         return name
Index: cobbler-2.6.6/cobbler/utils.py
===================================================================
--- cobbler-2.6.6.orig/cobbler/utils.py
+++ cobbler-2.6.6/cobbler/utils.py
@@ -1334,9 +1334,9 @@ def set_arch(self,arch,repo=False):
        arch = "i386"
 
    if repo:
-       valids = [ "i386", "x86_64", "ia64", "ppc", "ppc64", "s390", "s390x", "noarch", "src", "arm" ]
+       valids = [ "i386", "x86_64", "ia64", "ppc", "ppc64", "ppc64le", "ppc64el", "s390", "s390x", "noarch", "src", "arm" ]
    else:
-       valids = [ "i386", "x86_64", "ia64", "ppc", "ppc64", "s390", "s390x", "arm" ]
+       valids = [ "i386", "x86_64", "ia64", "ppc", "ppc64", "ppc64le", "ppc64el", "s390", "s390x", "arm" ]
 
    if arch in valids:
        self.arch = arch
Index: cobbler-2.6.6/config/distro_signatures.json
===================================================================
--- cobbler-2.6.6.orig/config/distro_signatures.json
+++ cobbler-2.6.6/config/distro_signatures.json
@@ -541,7 +541,7 @@
     "version_file_regex":null,
     "kernel_arch":"kernel-(.*)\\.rpm",
     "kernel_arch_regex":null,
-    "supported_arches":["x86_64", "s390x"],
+    "supported_arches":["x86_64", "s390x", "ppc64le"],
     "supported_repo_breeds":["yum"],
     "kernel_file":"linux[64.gz]?",
     "initrd_file":"initrd[64]?",
@@ -557,7 +557,7 @@
     "version_file_regex":null,
     "kernel_arch":"kernel-(.*)\\.rpm",
     "kernel_arch_regex":null,
-    "supported_arches":["x86_64", "s390x"],
+    "supported_arches":["x86_64", "s390x", "ppc64le"],
     "supported_repo_breeds":["yum"],
     "kernel_file":"linux[64.gz]?",
     "initrd_file":"initrd[64]?",
Index: cobbler-2.6.6/web/cobbler_web/templates/import.tmpl
===================================================================
--- cobbler-2.6.6.orig/web/cobbler_web/templates/import.tmpl
+++ cobbler-2.6.6/web/cobbler_web/templates/import.tmpl
@@ -20,6 +20,8 @@
         <option value="ia64">ia64</option>
         <option value="ppc">ppc</option>
         <option value="ppc64">ppc64</option>
+        <option value="ppc64le">ppc64le</option>
+        <option value="ppc64el">ppc64el</option>
         <option value="s390">s390</option>
         <option value="s390x">s390x</option>
         <option value="arm">arm</option>
