[game-data-packager] 06/09: Add support for patching files using xdelta

Simon McVittie smcv at debian.org
Thu Dec 24 16:28: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 ab6f25b55b9b4ba0c41bd2dda7722011291b60db
Author: Simon McVittie <smcv at debian.org>
Date:   Tue Dec 22 15:23:03 2015 +0000

    Add support for patching files using xdelta
    
    This operates on patches identified by file(1) as
    "XDelta binary patch file 1.1".
    
    If the file is set up like this:
    
        Fire.u.0:
          unpack:
            format: xdelta
            other_parts: [System/Fire.u?unpatched]
          provides: [System/Fire.u?patched]
    
    then we'll treat Fire.u.0 as the xdelta patch and apply it to
    the original file System/Fire.u?unpatched, to produce
    System/Fire.u?patched.
---
 debian/control                 |  2 ++
 doc/tags.txt                   |  2 +-
 game_data_packager/__init__.py |  7 +++++++
 game_data_packager/build.py    | 16 ++++++++++++++++
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/debian/control b/debian/control
index 9146256..88782c3 100644
--- a/debian/control
+++ b/debian/control
@@ -58,6 +58,8 @@ Suggests:
 	unrar,
 # for I have no mouth and I must scream
         unar,
+# for Unreal Tournament and potentially other Loki Games releases
+	xdelta,
 # for Doom2 Master Levels launcher
 	python3-gi,
 	gir1.2-gtk-3.0,
diff --git a/doc/tags.txt b/doc/tags.txt
index 6297621..3e317f8 100644
--- a/doc/tags.txt
+++ b/doc/tags.txt
@@ -98,7 +98,7 @@ files:
       flags: list (7z)
       groups: list (unshield)
       prefix: string (innoextract)
-      other_parts: list (cat, unshield, arj, innoextract)
+      other_parts: list (cat, unshield, arj, innoextract, unpatched file for xdelta)
       unpack: list
     provides: list
 
diff --git a/game_data_packager/__init__.py b/game_data_packager/__init__.py
index e6f59b4..d8ef300 100644
--- a/game_data_packager/__init__.py
+++ b/game_data_packager/__init__.py
@@ -1177,6 +1177,13 @@ class GameData(object):
                     assert len(wanted.provides) == 1, filename
                     assert isinstance(wanted.unpack['other_parts'],
                             list), filename
+                    for other_part in wanted.unpack['other_parts']:
+                        assert other_part in self.files, (filename, other_part)
+                elif wanted.unpack['format'] == 'xdelta':
+                    assert len(wanted.provides) == 1, filename
+                    assert len(wanted.unpack['other_parts']) == 1, filename
+                    assert isinstance(wanted.unpack['other_parts'][0], str), filename
+                    assert wanted.unpack['other_parts'][0] in self.files, filename
 
             if wanted.alternatives:
                 for alt_name in wanted.alternatives:
diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index a3f5521..535584a 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -1272,6 +1272,22 @@ class PackagingTask(object):
                 elif fmt == 'cat':
                     self.cat_files(package, provider, wanted)
 
+                elif fmt == 'xdelta':
+                    # provider (found_name) is the delta
+                    # other_parts contains only the base (unpatched) file
+                    # wanted is the patched file
+                    assert len(provider.unpack['other_parts']) == 1
+                    basis = self.game.files[provider.unpack['other_parts'][0]]
+                    if basis.name in self.found:
+                        out_path = os.path.join(self.get_workdir(), 'tmp',
+                                wanted.name)
+                        mkdir_p(os.path.dirname(out_path))
+                        check_call(['xdelta', 'patch', found_name,
+                            self.found[basis.name], out_path])
+                        orig_time = os.stat(found_name).st_mtime
+                        os.utime(out_path, (orig_time, orig_time))
+                        self.use_file(wanted, out_path)
+
                 if wanted.name in self.found:
                     assert (self.file_status[wanted.name] ==
                             FillResult.COMPLETE)

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