From 4b13534eeab011ffce64ac1316397993f384ee22 Mon Sep 17 00:00:00 2001 From: Luca Falavigna Date: Mon, 20 Sep 2010 18:12:39 +0200 Subject: [PATCH] * ubuntutools/misc.py: - Use output of dpkg --print-architecture command to correctly display platform architecture --- debian/changelog | 5 ++++- ubuntutools/misc.py | 14 +++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 82ae60f..b53827b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,8 +8,11 @@ ubuntu-dev-tools (0.103) UNRELEASED; urgency=low - Add Benjamin Drung to Uploaders. - Add DM-Upload-Allowed field, this way Benjamin can upload new versions on his own. + * ubuntutools/misc.py: + - Use output of dpkg --print-architecture command to correctly display + platform architecture (Closes: #594424). - -- Luca Falavigna Mon, 20 Sep 2010 17:46:46 +0200 + -- Luca Falavigna Mon, 20 Sep 2010 18:11:24 +0200 ubuntu-dev-tools (0.102) experimental; urgency=low diff --git a/ubuntutools/misc.py b/ubuntutools/misc.py index cabaa8d..1480483 100644 --- a/ubuntutools/misc.py +++ b/ubuntutools/misc.py @@ -22,6 +22,7 @@ # Modules. import os +from subprocess import Popen, PIPE from ubuntutools.lp.udtexceptions import PocketDoesNotExistError @@ -52,21 +53,20 @@ def system_distribution(): def host_architecture(): """ host_architecture -> string - Detect the host's architecture and return it as a string - (i386/amd64/other values). If the architecture can't be determined, - print an error message and return None. + Detect the host's architecture and return it as a string. If the + architecture can't be determined, print an error message and return None. """ - arch = os.uname()[4].replace('x86_64', 'amd64').replace('i586', 'i386' - ).replace('i686', 'i386') + arch = Popen(['dpkg', '--print-architecture'], stdout=PIPE, \ + stderr=PIPE).communicate()[0].split() - if not arch or 'not found' in arch: + if not arch or 'not found' in arch[0]: print 'Error: Not running on a Debian based system; could not ' \ 'detect its architecture.' return None - return arch + return arch[0] def readlist(filename, uniq=True): """ readlist(filename, uniq) -> list