[game-data-packager] 01/01: make-template: sniff Makeself archives

Alexandre Detiste detiste-guest at moszumanska.debian.org
Tue Apr 28 17:46:23 UTC 2015


This is an automated email from the git hooks/post-receive script.

detiste-guest pushed a commit to branch master
in repository game-data-packager.

commit 66de9020324b8833e91e73b1335f5dedd83d34f1
Author: Alexandre Detiste <alexandre.detiste at gmail.com>
Date:   Tue Apr 28 19:45:17 2015 +0200

    make-template: sniff Makeself archives
---
 game_data_packager/make_template.py | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/game_data_packager/make_template.py b/game_data_packager/make_template.py
index 7edd7ce..5226dd4 100644
--- a/game_data_packager/make_template.py
+++ b/game_data_packager/make_template.py
@@ -189,6 +189,40 @@ def do_one_file(name,lower):
     out_name = os.path.basename(name)
     if lower:
         out_name = out_name.lower()
+
+    # sniff Makeself archives
+    # http://megastep.org/makeself/
+    has_makeself = False
+    SHEBANG = bytes('/bin/sh', 'ascii')
+    HEADER_V1 = bytes('# This script was generated using Makeself 1.', 'ascii')
+    HEADER_V2 = bytes('# This script was generated using Makeself 2.', 'ascii')
+    TRAILER_V1 = bytes('END_OF_STUB', 'ascii')
+    TRAILER_V2 = bytes('eval $finish; exit $res', 'ascii')
+    with open(name, 'rb') as raw:
+        skip = 0
+        pos = 0
+        for line in raw:
+            pos += 1
+            skip += len(line)
+            if pos == 1 and SHEBANG not in line:
+                break
+            elif has_makeself:
+                if trailer in line:
+                    break
+            elif HEADER_V1 in line:
+                has_makeself = True
+                trailer = TRAILER_V1
+            elif HEADER_V2 in line:
+                has_makeself = True
+                trailer = TRAILER_V2
+            elif pos > 3:
+                break
+    if has_makeself:
+        print('  %s' % out_name)
+        print('    unpack: tar.gz')
+        print('    skip: %d' % skip)
+        print()
+
     print('  _ %-9s %s' % (os.path.getsize(name), out_name))
     print('  %s  %s' % (hf.md5, out_name))
     print('  %s  %s' % (hf.sha1, out_name))

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