[yocto] [auh][PATCH] gitrecipe/rename: avoid renaming incorrect files

jackie.huang at windriver.com jackie.huang at windriver.com
Thu Apr 16 23:32:32 PDT 2015


From: Jackie Huang <jackie.huang at windriver.com>

Previously f.find('pn') will not only match 'pn' but also packages
that have 'pn' in their names, for example 'python-glance' will
match 'python-glance', 'python-glanceclient' and 'python-glancestore',
so the later two packages will be incorrectly changed.

Get the exact package name to compare with pn to void this issue.

Signed-off-by: Jackie Huang <jackie.huang at windriver.com>
---
 gitrecipe.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/gitrecipe.py b/gitrecipe.py
index dfa5cd2..706483b 100644
--- a/gitrecipe.py
+++ b/gitrecipe.py
@@ -66,10 +66,14 @@ class GitRecipe(Recipe):
 
         for f in os.listdir(self.recipe_dir):
             full_path_f = os.path.join(self.recipe_dir, f)
-            if os.path.isfile(full_path_f) and \
-                    ((f.find(self.env['PN']) == 0 and (f.find(old_git_tag) != -1 or
-                      f.find("git") != -1) and f.find(".bb") != -1) or
-                     (f.find(self.env['PN']) == 0 and f.find(".inc") != -1)):
+
+            # We only care about files like pn_[pv|git].<bb|inc>
+            fname, fext = os.path.splitext(f)
+            if os.path.isfile(full_path_f) and (fext == ".bb" or fext == ".inc"):
+                f = fname.split("_")
+                if f[0] != self.env['PN'] or (len(f) == 2 and f[1] != old_git_tag and f[1] != "git"):
+                    continue
+
                 with open(full_path_f + ".tmp", "w+") as temp_recipe:
                     with open(full_path_f) as recipe:
                         for line in recipe:
-- 
1.9.1




More information about the yocto mailing list