From 56076f124f8a2eb4b563a1a3041edb4eab802555 Mon Sep 17 00:00:00 2001 From: "yan11.meng" Date: Sun, 26 Apr 2020 15:29:01 +0800 Subject: [PATCH] fix gbs build error about path with'[]' Change-Id: I3c68124934850fd211b2b0de27f15fdc31405275 Signed-off-by: yan11.meng --- gitbuildsys/utils.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gitbuildsys/utils.py b/gitbuildsys/utils.py index 4982826..8224290 100644 --- a/gitbuildsys/utils.py +++ b/gitbuildsys/utils.py @@ -68,8 +68,7 @@ def guess_spec(git_path, packaging_dir, given_spec, commit_id='WC.UNTRACKED'): packaging_dir = os.readlink(packaging_dir) check = lambda fname, dir_only=False: os.path.exists(os.path.join( git_path, fname)) - glob_ = lambda pattern: [name.replace(git_path+'/', '') \ - for name in reversed(glob.glob(os.path.join(git_path, pattern)))] + glob_ = lambda pattern: glob_in_inc(git_path, packaging_dir, pattern) msg = 'No such spec file %s' else: git_object = commit_id + ':' + packaging_dir @@ -96,7 +95,10 @@ def guess_spec(git_path, packaging_dir, given_spec, commit_id='WC.UNTRACKED'): if not check(spec): raise GbsError(msg % spec) - specs = glob_(os.path.join(packaging_dir, '*.spec')) + if commit_id == 'WC.UNTRACKED': + specs=glob_('*.spec') + else: + specs = glob_(os.path.join(packaging_dir, '*.spec')) if not specs: raise GbsError("can't find any spec file under packaging dir: " "%s" % packaging_dir) @@ -778,6 +780,16 @@ def file_exists_in_rev(git_path, relative_path, commit_id, dir_only=False): return output != '' +def glob_in_inc(git_path, packaging_dir, pattern): + f_path=os.path.join(git_path,packaging_dir) + specs = [] + if(os.path.isdir(f_path)): + for filename in os.listdir(f_path): + if fnmatch.fnmatch(filename,pattern): + specs.append(os.path.join(packaging_dir,filename)) + return specs + + def glob_in_rev(git_path, pattern, commit_id): """Glob pattern in given revision.""" -- 2.34.1