From d1b305f1c62275ee1ad07cbe39ea34d143c9807d Mon Sep 17 00:00:00 2001 From: Zhang Qiang Date: Wed, 15 Aug 2012 10:46:04 +0800 Subject: [PATCH] support multiple repos from gbs.conf and command line opts RepoParser class should parse all repos and generate standard repos and composite repos. --- gitbuildsys/utils.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/gitbuildsys/utils.py b/gitbuildsys/utils.py index 8ccf2ec..4d11b56 100644 --- a/gitbuildsys/utils.py +++ b/gitbuildsys/utils.py @@ -192,6 +192,7 @@ class RepoParser(object): self.repourls = {} self.buildmeta = None self.buildconf = None + self.standardrepos = [] self.parse() def get_buildconf(self): @@ -233,7 +234,10 @@ class RepoParser(object): validrepos.append(repo) except errors.UrlError: pass - self.repourls[arch] = validrepos + if arch in self.repourls: + self.repourls[arch] += validrepos + else: + self.repourls[arch] = validrepos self.archs = archs def parse(self): @@ -245,29 +249,30 @@ class RepoParser(object): try: urlgrab(repomd_url, repomd_file) + self.standardrepos.append(repo) # Try to download build.xml buildxml_url = urlparse.urljoin(repo.rstrip('/') + '/', \ '../../../../builddata/build.xml') self.buildmeta = os.path.join(self.cachedir, \ os.path.basename(buildxml_url)) - urlgrab(buildxml_url, self.buildmeta) # Try to download build conf if self.buildconf is None: + urlgrab(buildxml_url, self.buildmeta) build_conf = self.get_buildconf() buildconf_url = buildxml_url.replace(os.path.basename \ (buildxml_url), build_conf) self.buildconf = os.path.join(self.cachedir, \ os.path.basename(buildconf_url)) urlgrab(buildconf_url, self.buildconf) - # buildconf downloaded succeed, break! - break + # standard repo + continue except errors.UrlError: # if it's standard repo, that means buildconf fails to be - # downloaded, so reset buildconf and break + # downloaded, so reset buildconf and continue if self.buildmeta: self.buildconf = None - break + continue pass # Check if it's repo with builddata/build.xml exist @@ -294,6 +299,9 @@ class RepoParser(object): except errors.UrlError: self.buildconf = None + # reset buildmeta + self.buildmeta = None + # Split out local repo for repo in self.repos: if repo.startswith('/') and os.path.exists(repo): @@ -302,13 +310,13 @@ class RepoParser(object): def get_repos_by_arch(self, arch): # return directly for standard repos if not self.repourls: - return self.repos + self.localrepos + return self.localrepos + self.standardrepos if arch in ['ia32', 'i686', 'i586']: arch = 'ia32' if arch in self.repourls: - return self.repourls[arch] + self.localrepos + return self.repourls[arch] + self.localrepos + self.standardrepos return None -- 2.7.4