[game-data-packager] 01/01: move get_architecture to packaging/ (+ rebase + review)
Alexandre Detiste
detiste-guest at moszumanska.debian.org
Wed Jan 6 12:41:58 UTC 2016
This is an automated email from the git hooks/post-receive script.
detiste-guest pushed a commit to branch master
in repository game-data-packager.
commit e7b7c0d4f4bf0cce815b6a16015acd000bc95ca0
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date: Wed Jan 6 13:41:16 2016 +0100
move get_architecture to packaging/ (+ rebase + review)
---
game_data_packager/__init__.py | 2 +-
game_data_packager/build.py | 53 +++++---------------------------
game_data_packager/packaging/__init__.py | 33 +++++++++++++++++++-
game_data_packager/packaging/deb.py | 9 +++++-
game_data_packager/packaging/rpm.py | 7 ++++-
5 files changed, 55 insertions(+), 49 deletions(-)
diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index 5649aec..d78c365 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -2,7 +2,7 @@
# encoding=utf-8
#
# Copyright © 2014-2016 Simon McVittie <smcv at debian.org>
-# Copyright © 2015 Alexandre Detiste <alexandre at detiste.be>
+# Copyright © 2015-2016 Alexandre Detiste <alexandre at detiste.be>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index 2fbdb9f..fa57e46 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -2,7 +2,7 @@
# encoding=utf-8
#
# Copyright © 2014-2016 Simon McVittie <smcv at debian.org>
-# Copyright © 2015 Alexandre Detiste <alexandre at detiste.be>
+# Copyright © 2015-2016 Alexandre Detiste <alexandre at detiste.be>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -1724,7 +1724,7 @@ class PackagingTask(object):
control['Architecture'] = 'all'
control['Multi-Arch'] = 'foreign'
else:
- control['Architecture'] = self.get_architecture(package.architecture)
+ control['Architecture'] = self.packaging.get_architecture(package.architecture)
dep = dict()
for field in ('breaks', 'conflicts', 'provides',
@@ -1930,7 +1930,7 @@ class PackagingTask(object):
'at your own risk')
raise BinaryExecutablesNotAllowed()
- if self.get_architecture(self.game.binary_executables) not in \
+ if self.packaging.get_architecture(self.game.binary_executables) not in \
self.game.binary_executables.split():
logger.error('%s requires binary-only executables which are '
'only available for %s', self.game.longname,
@@ -2135,43 +2135,6 @@ class PackagingTask(object):
package.name)
raise CDRipFailed()
- def get_architecture(self, archs=''):
- if self._architecture is None:
- if FORMAT == 'deb':
- self._architecture = check_output(['dpkg',
- '--print-architecture']).strip().decode('ascii')
- self._foreign_architectures = set(check_output(['dpkg',
- '--print-foreign-architectures']
- ).strip().decode('ascii').split())
- elif FORMAT == 'rpm':
- arch = check_output(['rpm', '-q', '--qf', '%{ARCH}\n',
- 'rpm']).strip().decode('ascii')
- self._architecture = { 'armhfp': 'armhf',
- 'i686': 'i386',
- 'x86_64': 'amd64',
- }.get(arch, arch)
- self._foreign_architectures = set()
- elif FORMAT == 'arch':
- arch = check_output(['uname', '-m']).strip().decode('ascii')
- self._architecture = { 'x86_64': 'amd64',
- 'i686': 'i386',
- }.get(arch, arch)
- self._foreign_architectures = set()
-
- if archs:
- # In theory this should deal with wildcards like linux-any,
- # but it's unlikely to be relevant in practice.
- archs = archs.split()
-
- if self._architecture in archs or 'any' in archs:
- return self._architecture
-
- for arch in archs:
- if arch in self._foreign_architectures:
- return arch
-
- return self._architecture
-
def prepare_packages(self, packages=None, build_demos=False, download=True,
search=True, log_immediately=True):
if packages is None:
@@ -2269,13 +2232,13 @@ class PackagingTask(object):
continue
elif package.architecture == 'any':
# we'll need this later, cache it
- self.get_architecture()
+ self.packaging.get_architecture()
else:
archs = package.architecture.split()
- arch = self.get_architecture(package.architecture)
+ arch = self.packaging.get_architecture(package.architecture)
if arch not in archs:
logger.warning('cannot produce "%s" on architecture %s',
- package.name, archs)
+ package.name, arch)
possible.discard(package)
for package in set(possible):
@@ -2612,7 +2575,7 @@ class PackagingTask(object):
arch = package.architecture
if arch != 'all':
- arch = self.get_architecture(arch)
+ arch = self.packaging.get_architecture(arch)
deb_basename = '%s_%s_%s.deb' % (package.name, package.version, arch)
@@ -2659,7 +2622,7 @@ class PackagingTask(object):
arch = package.architecture
if arch != 'all':
- arch = self.get_architecture(arch)
+ arch = self.packaging.get_architecture(arch)
if arch == 'all':
arch = 'any'
diff --git a/game_data_packager/packaging/__init__.py b/game_data_packager/packaging/__init__.py
index 18def33..98154bb 100644
--- a/game_data_packager/packaging/__init__.py
+++ b/game_data_packager/packaging/__init__.py
@@ -2,7 +2,7 @@
# encoding=utf-8
#
# Copyright © 2014-2016 Simon McVittie <smcv at debian.org>
-# © 2015 Alexandre Detiste <alexandre at detiste.be>
+# © 2015-2016 Alexandre Detiste <alexandre at detiste.be>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -17,6 +17,7 @@
# /usr/share/common-licenses/GPL-2.
from abc import (ABCMeta, abstractmethod)
+import os
import string
class PackagingSystem(metaclass=ABCMeta):
@@ -24,6 +25,36 @@ class PackagingSystem(metaclass=ABCMeta):
BINDIR = 'usr/bin'
LICENSEDIR = 'usr/share/doc'
+ _architecture = None
+ _foreign_architectures = set()
+
+ def read_architecture(self):
+ arch = os.uname()[4]
+ self._architecture = { 'armv7l': 'armhf',
+ 'armhfp': 'armhf',
+ 'i586': 'i386',
+ 'i686': 'i386',
+ 'x86_64': 'amd64',
+ }.get(arch, arch)
+
+ def get_architecture(self, archs=''):
+ if self._architecture is None:
+ self.read_architecture()
+
+ if archs:
+ # In theory this should deal with wildcards like linux-any,
+ # but it's unlikely to be relevant in practice.
+ archs = archs.split()
+
+ if self._architecture in archs or 'any' in archs:
+ return self._architecture
+
+ for arch in archs:
+ if arch in self._foreign_architectures:
+ return arch
+
+ return self._architecture
+
def is_installed(self, package):
"""Return boolean: is a package with the given name installed?"""
return (self.current_version(package) is not None)
diff --git a/game_data_packager/packaging/deb.py b/game_data_packager/packaging/deb.py
index ed3d933..d287bfc 100644
--- a/game_data_packager/packaging/deb.py
+++ b/game_data_packager/packaging/deb.py
@@ -2,7 +2,7 @@
# encoding=utf-8
#
# Copyright © 2014-2016 Simon McVittie <smcv at debian.org>
-# © 2015 Alexandre Detiste <alexandre at detiste.be>
+# © 2015-2016 Alexandre Detiste <alexandre at detiste.be>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -35,6 +35,13 @@ class DebPackaging(PackagingSystem):
self.__installed = None
self.__available = None
+ def read_architecture(self):
+ self._architecture = check_output(['dpkg',
+ '--print-architecture']).strip().decode('ascii')
+ self._foreign_architectures = set(check_output(['dpkg',
+ '--print-foreign-architectures']
+ ).strip().decode('ascii').split())
+
def is_installed(self, package):
# FIXME: this shouldn't be hard-coded
if package == 'doom-engine':
diff --git a/game_data_packager/packaging/rpm.py b/game_data_packager/packaging/rpm.py
index 85758f8..956344c 100644
--- a/game_data_packager/packaging/rpm.py
+++ b/game_data_packager/packaging/rpm.py
@@ -1,7 +1,7 @@
#!/usr/bin/python3
# encoding=utf-8
#
-# Copyright © 2015 Alexandre Detiste <alexandre at detiste.be>
+# Copyright © 2015-2016 Alexandre Detiste <alexandre at detiste.be>
# Copyright © 2016 Simon McVittie <smcv at debian.org>
#
# This program is free software; you can redistribute it and/or
@@ -65,6 +65,11 @@ class DnfPackaging(RpmPackaging):
def __init__(self):
self.available = None
+ def read_architecture(self):
+ super(DnfPackaging, self).read_architecture()
+ if self._architecture == 'amd64':
+ self._foreign_architectures = set(['i386'])
+
def is_available(self, package):
if self.available is None:
cache = set()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list