[game-data-packager] 03/07: Warn if we unpack an archive and it doesn't contain everything that our metadata says it should

Simon McVittie smcv at debian.org
Wed Oct 21 11:00:45 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 8e4b28fe94af1001102f3a5e4fe6625eb3784543
Author: Simon McVittie <smcv at debian.org>
Date:   Wed Oct 21 08:25:58 2015 +0100

    Warn if we unpack an archive and it doesn't contain everything that our metadata says it should
---
 debian/changelog            |  2 ++
 game_data_packager/build.py | 28 +++++++++++++++++++---------
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index f2c723e..2583a8c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -92,6 +92,8 @@ game-data-packager (43) UNRELEASED; urgency=medium
   * Enable parallel build
   * Log external commands at debug level before we run them
   * Never try to unpack an archive more than once
+  * Warn if we unpack an archive and it doesn't contain everything that
+    our metadata says it should
 
  -- Simon McVittie <smcv at debian.org>  Thu, 16 Jul 2015 09:59:23 +0200
 
diff --git a/game_data_packager/build.py b/game_data_packager/build.py
index ad2c853..46e0718 100644
--- a/game_data_packager/build.py
+++ b/game_data_packager/build.py
@@ -626,9 +626,14 @@ class PackagingTask(object):
 
         logger.warning(message, *args)
 
-    def consider_file_or_dir(self, path):
+    def consider_file_or_dir(self, path, provider=None):
         st = os.stat(path)
 
+        if provider is None:
+            should_provide = set()
+        else:
+            should_provide = set(provider.provides)
+
         if stat.S_ISREG(st.st_mode):
             self.consider_file(path, True)
         elif stat.S_ISDIR(st.st_mode):
@@ -646,6 +651,11 @@ class PackagingTask(object):
             logger.warning('file "%s" does not exist or is not a file, ' +
                     'directory or CD block device', path)
 
+        for missing in sorted(should_provide):
+            if missing not in self.found:
+                logger.error('%s should have provided %s but did not',
+                        self.found[provider.name], missing)
+
     def fill_gaps(self, package, download=False, log=True, recheck=False):
         """Return a FillResult.
         """
@@ -1086,7 +1096,7 @@ class PackagingTask(object):
                     quiet = [] if self.verbose else ['-q']
                     check_call(['cabextract'] + quiet + ['-L',
                             os.path.abspath(found_name)], cwd=tmpdir)
-                    self.consider_file_or_dir(tmpdir)
+                    self.consider_file_or_dir(tmpdir, provider=provider)
                 elif fmt == 'unace-nonfree':
                     to_unpack = provider.unpack.get('unpack', provider.provides)
                     logger.debug('Extracting %r from %s',
@@ -1097,7 +1107,7 @@ class PackagingTask(object):
                     check_call(['unace', 'x',
                              os.path.abspath(found_name)] +
                              list(to_unpack), cwd=tmpdir)
-                    self.consider_file_or_dir(tmpdir)
+                    self.consider_file_or_dir(tmpdir, provider=provider)
                 elif fmt == 'unrar-nonfree':
                     to_unpack = provider.unpack.get('unpack', provider.provides)
                     logger.debug('Extracting %r from %s',
@@ -1109,7 +1119,7 @@ class PackagingTask(object):
                     check_call(['unrar-nonfree', 'x'] + quiet +
                              [os.path.abspath(found_name)] +
                              list(to_unpack), cwd=tmpdir)
-                    self.consider_file_or_dir(tmpdir)
+                    self.consider_file_or_dir(tmpdir, provider=provider)
                 elif fmt == 'innoextract':
                     to_unpack = provider.unpack.get('unpack', provider.provides)
                     logger.debug('Extracting %r from %s', to_unpack, found_name)
@@ -1141,7 +1151,7 @@ class PackagingTask(object):
                             i = i.split('?')[0]
                             cmdline.append(i)
                     check_call(cmdline)
-                    self.consider_file_or_dir(tmpdir)
+                    self.consider_file_or_dir(tmpdir, provider=provider)
                 elif fmt == 'unzip' and which('unzip'):
                     to_unpack = provider.unpack.get('unpack', provider.provides)
                     logger.debug('Extracting %r from %s',
@@ -1155,7 +1165,7 @@ class PackagingTask(object):
                             list(to_unpack), cwd=tmpdir)
                     # -j junk paths
                     # -C use case-insensitive matching
-                    self.consider_file_or_dir(tmpdir)
+                    self.consider_file_or_dir(tmpdir, provider=provider)
                 elif fmt in ('7z', 'unzip'):
                     to_unpack = provider.unpack.get('unpack', provider.provides)
                     logger.debug('Extracting %r from %s',
@@ -1169,7 +1179,7 @@ class PackagingTask(object):
                     check_call(['7z', 'x'] + flags +
                                 [os.path.abspath(found_name)] +
                                 list(to_unpack), cwd=tmpdir)
-                    self.consider_file_or_dir(tmpdir)
+                    self.consider_file_or_dir(tmpdir, provider=provider)
                 elif fmt in ('unar', 'unzip'):
                     to_unpack = provider.unpack.get('unpack', provider.provides)
                     logger.debug('Extracting %r from %s', to_unpack, found_name)
@@ -1180,7 +1190,7 @@ class PackagingTask(object):
                     check_call(['unar', '-D'] +
                                quiet + [os.path.abspath(found_name)] +
                                list(to_unpack), cwd=tmpdir)
-                    self.consider_file_or_dir(tmpdir)
+                    self.consider_file_or_dir(tmpdir, provider=provider)
                 elif fmt == 'unshield':
                     to_unpack = provider.unpack.get('unpack', provider.provides)
                     logger.debug('Extracting %r from %s', to_unpack, found_name)
@@ -1206,7 +1216,7 @@ class PackagingTask(object):
                         for fn in filenames:
                             full = os.path.join(dirpath, fn)
                             os.utime(full, (orig_time, orig_time))
-                    self.consider_file_or_dir(tmpdir)
+                    self.consider_file_or_dir(tmpdir, provider=provider)
                 elif fmt == 'arj':
                     to_unpack = provider.unpack.get('unpack', provider.provides)
                     logger.debug('Extracting %r from %s',

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