[entropy.qa/entropy.spm] implement Entropy SPM QA check routines and add hook to entropy.qa

This commit is contained in:
Fabio Erculiani
2009-10-11 00:57:36 +02:00
parent 4052792e93
commit f3e8cff068
3 changed files with 77 additions and 1 deletions
+14 -1
View File
@@ -991,6 +991,18 @@ class QAInterface:
return valid
def __check_package_using_spm(self, package_path):
from entropy.spm.plugins.factory import get_default_class
spm_class = get_default_class()
spm_rc, spm_msg = spm_class.execute_qa_tests(package_path)
if spm_rc == 0:
return True
sys.stderr.write("QA Error: " + spm_msg)
sys.stderr.flush()
return False
def entropy_package_checks(self, package_path):
"""
Main method for the execution of QA tests on physical Entropy
@@ -1001,7 +1013,8 @@ class QAInterface:
@return: True, if all checks passed
@rtype: bool
"""
qa_methods = [self.__analyze_package_edb]
qa_methods = [self.__analyze_package_edb,
self.__check_package_using_spm]
for method in qa_methods:
qa_rc = method(package_path)
if not qa_rc:
@@ -2028,6 +2028,63 @@ class PortagePlugin(SpmPlugin):
return 0
@staticmethod
def execute_qa_tests(package_path):
"""
Reimplemented from SpmPlugin class.
"""
tests = [PortagePlugin._test_environment_bz2]
msg = None
exec_rc = 0
for test in tests:
exec_rc, msg = test(package_path)
if exec_rc != 0:
break
return exec_rc, msg
@staticmethod
def _test_environment_bz2(package_path):
tmp_path = tempfile.mkdtemp()
entropy.tools.extract_xpak(package_path, tmpdir = tmp_path)
if not os.listdir(tmp_path):
shutil.rmtree(tmp_path)
return 1, "unable to extract xpak metadata"
# make sure we have the environment.bz2 file to check
env_file = os.path.join(tmp_path, PortagePlugin.ENV_FILE_COMP)
if not (os.path.isfile(env_file) and os.access(env_file, os.R_OK)):
shutil.rmtree(tmp_path)
return 2, "unable to locate %s file" % (
PortagePlugin.ENV_FILE_COMP,)
# read env file
bz_f = bz2.BZ2File(env_file, "r")
valid_lc_all = True
msg = None
lc_all_str = const_convert_to_rawstring("LC_ALL")
lc_all_c = const_convert_to_rawstring("LC_ALL=C")
lc_all_enus = const_convert_to_rawstring("LC_ALL=en_US")
try:
for line in bz_f.readlines():
if line.startswith(lc_all_str):
if line.startswith(lc_all_c) or \
line.startswith(lc_all_enus):
continue
valid_lc_all = False
msg = "LC_ALL set to => %s" % (line.strip(),)
break
finally:
bz_f.close()
env_rc = 0
if not valid_lc_all:
env_rc = 1
shutil.rmtree(tmp_path)
return env_rc, msg
@staticmethod
def entropy_install_setup_hook(entropy_client, package_metadata):
"""
+6
View File
@@ -524,6 +524,12 @@ class SpmPlugin(Singleton):
files. This method can be used to test Entropy produced packages
to make sure that they are fine on this side too. It is called
by Entropy QA module (entropy.qa).
@param package_path: path to Entropy package
@type package_path: string
@return: tuple composed by error status and error message (if any).
Error status is an int with != 0 values if error occured.
@rtype: tuple
"""
raise NotImplementedError()