[game-data-packager] 14/39: Do the .deb installation from Python for YAML games
Simon McVittie
smcv at debian.org
Sun Jan 11 01:52:22 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 518895919649621fb7e211f81dd6f1fb946a915f
Author: Simon McVittie <smcv at debian.org>
Date: Sat Jan 10 19:00:36 2015 +0000
Do the .deb installation from Python for YAML games
---
lib/game_data_packager/__init__.py | 25 +++++++++++++++++++++++++
lib/via-python | 21 +++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/lib/game_data_packager/__init__.py b/lib/game_data_packager/__init__.py
index 7f40ee5..f02e6ca 100644
--- a/lib/game_data_packager/__init__.py
+++ b/lib/game_data_packager/__init__.py
@@ -27,6 +27,7 @@ import logging
import os
import random
import re
+import shlex
import shutil
import subprocess
import sys
@@ -1074,6 +1075,11 @@ class GameData(object):
metavar='DIRECTORY|FILE')
def run_command_line(self, args, outdir=''):
+ self.preserve_debs = getattr(args, 'preserve', False)
+ self.install_debs = getattr(args, 'install', True)
+ self.compress_deb = (self.compress_deb and
+ getattr(args, 'compress', True))
+
if args.repack:
can_repack = False
absent = set()
@@ -1166,6 +1172,8 @@ class GameData(object):
if not ready:
raise SystemExit(1)
+ debs = set()
+
for package in ready:
destdir = os.path.join(self.get_workdir(),
'%s.deb.d' % package.name)
@@ -1200,14 +1208,31 @@ class GameData(object):
print(cpe.output)
raise
+ debs.add(outfile)
+
rm_rf(destdir)
rm_rf(os.path.join(self.get_workdir(), 'tmp'))
+ if self.preserve_debs:
+ for deb in debs:
+ print('generated "%s"' % os.path.abspath(deb))
+
+ if self.install_debs:
+ print('using su(1) to obtain root privileges and install the package(s)')
+ cmd = 'dpkg -i'
+ for deb in debs:
+ cmd = cmd + ' ' + shlex.quote(deb)
+
+ subprocess.call(['su', '-c', cmd])
+
def run_command_line():
datadir = os.environ['DATADIR']
etcdir = os.environ['ETCDIR']
workdir = os.environ['WORKDIR']
+ logger.debug('Running with DATADIR=%s ETCDIR=%s WORKDIR=%s',
+ datadir, etcdir, workdir)
+ logger.debug('Arguments: %r', sys.argv)
parser = argparse.ArgumentParser(prog='game-data-packager',
description='Package game files.')
diff --git a/lib/via-python b/lib/via-python
index 0730576..5a5d860 100644
--- a/lib/via-python
+++ b/lib/via-python
@@ -28,6 +28,23 @@ gdp_data_driven () {
if [ -n "${DEBUG:-}" ]; then
export DEBUG
fi
+ if [ "$INSTALL" = "yes" ]; then
+ set _ --no-install "$@"
+ else
+ set _ --install "$@"
+ fi
+ shift
+ if [ "$COMPRESS" = "yes" ]; then
+ set _ --compress "$@"
+ else
+ set _ --no-compress "$@"
+ fi
+ shift
+ if [ "$PRESERVE" = "yes" ]; then
+ set _ -d "$OUTDIR" "$@"
+ shift
+ fi
+ debug "Will run: python3 -m game_data_packager $*"
python3 -m game_data_packager "$@"
exit $?
)
@@ -39,4 +56,8 @@ gdp_data_driven () {
# Special value to signal that gdp should just install every .deb
# in $WORKDIR
OUTFILE="*.deb"
+
+ # The Python code does the installation if necessary, so we don't
+ # need to deal with this in shell script any more
+ INSTALL=no
}
--
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