[game-data-packager] 02/19: GameData: factor out build_deb from run_command_line
Simon McVittie
smcv at debian.org
Tue Jan 13 11:34:37 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 64bdf800b0a1c580655f1afb2f454e0e6afe44e9
Author: Simon McVittie <smcv at debian.org>
Date: Tue Jan 13 08:54:27 2015 +0000
GameData: factor out build_deb from run_command_line
---
lib/game_data_packager/__init__.py | 80 ++++++++++++++++++++++----------------
1 file changed, 46 insertions(+), 34 deletions(-)
diff --git a/lib/game_data_packager/__init__.py b/lib/game_data_packager/__init__.py
index 3363d56..2273516 100644
--- a/lib/game_data_packager/__init__.py
+++ b/lib/game_data_packager/__init__.py
@@ -1337,9 +1337,7 @@ class GameData(object):
# anyway
args.compress = preserve_debs
- # only compress if the command-line says we should and the YAML
- # says it's worthwhile
- compress_deb = (self.compress_deb and getattr(args, 'compress', True))
+ compress = getattr(args, 'compress', True)
for path in self.try_repack_from:
if os.path.isdir(path):
@@ -1431,41 +1429,17 @@ class GameData(object):
debs = set()
for package in ready:
- destdir = os.path.join(self.get_workdir(),
- '%s.deb.d' % package.name)
- if not self.fill_dest_dir(package, destdir):
- raise SystemExit(1)
-
- # it had better have a /usr and a DEBIAN directory or
- # something has gone very wrong
- assert os.path.isdir(os.path.join(destdir, 'usr')), destdir
- assert os.path.isdir(os.path.join(destdir, 'DEBIAN')), destdir
-
- deb_basename = '%s_%s_all.deb' % (package.name, package.version)
-
- if args.destination is not None:
- outfile = os.path.join(os.path.abspath(args.destination),
- deb_basename)
+ if args.destination is None:
+ destination = self.get_workdir()
else:
- outfile = os.path.join(self.get_workdir(), deb_basename)
+ destination = args.destination
- if compress_deb:
- dpkg_deb_args = []
- else:
- dpkg_deb_args = ['-Znone']
+ deb = self.build_deb(package, destination, compress=compress)
- try:
- subprocess.check_output(['fakeroot', 'dpkg-deb'] +
- dpkg_deb_args +
- ['-b', '%s.deb.d' % package.name, outfile],
- cwd=self.get_workdir())
- except subprocess.CalledProcessError as cpe:
- print(cpe.output)
- raise
-
- debs.add(outfile)
+ if deb is None:
+ raise SystemExit(1)
- rm_rf(destdir)
+ debs.add(deb)
rm_rf(os.path.join(self.get_workdir(), 'tmp'))
@@ -1513,6 +1487,44 @@ class GameData(object):
def construct_package(self, binary):
return GameDataPackage(binary)
+ 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)
+ if not self.fill_dest_dir(package, destdir):
+ # FIXME: probably better as an exception?
+ return None
+
+ # it had better have a /usr and a DEBIAN directory or
+ # something has gone very wrong
+ assert os.path.isdir(os.path.join(destdir, 'usr')), destdir
+ assert os.path.isdir(os.path.join(destdir, 'DEBIAN')), destdir
+
+ deb_basename = '%s_%s_all.deb' % (package.name, package.version)
+
+ outfile = os.path.join(os.path.abspath(destination), deb_basename)
+
+ # only compress if the caller says we should and the YAML
+ # says it's worthwhile
+ if compress and self.compress_deb:
+ dpkg_deb_args = []
+ else:
+ dpkg_deb_args = ['-Znone']
+
+ try:
+ subprocess.check_output(['fakeroot', 'dpkg-deb'] +
+ dpkg_deb_args +
+ ['-b', '%s.deb.d' % package.name, outfile],
+ cwd=self.get_workdir())
+ except subprocess.CalledProcessError as cpe:
+ print(cpe.output)
+ raise
+
+ rm_rf(destdir)
+ return outfile
+
def load_yaml_games(workdir=None):
games = {}
--
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