[game-data-packager] 01/01: handle creation of 'free' packages

Alexandre Detiste detiste-guest at moszumanska.debian.org
Sat Apr 25 16:48:25 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 abdbc98113bf951d674539d053b3ddb9c0833271
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Sat Apr 25 18:47:47 2015 +0200

    handle creation of 'free' packages
---
 data/sfinx.yaml                |  2 ++
 data/soltys.yaml               |  4 ++++
 game_data_packager/__init__.py | 48 +++++++++++++++++++++++++++++++++++-------
 3 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/data/sfinx.yaml b/data/sfinx.yaml
index 9d1075e..a980eb8 100644
--- a/data/sfinx.yaml
+++ b/data/sfinx.yaml
@@ -13,6 +13,7 @@ packages:
     debian:
       version: '1.1'
       provides: sfinx-data
+    section: games
     install:
     - vol.cat
     - vol.dat
@@ -24,6 +25,7 @@ packages:
     debian:
       version: '1.0'
       provides: sfinx-data
+    section: games
     install:
     - vol.cat_pl
     - vol.dat_pl
diff --git a/data/soltys.yaml b/data/soltys.yaml
index c17edb5..fb4be95 100644
--- a/data/soltys.yaml
+++ b/data/soltys.yaml
@@ -9,6 +9,8 @@ packages:
     debian:
       version: '1.0'
       provides: soltys-data
+    # instead of non-free/games
+    section: games
     install:
     - vol.cat
     - vol.dat
@@ -20,6 +22,7 @@ packages:
     debian:
       version: '1.0'
       provides: soltys-data
+    section: games
     install:
     - vol.cat_pl
     - vol.dat_pl
@@ -31,6 +34,7 @@ packages:
     debian:
       version: '1.0'
       provides: soltys-data
+    section: games
     install:
     - vol.cat_es
     - vol.dat_es
diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index 65bdd09..ea071db 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -394,6 +394,9 @@ class GameDataPackage(object):
         # Debian architecture(s)
         self.architecture = 'all'
 
+        # Debian section
+        self.section = 'non-free/games'
+
     @property
     def aliases(self):
         return self._aliases
@@ -768,11 +771,12 @@ class GameData(object):
         for k in ('expansion_for', 'longname', 'symlinks', 'install_to',
                 'install_to_docdir', 'install_contents_of', 'steam', 'debian',
                 'rip_cd', 'architecture', 'aliases', 'better_version',
-                'copyright', 'engine', 'gog', 'origin', 'lang'):
+                'copyright', 'engine', 'gog', 'origin', 'lang', 'section'):
             if k in d:
                 setattr(package, k, d[k])
 
         assert self.copyright or package.copyright, package.name
+        assert package.section in ('non-free/games', 'games'), 'unsupported'
 
         if 'install_to' in d:
             assert 'usr/share/games/' + package.name != d['install_to'] + '-data', \
@@ -1706,8 +1710,13 @@ class GameData(object):
              open(copy_to, 'w', encoding='utf-8') as o:
             o.write('The package %s was generated using '
                     'game-data-packager.\n' % package.name)
-            o.write('It contains proprietary game data '
-                    'and must not be redistributed.\n\n')
+
+            if package.section.split('/')[0] == 'non-free':
+                o.write('It contains proprietary game data '
+                        'and must not be redistributed.\n\n')
+            else:
+                o.write('It contains free game data '
+                        'and may be redistributed.\n\n')
 
             count_usr = 0
             exts = set()
@@ -1750,7 +1759,7 @@ class GameData(object):
 
             licenses = set()
             for f in package.install | package.optional:
-                 if self.file_status[f] is FillResult.IMPOSSIBLE:
+                 if self.file_status[f] is not FillResult.COMPLETE:
                      continue
                  if self.files[f].license:
                      license_file = self.files[f].install_as
@@ -1948,7 +1957,6 @@ class GameData(object):
         control['Installed-Size'] = str(installed_size)
 
         default_values = {
-            'Section' : 'non-free/games',
             'Priority' : 'optional',
             'Architecture' : 'all',
             'Maintainer' : 'Debian Games Team <pkg-games-devel at lists.alioth.debian.org>',
@@ -1957,6 +1965,9 @@ class GameData(object):
             if field not in control:
                 control[field] = default_values[field]
 
+        assert 'Section' not in control, 'please specify only in YAML'
+        control['Section'] = package.section
+
         if package.architecture != 'all':
             control['Architecture'] = self.get_architecture()
 
@@ -2027,9 +2038,13 @@ class GameData(object):
 
             short_desc = package.data_type + ' for "' + longname + '" game'
 
-            long_desc =  ' This package was built using game-data-packager. It contains\n'
-            long_desc += ' proprietary game data and must not be redistributed.\n'
-            long_desc += ' .\n'
+            long_desc =  ' This package was built using game-data-packager.\n'
+            if package.section == 'non-free/games':
+                long_desc += ' It contains proprietary game data and must not be redistributed.\n'
+                long_desc += ' .\n'
+            elif package.section == 'games':
+                long_desc += ' It contains free game data and may be redistributed.\n'
+                long_desc += ' .\n'
 
             if self.genre:
                 long_desc += ' Genre: ' + self.genre + '\n'
@@ -2525,12 +2540,29 @@ class GameData(object):
     def construct_package(self, binary):
         return GameDataPackage(binary)
 
+    def check_section(self, package):
+        # free packages are free as long as their
+        # optional license file is present
+        if package.section.split('/')[0] == 'non-free':
+            return
+        license_missing = False
+        for f in package.optional:
+             if not self.files[f].license:
+                 continue
+             if self.file_status[f] is not FillResult.COMPLETE:
+                 license_missing = True
+                 break
+        if license_missing:
+            package.section = 'non-free/' + package.section
+
     def build_deb(self, package, destination, compress=True):
         """
         If we have all the necessary files for package, build the .deb
         and return the output filename in destination. Otherwise return None.
         """
         destdir = os.path.join(self.get_workdir(), '%s.deb.d' % package.name)
+
+        self.check_section(package)
         if not self.fill_dest_dir(package, destdir):
             # FIXME: probably better as an exception?
             return None

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