本文整理汇总了Python中rpm.labelCompare方法的典型用法代码示例。如果您正苦于以下问题:Python rpm.labelCompare方法的具体用法?Python rpm.labelCompare怎么用?Python rpm.labelCompare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rpm
的用法示例。
在下文中一共展示了rpm.labelCompare方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cmpKernelVer
# 需要导入模块: import rpm [as 别名]
# 或者: from rpm import labelCompare [as 别名]
def cmpKernelVer(str1, str2):
'compare two kernel version strings and return -1, 0, 1 for less, equal, greater'
import rpm
return rpm.labelCompare(('', str1, ''), ('', str2, ''))
示例2: nvrcmp
# 需要导入模块: import rpm [as 别名]
# 或者: from rpm import labelCompare [as 别名]
def nvrcmp(nvr1, nvr2):
if not RPM_AVAILABLE:
raise exception.RpmModuleNotAvailable()
t1 = string_to_version(nvr1)
t2 = string_to_version(nvr2)
return rpm.labelCompare(t1, t2)
示例3: vcmp
# 需要导入模块: import rpm [as 别名]
# 或者: from rpm import labelCompare [as 别名]
def vcmp(v1, v2):
if not RPM_AVAILABLE:
raise exception.RpmModuleNotAvailable()
t1 = ('0', v1, '')
t2 = ('0', v2, '')
return rpm.labelCompare(t1, t2)
示例4: _compare_rpm_labels
# 需要导入模块: import rpm [as 别名]
# 或者: from rpm import labelCompare [as 别名]
def _compare_rpm_labels(lhs, rhs):
lhs_epoch, lhs_version, lhs_release = lhs
rhs_epoch, rhs_version, rhs_release = rhs
result = _compare_rpm_field(lhs_epoch, rhs_epoch)
if result:
return result
result = _compare_rpm_field(lhs_version, rhs_version)
if result:
return result
return _compare_rpm_field(lhs_release, rhs_release)
示例5: rpm_cmp
# 需要导入模块: import rpm [as 别名]
# 或者: from rpm import labelCompare [as 别名]
def rpm_cmp(v1, v2):
diff = _compare_rpm_labels((None, v1, None), (None, v2, None))
return diff
示例6: is_pkg_vuln
# 需要导入模块: import rpm [as 别名]
# 或者: from rpm import labelCompare [as 别名]
def is_pkg_vuln(vtag, vpkg, flavor, ivers, iversonly, vvers):
isvuln = False
#print "cve-scan: " + vpkg + "\n\tvulnerability package version: " + vvers + "\n\timage package version: " + ivers
if vtag == 'VulnerableIn' and vvers == 'all':
isvuln = True
elif vvers != 'None':
if flavor == 'RHEL':
fixfile = vpkg + "-" + vvers + ".arch.rpm"
imagefile = vpkg + "-" + ivers + ".arch.rpm"
(n1, v1, r1, e1, a1) = splitFilename(imagefile)
(n2, v2, r2, e2, a2) = splitFilename(fixfile)
if vtag == 'FixedIn':
if rpm.labelCompare(('1', v1, r1), ('1', v2, r2)) < 0:
isvuln = True
elif vtag == 'VulnerableIn':
if ivers == vvers or iversonly == vvers:
isvuln = True
elif flavor == 'DEB':
if vtag == 'FixedIn':
if ivers != vvers:
comp_rc = dpkg_compare_versions(ivers, 'lt', vvers)
if comp_rc == 0:
isvuln = True
elif vtag == 'VulnerableIn':
if ivers == vvers or iversonly == vvers:
isvuln = True
elif flavor == "ALPINE":
if vtag == 'FixedIn':
comp_rc = apkg_compare_versions(ivers, 'lt', vvers)
if comp_rc == 0:
isvuln = True
elif vtag == 'VulnerableIn':
if ivers == vvers or iversonly == vvers:
isvuln = True
else:
isvuln = True
return(isvuln)
示例7: compare_evr
# 需要导入模块: import rpm [as 别名]
# 或者: from rpm import labelCompare [as 别名]
def compare_evr(evr1, evr2):
def epoch_to_str(epoch):
return str(epoch) if epoch is not None else None
evr1, evr2 = ((epoch_to_str(e), v, r) for (e, v, r) in (evr1, evr2))
return rpm.labelCompare(evr1, evr2)
示例8: rpmvercmp
# 需要导入模块: import rpm [as 别名]
# 或者: from rpm import labelCompare [as 别名]
def rpmvercmp(v1, v2):
return rpm.labelCompare((None, None, v1), (None, None, v2))
示例9: compare_package_versions
# 需要导入模块: import rpm [as 别名]
# 或者: from rpm import labelCompare [as 别名]
def compare_package_versions(imageId, pkga, vera, pkgb, verb):
# if ret == 0, versions are equal
# if ret > 0, vers A is greater than version B
# if ret < 0, vers A is less than version B
fulla = '-'.join([str(pkga), str(vera)])
fullb = '-'.join([str(pkgb), str(verb)])
if fulla == fullb:
return(0)
distrometa = get_distro_from_imageId(imageId)
idistro = distrometa['DISTRO']
idistrovers = distrometa['DISTROVERS']
ilikedistro = distrometa['LIKEDISTRO']
distrodict = get_distro_flavor(idistro, idistrovers, likedistro=ilikedistro)
flavor = distrodict['flavor']
if flavor == "RHEL":
fixfile = pkgb + "-" + verb + ".arch.rpm"
imagefile = pkga + "-" + vera + ".arch.rpm"
(n1, v1, r1, e1, a1) = splitFilename(imagefile)
(n2, v2, r2, e2, a2) = splitFilename(fixfile)
if rpm.labelCompare(('1', v1, r1), ('1', v2, r2)) < 0:
return(-1)
else:
return(1)
elif flavor == "DEB":
comp_rc = dpkg_compare_versions(vera, 'lt', verb)
if comp_rc == 0:
return(-1)
else:
return(1)
elif flavor == "ALPINE":
comp_rc = apkg_compare_versions(vera, 'lt', verb)
if comp_rc == 0:
return(-1)
else:
return(1)
else:
raise ValueError("unsupported distro, cannot compare package versions")
return(0)