当前位置: 首页>>代码示例>>Python>>正文


Python rpm.labelCompare方法代码示例

本文整理汇总了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, '')) 
开发者ID:rpm-software-management,项目名称:mock,代码行数:6,代码来源:util.py

示例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) 
开发者ID:softwarefactory-project,项目名称:rdopkg,代码行数:8,代码来源:specfile.py

示例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) 
开发者ID:softwarefactory-project,项目名称:rdopkg,代码行数:8,代码来源:specfile.py

示例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) 
开发者ID:fedora-infra,项目名称:the-new-hotness,代码行数:12,代码来源:helpers.py

示例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 
开发者ID:fedora-infra,项目名称:the-new-hotness,代码行数:5,代码来源:helpers.py

示例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) 
开发者ID:anchore,项目名称:anchore,代码行数:43,代码来源:anchore_utils.py

示例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) 
开发者ID:fedora-infra,项目名称:koschei,代码行数:8,代码来源:util.py

示例8: rpmvercmp

# 需要导入模块: import rpm [as 别名]
# 或者: from rpm import labelCompare [as 别名]
def rpmvercmp(v1, v2):
    return rpm.labelCompare((None, None, v1), (None, None, v2)) 
开发者ID:fedora-infra,项目名称:koschei,代码行数:4,代码来源:common.py

示例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) 
开发者ID:anchore,项目名称:anchore,代码行数:45,代码来源:anchore_utils.py


注:本文中的rpm.labelCompare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。