Fix rpmlint checker bug when rpmlint config not exists
authorLingchaox Xin <lingchaox.xin@intel.com>
Fri, 24 May 2013 03:20:39 +0000 (11:20 +0800)
committerGerrit Code Review <gerrit2@otctools.jf.intel.com>
Mon, 27 May 2013 02:51:14 +0000 (19:51 -0700)
We have added git-obs-mapping project judgement to ensure it existing
indeed, so give an equal treatment to rpmlint-config project in Gerrit.

Change-Id: I70ed0314651bcd1d327279e915a2b578ecb11ecc

common/rpmlint.py

index 630fbf5..c1d2ded 100644 (file)
@@ -27,6 +27,8 @@ import Config
 import Pkg
 import Filter
 
+from common.git import clone_gitproject
+
 def rpmlint(spec_file):
 
     def __print(s):
@@ -79,10 +81,16 @@ def rpmlint(spec_file):
 
     # the tempfile is designed for python policycheck.py, bash script doesn't use it
 
+    rpmlint_prj = os.getenv('RPMLINT_PRJ')
+    git_cache_dir = os.getenv('GIT_CACHE_DIR')
+    rpmlint_config_dir = os.path.join(git_cache_dir, rpmlint_prj)
+
+    # if rpmlint_config does NOT exist, then clone it from gerrit projects.
+    if not os.path.isdir(rpmlint_config_dir):
+        clone_gitproject(rpmlint_prj, rpmlint_config_dir)
+
     try:
-        rpmlint_config = os.path.join(os.getenv('GIT_CACHE_DIR'),
-                                      os.getenv('RPMLINT_PRJ'),
-                                      'rpmlint')
+        rpmlint_config = os.path.join(git_cache_dir, rpmlint_prj, 'rpmlint')
         if not os.path.isfile(rpmlint_config):
             rpmlint_config = '~/.config/rpmlint'
         execfile(os.path.expanduser(rpmlint_config))