summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGui Chen <gui.chen@intel.com>2012-09-22 23:00:40 +0800
committerGui Chen <gui.chen@intel.com>2012-12-12 19:33:23 +0800
commit7b057b0e36df3e71c9fc24a877614438036db9a7 (patch)
tree46239a1d23b0e815c5c373cb8bdd7db62f6f0862
parentb14f06a0dd03eb4a5c558214bfc025d197c26dbd (diff)
downloadmic-7b057b0e36df3e71c9fc24a877614438036db9a7.tar.gz
mic-7b057b0e36df3e71c9fc24a877614438036db9a7.tar.bz2
mic-7b057b0e36df3e71c9fc24a877614438036db9a7.zip
decide uniq arch when one repo only has one uniq arch
the arch detection is changed: when one uniq arch is found in a repo, this arch should be detected arch now. Signed-off-by: Gui Chen <gui.chen@intel.com>
-rw-r--r--mic/utils/misc.py58
1 files changed, 35 insertions, 23 deletions
diff --git a/mic/utils/misc.py b/mic/utils/misc.py
index 5b5a299..9458bae 100644
--- a/mic/utils/misc.py
+++ b/mic/utils/misc.py
@@ -621,8 +621,35 @@ def get_rpmver_in_repo(repometadata):
return None
def get_arch(repometadata):
- archlist = []
+ def uniqarch(archlist=[]):
+ uniq_arch = []
+ for i in range(len(archlist)):
+ if archlist[i] not in rpmmisc.archPolicies.keys():
+ continue
+ need_append = True
+ j = 0
+ while j < len(uniq_arch):
+ if archlist[i] in rpmmisc.archPolicies[uniq_arch[j]].split(':'):
+ need_append = False
+ break
+ if uniq_arch[j] in rpmmisc.archPolicies[archlist[i]].split(':'):
+ if need_append:
+ uniq_arch[j] = archlist[i]
+ need_append = False
+ else:
+ uniq_arch.remove(uniq_arch[j])
+ continue
+ j += 1
+ if need_append:
+ uniq_arch.append(archlist[i])
+
+ return uniq_arch
+
+
+ ret_uniq_arch = []
+ ret_arch_list = []
for repo in repometadata:
+ archlist = []
if repo["primary"].endswith(".xml"):
root = xmlparse(repo["primary"])
ns = root.getroot().tag
@@ -640,28 +667,13 @@ def get_arch(repometadata):
con.close()
- uniq_arch = []
- for i in range(len(archlist)):
- if archlist[i] not in rpmmisc.archPolicies.keys():
- continue
- need_append = True
- j = 0
- while j < len(uniq_arch):
- if archlist[i] in rpmmisc.archPolicies[uniq_arch[j]].split(':'):
- need_append = False
- break
- if uniq_arch[j] in rpmmisc.archPolicies[archlist[i]].split(':'):
- if need_append:
- uniq_arch[j] = archlist[i]
- need_append = False
- else:
- uniq_arch.remove(uniq_arch[j])
- continue
- j += 1
- if need_append:
- uniq_arch.append(archlist[i])
-
- return uniq_arch, archlist
+ uniq_arch = uniqarch(archlist)
+ if not ret_uniq_arch and len(uniq_arch) == 1:
+ ret_uniq_arch = uniq_arch
+ ret_arch_list += uniq_arch
+
+ ret_arch_list = uniqarch(ret_arch_list)
+ return ret_uniq_arch, ret_arch_list
def get_package(pkg, repometadata, arch = None):
ver = ""