[game-data-packager] 01/02: port to SuSE: "Have a lot of fun..."

Alexandre Detiste detiste-guest at moszumanska.debian.org
Sun Nov 22 09:51:29 UTC 2015


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 c70220fd5d3676cb70f9cf2e3f9c596dfec1be10
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Sun Nov 22 10:41:19 2015 +0100

    port to SuSE: "Have a lot of fun..."
---
 Makefile                                           |  3 +-
 data/heretic.yaml                                  |  4 ++
 data/hexen.yaml                                    |  6 +++
 data/strife.yaml                                   |  2 +
 debian/rules                                       |  3 ++
 game_data_packager/__init__.py                     | 11 +++--
 game_data_packager/build.py                        | 12 ++++-
 game_data_packager/util.py                         | 10 ++--
 game_data_packager/{util_rpm.py => util_fedora.py} | 19 ++------
 game_data_packager/util_rpm.py                     | 35 +-------------
 game_data_packager/util_suse.py                    | 53 ++++++++++++++++++++++
 game_data_packager/version.py                      | 12 +++++
 tools/game-data-packager.spec                      |  2 +
 13 files changed, 113 insertions(+), 59 deletions(-)

diff --git a/Makefile b/Makefile
index ab456d4..1353e82 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,8 @@ GDP_MIRROR ?= localhost
 bindir := /usr/games
 PYFLAKES3 := $(shell if [ -x /usr/bin/pyflakes3 ] ;  then echo pyflakes3 ; \
                    elif [ -x /usr/bin/pyflakes3k ] ; then echo pyflakes3k ; \
-                                                     else echo python3-pyflakes ; \
+                   elif [ -x /usr/bin/python3-pyflakes ] ; then echo python3-pyflakes ; \
+                   else ls -1 /usr/bin/pyflakes-python3.* | tail -n 1 ; \
                     fi)
 
 # some cherry picked games that:
diff --git a/data/heretic.yaml b/data/heretic.yaml
index 82a727a..6f10dbe 100644
--- a/data/heretic.yaml
+++ b/data/heretic.yaml
@@ -27,6 +27,8 @@ packages:
     steam:
       id: 2390
       path: "common/Heretic Shadow of the Serpent Riders"
+    suse:
+      engine: chocolate-doom
     install:
     - heretic.wad
 
@@ -36,6 +38,8 @@ packages:
     component: non-free
     debian:
       replaces: heretic-shareware-data
+    suse:
+      engine: chocolate-doom
     install:
     - heretic1.wad
     license:
diff --git a/data/hexen.yaml b/data/hexen.yaml
index f12ff5b..702a516 100644
--- a/data/hexen.yaml
+++ b/data/hexen.yaml
@@ -29,6 +29,8 @@ packages:
     steam:
       id: 2360
       path: "common/Hexen"
+    suse:
+      engine: chocolate-doom
     install:
     - hexen.wad
 
@@ -38,6 +40,8 @@ packages:
     debian:
       breaks: chocolate-doom (<< 2)
       replaces: hexen-deathkings-data
+    suse:
+      engine: chocolate-doom
     steam:
       id: 2370
       path: "common/Hexen Deathkings of the Dark Citadel"
@@ -50,6 +54,8 @@ packages:
     debian:
       replaces: hexen-demo-data
       breaks: chocolate-doom (<< 2.2.0)
+    suse:
+      engine: chocolate-doom
     demo_for: hexen-wad
     install:
     - hexendemo.wad
diff --git a/data/strife.yaml b/data/strife.yaml
index a5110b6..03a0f87 100644
--- a/data/strife.yaml
+++ b/data/strife.yaml
@@ -26,6 +26,8 @@ packages:
     steam:
       id: 317040
       path: common/Strife
+    suse:
+      engine: chocolate-doom
     install:
     - strife1.wad
     - voices.wad
diff --git a/debian/rules b/debian/rules
index 1582b6b..e0cdddb 100755
--- a/debian/rules
+++ b/debian/rules
@@ -30,6 +30,7 @@ override_dh_install:
 	dh_install
 	echo 'GAME_PACKAGE_VERSION = """$(DEB_VERSION)"""' > debian/game-data-packager/usr/share/games/game-data-packager/game_data_packager/version.py
 	echo 'FORMAT = "deb"' >> debian/game-data-packager/usr/share/games/game-data-packager/game_data_packager/version.py
