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
答案 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