[game-data-packager] 13/21: Add the ability to use .copyright or .copyright.in files based on shortname
Simon McVittie
smcv at debian.org
Wed Jan 21 11:52:01 UTC 2015
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch master
in repository game-data-packager.
commit bf507feef8711ac699dd0c9221662b763681eaf4
Author: Simon McVittie <smcv at debian.org>
Date: Wed Jan 21 10:20:16 2015 +0000
Add the ability to use .copyright or .copyright.in files based on shortname
---
lib/game_data_packager/__init__.py | 19 +++++++++++++++++--
lib/game_data_packager/games/doom_common.py | 16 +++++-----------
lib/game_data_packager/util.py | 6 ++++++
3 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/lib/game_data_packager/__init__.py b/lib/game_data_packager/__init__.py
index 3019159..a250855 100644
--- a/lib/game_data_packager/__init__.py
+++ b/lib/game_data_packager/__init__.py
@@ -46,6 +46,7 @@ import yaml
from .paths import DATADIR, ETCDIR
from .util import (MEBIBYTE,
TemporaryUmask,
+ copy_with_substitutions,
mkdir_p,
rm_rf,
human_size,
@@ -1440,8 +1441,22 @@ class GameData(object):
return complete
def fill_docs(self, package, docdir):
- shutil.copyfile(os.path.join(DATADIR, package.name + '.copyright'),
- os.path.join(docdir, 'copyright'))
+ for n in (package.name, self.shortname):
+ copy_from = os.path.join(DATADIR, n + '.copyright')
+ copy_to = os.path.join(docdir, 'copyright')
+
+ if os.path.exists(copy_from):
+ shutil.copyfile(copy_from, copy_to)
+ return
+
+ if os.path.exists(copy_from + '.in'):
+ copy_with_substitutions(open(copy_from + '.in'),
+ open(copy_to, 'w'),
+ PACKAGE=package.name)
+ return
+
+ raise AssertionError('should have found a copyright file for %s' %
+ package.name)
def fill_extra_files(self, package, destdir):
pass
diff --git a/lib/game_data_packager/games/doom_common.py b/lib/game_data_packager/games/doom_common.py
index 2d16d05..8ecf8d2 100644
--- a/lib/game_data_packager/games/doom_common.py
+++ b/lib/game_data_packager/games/doom_common.py
@@ -21,19 +21,13 @@ import subprocess
from .. import GameData, GameDataPackage
from ..paths import DATADIR
-from ..util import TemporaryUmask, mkdir_p
+from ..util import (TemporaryUmask, copy_with_substitutions, mkdir_p)
logger = logging.getLogger('game-data-packager.games.doom-common')
def install_data(from_, to):
subprocess.check_call(['cp', '--reflink=auto', from_, to])
-def subst(from_, to, **kwargs):
- for line in from_:
- for k, v in kwargs.items():
- line = line.replace(k, v)
- to.write(line)
-
class WadPackage(GameDataPackage):
def __init__(self, name):
super(WadPackage, self).__init__(name)
@@ -115,12 +109,12 @@ class DoomGameData(GameData):
def fill_docs(self, package, docdir):
main_wad = package.main_wad
- subst(
+ copy_with_substitutions(
open(os.path.join(DATADIR, 'doom-common.README.Debian.in')),
open(os.path.join(docdir, 'README.Debian'), 'w'),
PACKAGE=package.name,
GAME=(package.longname or self.longname))
- subst(
+ copy_with_substitutions(
open(os.path.join(DATADIR, 'doom-common.copyright.in')),
open(os.path.join(docdir, 'copyright'), 'w'),
PACKAGE=package.name,
@@ -148,7 +142,7 @@ class DoomGameData(GameData):
for basename in (package.name, 'doom-common'):
from_ = os.path.join(DATADIR, basename + '.desktop.in')
if os.path.exists(from_):
- subst(open(from_),
+ copy_with_substitutions(open(from_),
open(os.path.join(appdir, '%s.desktop' % package.name),
'w'),
GAME=wad_base,
@@ -160,7 +154,7 @@ class DoomGameData(GameData):
debdir = os.path.join(destdir, 'DEBIAN')
mkdir_p(debdir)
- subst(
+ copy_with_substitutions(
open(os.path.join(DATADIR, 'doom-common.preinst.in')),
open(os.path.join(debdir, 'preinst'), 'w'),
IWAD=main_wad)
diff --git a/lib/game_data_packager/util.py b/lib/game_data_packager/util.py
index f31b320..e2fd42f 100644
--- a/lib/game_data_packager/util.py
+++ b/lib/game_data_packager/util.py
@@ -69,3 +69,9 @@ def human_size(size):
# 1.0 MiB or more
return '%.1f MiB' % (size / (MEBIBYTE))
+
+def copy_with_substitutions(from_, to, **kwargs):
+ for line in from_:
+ for k, v in kwargs.items():
+ line = line.replace(k, v)
+ to.write(line)
--
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