[game-data-packager] 06/11: Move ASSETS, BINDIR, LICENSEDIR into PackagingSystem object
Simon McVittie
smcv at debian.org
Tue Jan 5 09:55:27 UTC 2016
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 b3ef1dfee2f916efeaed718a03a89fadb45acbb7
Author: Simon McVittie <smcv at debian.org>
Date: Tue Jan 5 00:05:55 2016 +0000
Move ASSETS, BINDIR, LICENSEDIR into PackagingSystem object
---
debian/rules | 3 ---
game_data_packager/__init__.py | 10 +++----
game_data_packager/build.py | 42 ++++++++++++++++++------------
game_data_packager/games/doom_common.py | 4 +--
game_data_packager/games/scummvm_common.py | 3 +--
game_data_packager/games/unreal.py | 3 +--
game_data_packager/games/z_code.py | 6 ++---
game_data_packager/packaging/__init__.py | 3 +++
game_data_packager/packaging/deb.py | 3 +++
game_data_packager/packaging/rpm.py | 2 ++
game_data_packager/version.py | 12 ---------
tools/game-data-packager.spec | 3 ---
12 files changed, 45 insertions(+), 49 deletions(-)
diff --git a/debian/rules b/debian/rules
index afcc122..46aadb7 100755
--- a/debian/rules
+++ b/debian/rules
@@ -31,9 +31,6 @@ override_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 'LICENSEDIR = "usr/share/doc"' >> 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 \
touch debian/game-data-packager/usr/share/games/game-data-packager/is-ubuntu-derived; \
fi
diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index 8a759c8..de7fd4e 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 (ASSETS, DISTRO, FORMAT, GAME_PACKAGE_VERSION)
+from .version import (DISTRO, FORMAT, GAME_PACKAGE_VERSION)
logging.basicConfig()
logger = logging.getLogger('game-data-packager')
@@ -239,9 +239,9 @@ class GameDataPackage(object):
# put 'usr/share/games/quake3/baseq3/pak1.pk3' in the .deb.
# The default is 'usr/share/games/' plus the binary package's name.
if name.endswith('-data'):
- self.install_to = ASSETS + '/' + name[:len(name) - 5]
+ self.install_to = '$assets/' + name[:len(name) - 5]
else:
- self.install_to = ASSETS + '/' + name
+ self.install_to = '$assets/' + name
# If true, this package is allowed to be empty
self.empty = False
@@ -838,9 +838,7 @@ class GameData(object):
"A package shouldn't extraneously provide itself"
if 'install_to' in d:
- if package.install_to.startswith('$assets/'):
- package.install_to = ASSETS + package.install_to[len('$assets'):]
- assert 'usr/share/games/' + package.name != d['install_to'] + '-data', \
+ assert '$assets/' + package.name != d['install_to'] + '-data', \
"install_to %s is extraneous" % package.name
if 'demo_for' in d:
diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index 221fbf9..4d9a2a0 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -57,7 +57,7 @@ from .util import (AGENT,
rm_rf,
recursive_utime,
which)
-from .version import (ASSETS, BINDIR, LICENSEDIR, FORMAT, DISTRO)
+from .version import (FORMAT, DISTRO)
if FORMAT == 'deb':
from debian.deb822 import Deb822
@@ -1334,7 +1334,8 @@ class PackagingTask(object):
if not f.license:
continue
license_file = f.install_as
- licenses.add("/%s/%s/%s" % (LICENSEDIR, package.name, license_file))
+ licenses.add("/%s/%s/%s" % (self.packaging.LICENSEDIR,
+ package.name, license_file))
if os.path.splitext(license_file)[0].lower() == 'license':
lintian_license(destdir, package.name, license_file)
@@ -1376,16 +1377,20 @@ class PackagingTask(object):
main_wad = f.install_as
exts.add(os.path.splitext(main_wad.lower())[1])
+ install_to = package.install_to
+ if install_to.startswith('$assets'):
+ install_to = self.packaging.ASSETS + install_to[7:]
+
if count_usr == 0 and count_doc == 1:
o.write('"/usr/share/doc/%s/%s"\n' % (package.name,
package.only_file))
elif count_usr == 1:
- o.write('"/%s/%s"\n' % (package.install_to, main_wad))
+ o.write('"/%s/%s"\n' % (install_to, main_wad))
elif len(exts) == 1:
o.write('The %s files under "/%s/"\n' %
- (list(exts)[0] ,package.install_to))
+ (list(exts)[0], install_to))
else:
- o.write('The files under "/%s/"\n' % package.install_to)
+ o.write('The files under "/%s/"\n' % install_to)
if count_usr and count_doc:
if count_usr == 1:
@@ -1551,7 +1556,8 @@ class PackagingTask(object):
docdir = os.path.join(destdir, 'usr/share/doc', package.name)
mkdir_p(docdir)
# only create licensedir if needed
- licensedir = os.path.join(destdir, LICENSEDIR, package.name)
+ licensedir = os.path.join(destdir, self.packaging.LICENSEDIR,
+ package.name)
shutil.copyfile(os.path.join(DATADIR, 'changelog.gz'),
os.path.join(docdir, 'changelog.gz'))
@@ -1587,13 +1593,15 @@ class PackagingTask(object):
if install_to is None:
install_to = package.install_to
- if install_to.startswith('$docdir'):
+ if install_to.startswith('$assets'):
+ install_to = self.packaging.ASSETS + install_to[7:]
+ elif install_to.startswith('$docdir'):
install_to = 'usr/share/doc/%s%s' % (package.name,
install_to[7:])
- if install_to.startswith('$licensedir'):
+ elif install_to.startswith('$licensedir'):
mkdir_p(licensedir)
- install_to = '%s/%s%s' % (LICENSEDIR, package.name,
- install_to[11:])
+ install_to = '%s/%s%s' % (self.packaging.LICENSEDIR,
+ package.name, install_to[11:])
copy_to = os.path.join(destdir, install_to, install_as)
copy_to_dir = os.path.dirname(copy_to)
@@ -1615,17 +1623,17 @@ class PackagingTask(object):
real_file = real_file.lstrip('/')
symlink = string.Template(symlink).safe_substitute(
- assets=ASSETS,
- bindir=BINDIR,
+ assets=self.packaging.ASSETS,
+ bindir=self.packaging.BINDIR,
docdir=docdir,
- LICENSEDIR=LICENSEDIR,
+ LICENSEDIR=self.packaging.LICENSEDIR,
licensedir=licensedir,
install_to=package.install_to)
real_file = string.Template(real_file).safe_substitute(
- assets=ASSETS,
- bindir=BINDIR,
+ assets=self.packaging.ASSETS,
+ bindir=self.packaging.BINDIR,
docdir=docdir,
- LICENSEDIR=LICENSEDIR,
+ LICENSEDIR=self.packaging.LICENSEDIR,
licensedir=licensedir,
install_to=package.install_to)
@@ -1653,6 +1661,8 @@ class PackagingTask(object):
for i, copy_from in self.cd_tracks[package.name].items():
logger.debug('Found CD track %d at %s', i, copy_from)
install_to = package.install_to
+ if install_to.startswith('$assets'):
+ install_to = self.packaging.ASSETS + install_to[7:]
install_as = package.rip_cd['filename_format'] % i
copy_to = os.path.join(destdir, install_to, install_as)
copy_to_dir = os.path.dirname(copy_to)
diff --git a/game_data_packager/games/doom_common.py b/game_data_packager/games/doom_common.py
index f9be0df..2b33d84 100644
--- a/game_data_packager/games/doom_common.py
+++ b/game_data_packager/games/doom_common.py
@@ -25,7 +25,7 @@ from .. import GameData
from ..build import (PackagingTask)
from ..paths import DATADIR
from ..util import (copy_with_substitutions, mkdir_p, lintian_desktop)
-from ..version import (FORMAT, ASSETS)
+from ..version import (FORMAT)
logger = logging.getLogger('game-data-packager.games.doom-common')
@@ -80,7 +80,7 @@ class DoomGameData(GameData):
if FORMAT == 'arch':
package.install_to = 'usr/share/games/doom'
else:
- package.install_to = ASSETS + '/doom'
+ package.install_to = '$assets/doom'
engine = package.engine or self.engine
engine = engine.split('|')[-1].strip()
package.program = package_map.get(engine, engine)
diff --git a/game_data_packager/games/scummvm_common.py b/game_data_packager/games/scummvm_common.py
index 90b0932..e90d192 100644
--- a/game_data_packager/games/scummvm_common.py
+++ b/game_data_packager/games/scummvm_common.py
@@ -25,7 +25,6 @@ from .. import GameData
from ..build import (PackagingTask)
from ..paths import DATADIR
from ..util import (mkdir_p, lintian_desktop)
-from ..version import (BINDIR)
logger = logging.getLogger('game-data-packager.games.scummvm-common')
@@ -135,7 +134,7 @@ class ScummvmTask(PackagingTask):
else:
pgm = package.name[0:len(package.name)-len('-data')]
entry['Exec'] = pgm
- bindir = os.path.join(destdir, BINDIR)
+ bindir = os.path.join(destdir, self.packaging.BINDIR)
mkdir_p(bindir)
path = os.path.join(bindir, pgm)
if 'en' not in package.langs:
diff --git a/game_data_packager/games/unreal.py b/game_data_packager/games/unreal.py
index 208cc59..ab15a2e 100644
--- a/game_data_packager/games/unreal.py
+++ b/game_data_packager/games/unreal.py
@@ -21,7 +21,6 @@ import os
from .. import (GameData)
from ..build import (PackagingTask)
from ..util import (TemporaryUmask, mkdir_p)
-from ..version import (ASSETS)
logger = logging.getLogger('game-data-packager.games.unreal')
@@ -34,7 +33,7 @@ class UnrealTask(PackagingTask):
self.__convert_logo(destdir)
def __convert_logo(self, destdir):
- skaarj_logo = os.path.join(destdir, ASSETS, 'unreal',
+ skaarj_logo = os.path.join(destdir, self.packaging.ASSETS, 'unreal',
'skaarj_logo.jpg')
try:
diff --git a/game_data_packager/games/z_code.py b/game_data_packager/games/z_code.py
index 010b03b..ff96989 100644
--- a/game_data_packager/games/z_code.py
+++ b/game_data_packager/games/z_code.py
@@ -25,7 +25,6 @@ from ..build import (PackagingTask)
from ..util import (TemporaryUmask,
mkdir_p,
lintian_desktop)
-from ..version import (BINDIR)
logger = logging.getLogger('game-data-packager.games.z_code')
@@ -85,13 +84,14 @@ class ZCodeTask(PackagingTask):
lintian_desktop(destdir, package.name, engine)
if engine == 'frotz':
- bindir = os.path.join(destdir, BINDIR)
+ bindir = os.path.join(destdir, self.packaging.BINDIR)
mkdir_p(bindir)
pgm = package.name[0:len(package.name)-len('-data')]
path = os.path.join(bindir, pgm)
with open(path, 'w') as f:
f.write('#!/bin/sh\n')
- f.write('test -x /%s/frotz && exec frotz $@ %s\n' % (BINDIR, arg))
+ f.write('test -x /%s/frotz && exec frotz $@ %s\n' %
+ (self.packaging.BINDIR, arg))
f.write('echo "You need to install some engine '
'like frotz to play this game"\n')
os.chmod(path, 0o755)
diff --git a/game_data_packager/packaging/__init__.py b/game_data_packager/packaging/__init__.py
index 93bcd1d..5ca2acf 100644
--- a/game_data_packager/packaging/__init__.py
+++ b/game_data_packager/packaging/__init__.py
@@ -19,6 +19,9 @@
from abc import (ABCMeta, abstractmethod)
class PackagingSystem(metaclass=ABCMeta):
+ ASSETS = 'usr/share'
+ BINDIR = 'usr/bin'
+ LICENSEDIR = 'usr/share/doc'
def is_installed(self, package):
"""Return boolean: is a package with the given name installed?"""
diff --git a/game_data_packager/packaging/deb.py b/game_data_packager/packaging/deb.py
index 9c8f44f..5d9c2f9 100644
--- a/game_data_packager/packaging/deb.py
+++ b/game_data_packager/packaging/deb.py
@@ -28,6 +28,9 @@ from ..util import (check_output, run_as_root)
logger = logging.getLogger(__name__)
class DebPackaging(PackagingSystem):
+ BINDIR = 'usr/games'
+ ASSETS = 'usr/share/games'
+
def __init__(self):
self.__installed = None
self.__available = None
diff --git a/game_data_packager/packaging/rpm.py b/game_data_packager/packaging/rpm.py
index b74f8f9..929992a 100644
--- a/game_data_packager/packaging/rpm.py
+++ b/game_data_packager/packaging/rpm.py
@@ -26,6 +26,8 @@ from ..util import (check_output, run_as_root)
logger = logging.getLogger(__name__)
class RpmPackaging(PackagingSystem):
+ LICENSEDIR = 'usr/share/licenses'
+
def is_installed(self, package):
return 0 == subprocess.call(['rpm', '-q', package],
stdout=subprocess.DEVNULL,
diff --git a/game_data_packager/version.py b/game_data_packager/version.py
index df570dd..9e419cf 100644
--- a/game_data_packager/version.py
+++ b/game_data_packager/version.py
@@ -17,27 +17,15 @@ with open('debian/changelog', encoding='utf-8') as cl:
if os.path.isfile('/etc/debian_version'):
FORMAT = 'deb'
DISTRO = 'generic'
- BINDIR = 'usr/games'
- ASSETS = 'usr/share/games'
- LICENSEDIR = 'usr/share/doc'
elif os.path.isfile('/etc/redhat-release'):
FORMAT = 'rpm'
DISTRO = 'fedora'
- BINDIR = 'usr/bin'
- ASSETS = 'usr/share'
- LICENSEDIR = 'usr/share/licenses'
elif os.path.isfile('/etc/SuSE-release'):
FORMAT = 'rpm'
DISTRO = 'suse'
- BINDIR = 'usr/bin'
- ASSETS = 'usr/share'
- LICENSEDIR = 'usr/share/licenses'
elif os.path.isfile('/etc/arch-release'):
FORMAT = 'arch'
DISTRO = 'arch'
- BINDIR = 'usr/bin'
- ASSETS = 'usr/share'
- LICENSEDIR = 'usr/share/doc'
diff --git a/tools/game-data-packager.spec b/tools/game-data-packager.spec
index 6481ca0..682d6af 100644
--- a/tools/game-data-packager.spec
+++ b/tools/game-data-packager.spec
@@ -76,9 +76,6 @@ 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 'LICENSEDIR = "usr/share/licenses"' >> $VERSION_PY
-echo 'ASSETS = "usr/share"' >> $VERSION_PY
find $RPM_BUILD_ROOT/usr/share/games/game-data-packager/game_data_packager -name '*.py' -exec chmod 755 {} \;
find $RPM_BUILD_ROOT/etc/game-data-packager -empty -exec sh -c "echo '# we need more mirrors' > {}" \;
--
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