百胜是否意识到包年表?

时间:2013-12-03 20:40:41

标签: yum

yum是否了解包年表?

假设我构建了一个包 MY-PKG-0.40-1 并将其发布到带有createrepo --update的yum仓库中。然后我用较低版本(来自不同的VCS分支)构建另一个包, MY-PKG-0.38-5

yum list recent似乎显示最佳版本,而不是最新版本。但是从手册页

   yum list recent
          List packages recently added into the repositories. This is often not
          helpful, but what you may really want to use is
          "yum list-updateinfo new" from the security yum plugin.

我已经尝试过list-updateinfo new并且收效甚微。 yum list-updateinfo new MY-PKG似乎返回了包所属的存储库...

尽管已经发布了 0.40-1

1 个答案:

答案 0 :(得分:0)

这里的答案是。由于yum管理RPM并且运行rpm -qi <package>将列出Build Date字段(它是包头的一部分)。

在网上挖掘yum python库并处理部分code samples on the yum wiki后,我能够编写一个工作样本,其中列出了最新版本的封装

#!/usr/bin/python

import sys 
import yum 

package = sys.argv[1:]

yb = yum.YumBase()
yb.conf.cache = 0 # Must run as root to search packages w/o cache
pl = yb.doPackageLists(patterns=package, pkgnarrow='all', showdups=True)

print 'Searching for latest version of package: ' + str(package[0])

if pl.available:
    package = ''
    latest  = 0 
    for pkg in sorted(pl.available):
        # XXX Works with sqlitesack, unsure if it works with rpmsack
        buildtime = pkg['buildtime']

        # If we're looking at the latest package, update the version
        # and textual name for reference
        if max(latest, buildtime) == buildtime:
            latest  = buildtime
            package = pkg 

    print "Latest Package"
    print package