+	echo 'DISTRO = "generic"' >> debian/game-data-packager/usr/share/games/game-data-packager/game_data_packager/version.py
 	echo 'BINDIR = "usr/games"' >> debian/game-data-packager/usr/share/games/game-data-packager/game_data_packager/version.py
 	echo 'ASSETS = "usr/share/games"' >> debian/game-data-packager/usr/share/games/game-data-packager/game_data_packager/version.py
 	if dpkg-vendor --derives-from Ubuntu; then \
@@ -37,7 +38,9 @@ override_dh_install:
 	fi
 	install -D -m755 runtime/doom2-masterlevels.py debian/game-data-packager/usr/games/doom2-masterlevels
 	rm -f debian/game-data-packager/usr/share/games/game-data-packager/game_data_packager/util_arch.py
+	rm -f debian/game-data-packager/usr/share/games/game-data-packager/game_data_packager/util_fedora.py
 	rm -f debian/game-data-packager/usr/share/games/game-data-packager/game_data_packager/util_rpm.py
+	rm -f debian/game-data-packager/usr/share/games/game-data-packager/game_data_packager/util_suse.py
 
 override_dh_installdocs:
 	dh_installdocs -XTODO
diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index 70aac8a..f5c427e 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -37,7 +37,7 @@ from .gog import run_gog_meta_mode
 from .paths import (DATADIR,USE_VFS)
 from .util import ascii_safe
 from .steam import run_steam_meta_mode
-from .version import (GAME_PACKAGE_VERSION, FORMAT, ASSETS)
+from .version import (GAME_PACKAGE_VERSION, DISTRO, ASSETS)
 
 logging.basicConfig()
 logger = logging.getLogger('game-data-packager')
@@ -790,10 +790,11 @@ class GameData(object):
             if k in d:
                 setattr(package, k, d[k])
 
-        if FORMAT == 'rpm' and 'fedora' in d:
-            for k in ('engine', 'install_to', 'description'):
-                if k in d['fedora']:
-                    setattr(package, k, d['fedora'][k])
+        for port in ('arch', 'fedora', 'suse'):
+            if DISTRO == port and port in d:
+                for k in ('engine', 'install_to', 'description'):
+                    if k in d[port]:
+                        setattr(package, k, d[port][k])
 
         assert self.copyright or package.copyright, package.name
         assert package.component in ('main', 'contrib', 'non-free', 'local')
diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index 4fa38ad..aea1d4e 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -56,7 +56,7 @@ from .util import (AGENT,
         rm_rf,
         recursive_utime,
         which)
-from .version import (FORMAT)
+from .version import (FORMAT, DISTRO)
 
 if FORMAT == 'deb':
     from debian.deb822 import Deb822
@@ -2668,7 +2668,7 @@ class PackagingTask(object):
                 '7z': 'p7zip-full',
                 'unrar-nonfree': 'unrar',
             }
-        elif FORMAT == 'rpm':
+        elif DISTRO == 'fedora':
             command = 'dnf install'
             package_map = {
                 'dpkg-deb': 'dpkg',
@@ -2676,6 +2676,14 @@ class PackagingTask(object):
                 '7z': 'p7zip-plugins',
                 'unrar-nonfree': 'unrar',
             }
