[elbe-devel] [PATCH 2/5] debianize: remove duplicated code with DebianizeBase.get_k_arch()

Torben Hohn torben.hohn at linutronix.de
Tue Oct 23 15:43:40 CEST 2018


mapping to "kernel" arch is used in all debianize implementations,
because kernel, u-boot and barebox all use Kbuild.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/debianize/barebox.py |  9 +--------
 elbepack/debianize/base.py    | 11 +++++++++++
 elbepack/debianize/kernel.py  |  9 +--------
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/elbepack/debianize/barebox.py b/elbepack/debianize/barebox.py
index 90cb51df..933658b4 100644
--- a/elbepack/debianize/barebox.py
+++ b/elbepack/debianize/barebox.py
@@ -45,14 +45,7 @@ class BareBox (DebianizeBase):
             TitleText, name="BareboxVersion:", value="2016.10")
 
     def debianize(self):
-        if self.deb['p_arch'] == 'armhf':
-            self.deb['k_arch'] = 'arm'
-        elif self.deb['p_arch'] == 'armel':
-            self.deb['k_arch'] = 'arm'
-        elif self.deb['p_arch'] == 'amd64':
-            self.deb['k_arch'] = 'x86_64'
-        else:
-            self.deb['k_arch'] = self.deb['p_arch']
+        self.deb['k_arch'] = self.get_k_arch()
 
         self.deb['defconfig'] = self.defconfig.get_value()
         self.deb['cross_compile'] = self.cross.get_value()
diff --git a/elbepack/debianize/base.py b/elbepack/debianize/base.py
index b9aaf74c..06ef6796 100644
--- a/elbepack/debianize/base.py
+++ b/elbepack/debianize/base.py
@@ -63,6 +63,17 @@ class DebianizeBase (FormMultiPage):
     def debianize(self):
         raise NotImplementedError('gui() not implemented')
 
+    def get_k_arch(self):
+        """ get_k_arch() may be used in debianize() """
+        if self.deb['p_arch'] == 'armhf':
+            return 'arm'
+        elif self.deb['p_arch'] == 'armel':
+            return 'arm'
+        elif self.deb['p_arch'] == 'amd64':
+            return 'x86_64'
+        else:
+            return self.deb['p_arch']
+
     def create(self):
         self.p_name = self.add_widget_intelligent(TitleText,
                                                   name="Name:", value="elbe")
diff --git a/elbepack/debianize/kernel.py b/elbepack/debianize/kernel.py
index 227985a3..444b9678 100644
--- a/elbepack/debianize/kernel.py
+++ b/elbepack/debianize/kernel.py
@@ -55,14 +55,7 @@ class Kernel (DebianizeBase):
             TitleText, name="Kernelversion", value="4.4")
 
     def debianize(self):
-        if self.deb['p_arch'] == 'armhf':
-            self.deb['k_arch'] = 'arm'
-        elif self.deb['p_arch'] == 'armel':
-            self.deb['k_arch'] = 'arm'
-        elif self.deb['p_arch'] == 'amd64':
-            self.deb['k_arch'] = 'x86_64'
-        else:
-            self.deb['k_arch'] = self.deb['p_arch']
+        self.deb['k_arch'] = self.get_k_arch()
 
         self.deb['loadaddr'] = self.loadaddr.get_value()
         self.deb['defconfig'] = self.defconfig.get_value()
-- 
2.11.0




More information about the elbe-devel mailing list