From: Zhang Qiang Date: Tue, 2 Apr 2013 10:22:47 +0000 (+0800) Subject: condider repo priority while sorting packages X-Git-Tag: 0.18~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4cc9b1be3146a70485977b1dde0677b3d4b7530d;p=tools%2Fmic.git condider repo priority while sorting packages standard criterion: - arch compatibility with highest priority - repo priority - package version have lowest priority Change-Id: I86dcb35a568ddc0162e6145b6871dc2502c3d24f --- diff --git a/plugins/backend/zypppkgmgr.py b/plugins/backend/zypppkgmgr.py index abc4f41..7272805 100755 --- a/plugins/backend/zypppkgmgr.py +++ b/plugins/backend/zypppkgmgr.py @@ -170,6 +170,8 @@ class Zypp(BackendPlugin): obs.status().setToBeInstalled (zypp.ResStatus.USER) def cmpEVR(p1, p2): + # compare criterion: arch compatibility first, then repo + # priority, and version last a1 = p1.arch() a2 = p2.arch() if str(a1) != str(a2): @@ -177,6 +179,15 @@ class Zypp(BackendPlugin): return -1 else: return 1 + # Priority of a repository is an integer value between 0 (the + # highest priority) and 99 (the lowest priority) + p1 = int(p1.repoInfo().priority()) + p2 = int(p2.repoInfo().priority()) + if p1 > p2: + return -1 + elif p1 < p2: + return 1 + ed1 = p1.edition() ed2 = p2.edition() (e1, v1, r1) = map(str, [ed1.epoch(), ed1.version(), ed1.release()])