+        elif DISTRO == 'suse':
+            command = 'zypper install'
+            package_map = {
+                'dpkg-deb': 'dpkg',
+                'id-shr-extract': None,
+                '7z': 'p7zip',
+                'unrar-nonfree': 'unrar',
+            }
         elif FORMAT == 'arch':
             command = 'pacman -S'
             package_map = {
diff --git a/game_data_packager/util.py b/game_data_packager/util.py
index eb23090..ea22d5e 100644
--- a/game_data_packager/util.py
+++ b/game_data_packager/util.py
@@ -26,7 +26,7 @@ import subprocess
 import sys
 
 from .paths import DATADIR
-from .version import (GAME_PACKAGE_VERSION, FORMAT)
+from .version import (GAME_PACKAGE_VERSION, FORMAT, DISTRO)
 
 logger = logging.getLogger('game-data-packager.util')
 
@@ -225,8 +225,12 @@ elif FORMAT == 'arch':
     from .util_arch import (PACKAGE_CACHE, install_packages)
     lintian_license = lambda a,b,c: None
     lintian_desktop = lambda a,b,c: None
-else:
-    from .util_rpm import (PACKAGE_CACHE, install_packages)
+elif DISTRO == 'fedora':
+    from .util_fedora import (PACKAGE_CACHE, install_packages)
+    lintian_license = lambda a,b,c: None
+    lintian_desktop = lambda a,b,c: None
+elif DISTRO == 'suse':
+    from .util_suse import (PACKAGE_CACHE, install_packages)
     lintian_license = lambda a,b,c: None
     lintian_desktop = lambda a,b,c: None
 
diff --git a/game_data_packager/util_rpm.py b/game_data_packager/util_fedora.py
similarity index 73%
copy from game_data_packager/util_rpm.py
copy to game_data_packager/util_fedora.py
index 5974889..c2caa03 100644
--- a/game_data_packager/util_rpm.py
+++ b/game_data_packager/util_fedora.py
@@ -15,18 +15,14 @@
 import logging
 import subprocess
 
-from .util import (run_as_root, check_output)
+from .util import (run_as_root)
+from .util_rpm import (RPM_PackageCache)
 
-logger = logging.getLogger('game-data-packager.util_rpm')
+logger = logging.getLogger('game-data-packager.util_fedora')
 
-class PackageCache:
+class PackageCache(RPM_PackageCache):
     available = None
 
-    def is_installed(self, package):
-        return 0 == subprocess.call(['rpm', '-q', package],
-                                    stdout=subprocess.DEVNULL,
-                                    stderr=subprocess.DEVNULL)
-
     def is_available(self, package):
         if self.available is None:
             cache = set()
@@ -40,13 +36,6 @@ class PackageCache:
 
         return package in self.available
 
-    def current_version(self, package):
-        try:
-            return check_output(['rpm', '-q',
-              '--qf', '%{VERSION}', package], universal_newlines=True)
-        except subprocess.CalledProcessError:
-            return
-
     def available_version(self, package):
         proc = subprocess.Popen(['dnf', 'list', package],
                                  universal_newlines=True,
diff --git a/game_data_packager/util_rpm.py b/game_data_packager/util_rpm.py
index 5974889..03e9fa0 100644
--- a/game_data_packager/util_rpm.py
+++ b/game_data_packager/util_rpm.py
@@ -15,50 +15,19 @@
 import logging
 import subprocess
 
-from .util import (run_as_root, check_output)
+from .util import (check_output)
 
 logger = logging.getLogger('game-data-packager.util_rpm')
 
-class PackageCache:
-    available = None
-
+class RPM_PackageCache:
     def is_installed(self, package):
         return 0 == subprocess.call(['rpm', '-q', package],
                                     stdout=subprocess.DEVNULL,
                                     stderr=subprocess.DEVNULL)
 
-    def is_available(self, package):
-        if self.available is None:
-            cache = set()
-            proc = subprocess.Popen(['dnf', 'list'],
-                    universal_newlines=True,
-                    stdout=subprocess.PIPE)
-            for line in proc.stdout:
-                if '.' in line:
-                    cache.add(line.split('.')[0])
-            self.available = cache
-
-        return package in self.available
-
     def current_version(self, package):
         try:
             return check_output(['rpm', '-q',
               '--qf', '%{VERSION}', package], universal_newlines=True)
         except subprocess.CalledProcessError:
             return
-
-    def available_version(self, package):
-        proc = subprocess.Popen(['dnf', 'list', package],
-                                 universal_newlines=True,
-                                 stderr=subprocess.DEVNULL,
-                                 stdout=subprocess.PIPE)
-        # keep only last line
-        for line in proc.stdout:
-            pass
-        return line.split()[1]
-
-PACKAGE_CACHE = PackageCache()
-
-def install_packages(debs, method, gain_root='su'):
-    """Install one or more packages (a list of filenames)."""
-    run_as_root(['dnf', 'install'] + list(debs), gain_root)
diff --git a/game_data_packager/util_suse.py b/game_data_packager/util_suse.py
new file mode 100644
index 0000000..60d8ecb
--- /dev/null
+++ b/game_data_packager/util_suse.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python3
+# encoding=utf-8
+#
+# Copyright © 2015 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
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+import logging
+import subprocess
+
+from .util import (run_as_root)
+from .util_rpm import (RPM_PackageCache)
+
+logger = logging.getLogger('game-data-packager.util_suse')
+
+class PackageCache(RPM_PackageCache):
+    def is_available(self, package):
+        proc = subprocess.Popen(['zypper', 'info', package],
+                universal_newlines=True,
+                stdout=subprocess.PIPE,
+                env={'LANG':'C'})
+        for line in proc.stdout:
+            if ':' not in line:
+                continue
+            k, _, v = line.split(maxsplit=2)
+            if k == 'Version':
+                return True
+        return False
+
+    def available_version(self, package):
+        proc = subprocess.Popen(['zypper', 'info', package],
+                universal_newlines=True,
+                stdout=subprocess.PIPE,
+                env={'LANG':'C'})
+        for line in proc.stdout:
+            if ':' not in line:
+                continue
+            k, _, v = line.split(maxsplit=2)
+            if k == 'Version':
+                return v
+
+PACKAGE_CACHE = PackageCache()
+
+def install_packages(rpms, method, gain_root='su'):
+    """Install one or more packages (a list of filenames)."""
+    run_as_root(['zypper', 'install'] + list(rpms), gain_root)
diff --git a/game_data_packager/version.py b/game_data_packager/version.py
index d7c86cd..a352d13 100644
--- a/game_data_packager/version.py
+++ b/game_data_packager/version.py
@@ -7,6 +7,7 @@ import os
 
 if os.path.isfile('/etc/debian_version'):
     FORMAT = 'deb'
+    DISTRO = 'generic'
     BINDIR = 'usr/games'
     ASSETS = 'usr/share/games'
 
@@ -16,6 +17,16 @@ if os.path.isfile('/etc/debian_version'):
 
 elif os.path.isfile('/etc/redhat-release'):
     FORMAT = 'rpm'
+    DISTRO = 'fedora'
+    BINDIR = 'usr/bin'
+    ASSETS = 'usr/share'
+
+    cl = open('debian/changelog', encoding='utf-8').readline()
+    GAME_PACKAGE_VERSION = cl.split('(')[1].split(')')[0]
+
+elif os.path.isfile('/etc/SuSE-release'):
+    FORMAT = 'rpm'
+    DISTRO = 'suse'
     BINDIR = 'usr/bin'
     ASSETS = 'usr/share'
 
@@ -24,6 +35,7 @@ elif os.path.isfile('/etc/redhat-release'):
 
 elif os.path.isfile('/etc/arch-release'):
     FORMAT = 'arch'
+    DISTRO = 'arch'
     BINDIR = 'usr/bin'
     ASSETS = 'usr/share'
 
diff --git a/tools/game-data-packager.spec b/tools/game-data-packager.spec
index 248da00..d799d18 100644
--- a/tools/game-data-packager.spec
+++ b/tools/game-data-packager.spec
@@ -59,10 +59,12 @@ VERSION_PY=$RPM_BUILD_ROOT/usr/share/games/game-data-packager/game_data_packager
 echo '#!/usr/bin/python3' > $VERSION_PY
 echo 'GAME_PACKAGE_VERSION = """%{version}"""' >> $VERSION_PY
 echo 'FORMAT = "rpm"' >> $VERSION_PY
+echo 'DISTRO = "fedora"' >> $VERSION_PY
 echo 'BINDIR = "usr/bin"' >> $VERSION_PY
 echo 'ASSETS = "usr/share"' >> $VERSION_PY
 rm $RPM_BUILD_ROOT/usr/share/games/game-data-packager/game_data_packager/util_arch.py
 rm $RPM_BUILD_ROOT/usr/share/games/game-data-packager/game_data_packager/util_deb.py
+rm $RPM_BUILD_ROOT/usr/share/games/game-data-packager/game_data_packager/util_suse.py
 chmod 755 $RPM_BUILD_ROOT/usr/share/games/game-data-packager/game_data_packager/*.py
 chmod 755 $RPM_BUILD_ROOT/usr/share/games/game-data-packager/game_data_packager/games/*.py
 mkdir -p $RPM_BUILD_ROOT/usr/share/man/man6

-- 
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