[csw-devel] SF.net SVN: gar:[19962] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Wed Dec 26 12:33:55 CET 2012
Revision: 19962
http://gar.svn.sourceforge.net/gar/?rev=19962&view=rev
Author: wahwah
Date: 2012-12-26 11:33:54 +0000 (Wed, 26 Dec 2012)
Log Message:
-----------
checkpkg: chicken-and-egg mimetype problem fix
The IsBinary() function is used to:
1. Figure out whether a file is a binary file
2. Check if hachoir parser info is already there
3. Whether we should collect hachoir parser info
The first time we're calling it to figure out whether we should collect
hachoir parser info, so obviously hachoir parser info is not present yet, and
we need to tell it to not check for that.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/inspective_package.py
csw/mgar/gar/v2/lib/python/sharedlib_utils.py
Modified: csw/mgar/gar/v2/lib/python/inspective_package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/inspective_package.py 2012-12-26 11:32:30 UTC (rev 19961)
+++ csw/mgar/gar/v2/lib/python/inspective_package.py 2012-12-26 11:33:54 UTC (rev 19962)
@@ -54,7 +54,7 @@
"will probably finish successfully when do you that."
% full_path)
raise package.PackageError(msg)
- if sharedlib_utils.IsBinary(file_info):
+ if sharedlib_utils.IsBinary(file_info, check_consistency=False):
parser = hachoir_parser.createParser(full_path)
if not parser:
logging.warning("Can't parse file %s", file_path)
Modified: csw/mgar/gar/v2/lib/python/sharedlib_utils.py
===================================================================
--- csw/mgar/gar/v2/lib/python/sharedlib_utils.py 2012-12-26 11:32:30 UTC (rev 19961)
+++ csw/mgar/gar/v2/lib/python/sharedlib_utils.py 2012-12-26 11:33:54 UTC (rev 19962)
@@ -217,8 +217,16 @@
return LCS
-def IsBinary(file_info):
- """Returns True or False depending on file metadata."""
+def IsBinary(file_info, check_consistency=True):
+ """Returns True or False depending on file metadata.
+
+ Args:
+ file_info: A dictionary containing file information
+ check_consistency: Whether to check for consistency between the mimetype
+ information and other information, such as machine_id. During the
+ initial data gathering, the check must be disabled, because IsBinary()
+ is used to determine whether we should collect machine_id or not.
+ """
is_a_binary = False
if "mime_type" not in file_info:
# This would be a problem in the data.
@@ -231,13 +239,12 @@
if mimetype in file_info["mime_type"]:
is_a_binary = True
break
- if is_a_binary and not "machine_id" in file_info:
+ if check_consistency and is_a_binary and not "machine_id" in file_info:
raise DataInconsistencyError(
"'machine_id' not found in file_info: %r. checkpkg can't continue, "
"but it's not a problem with checkpkg; it's a problem with the underlying "
"libraries. In this case it's the hachoir library, which failed to "
- "detect the processor type for this binary. A workaround for it "
- "could be building the binary again, e.g. 'mgar clean package'."
+ "detect the processor type for this binary."
% file_info)
return is_a_binary
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list