From 0844d4ad6578f663051691bc6cdb827900e887f5 Mon Sep 17 00:00:00 2001
From: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Date: Tue, 13 Dec 2016 13:02:48 +0100
Subject: [PATCH] Sort out the various machine type names

We're using four different ways to define the achitecture. There is the
machine name as given by e.g. uname -m, the dpkg architectures (armhf,
amd64, etc) and finally the gnu arch triplet (e.g. aarch64-linux-gnu).
Have TargetTriplet recognize all three and properties for all three
variants.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D5253
---
 tools/ade | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/tools/ade b/tools/ade
index f4fc365..d8668c7 100755
--- a/tools/ade
+++ b/tools/ade
@@ -134,16 +134,17 @@ class Colors:
 
 
 class TargetTriplet:
-    SUPPORTED = {
-        'armhf': "arm-linux-gnueabihf",
-        'arm64': "aarch64-linux-gnu",
-        'x86_64': "x86_64-linux-gnu"
-    }
+    # Machine name, dpkg architecture, gnu triplet
+    SUPPORTED = [
+        [ 'armv7l', "armhf",  "arm-linux-gnueabihf" ],
+        [ 'aarch64',"arm64",  "aarch64-linux-gnu" ],
+        [ 'x86_64', "amd64", "x86_64-linux-gnu" ],
+    ]
 
     def __init__(self, string):
-        for items in self.SUPPORTED.items():
+        for items in self.SUPPORTED:
             if string in items:
-                self.arch, self.triplet = items
+                self.machine, self.arch, self.triplet = items
                 return
         raise NotSupportedError
 
@@ -208,9 +209,11 @@ class Device:
             print(e)
             raise InvalidDeviceError("No image_version file found")
         a = self._exec('uname', '-m')
-        if a not in TargetTriplet.SUPPORTED:
+        try:
+            triplet = TargetTriplet (a)
+        except NotSupportedError:
             raise InvalidDeviceError("Unsupported architecture {}".format(a))
-        self.version.arch = a
+        self.version.arch = triplet.arch
 
 
 class SysrootVersion:
-- 
GitLab