我正在尝试将以前版本为 1.03ii-1 的 RPM 升级为最新版本的软件包 1.1-1。
Yum,出于某种原因,认为 1.03ii-1 比 1.1-1 更新。这两个包都没有纪元,rpm.labelCompare(('1', '1.03ii', '1'), ('1','1.1','1')) 在 python 中也是如此暗示 1.03ii-1 高于 1.1-1。
这是为什么? ii 是否以某种方式被评估为数字?字母数字版本是否被视为高于数字版本?
请您参考如下方法:
来自 http://rpm5.org/docs/api/dependencies.html , 强调我的
The algorithm that RPM uses to determine the version ordering of packages is simple and developers are encouraged not to rely on the details of its working. Developers should keep their numbering scheme simple so any reasonable ordering algorithm would work. The version comparison algorithm is in the routine rpmvercmp() and it is just a segmented strcmp(3). First, the boundaries of the segments are found using isdigit(3)/isalpha(3). Each segment is then compared in order with the right most segment being the least significant. The alphabetical portions are compared using a lexical graphical ascii ordering, the digit segments strip leading zeroes and compare the strlen before doing a strcmp. If both numerical strings are equal, the longer string is larger. Notice that the algorithm has no knowledge of decimal fractions, and perl-5.6 is "older" than perl-5.00503 because the number 6 is less than the number 503.
在这种情况下,版本被转换为元组 (1,3,'ii') 和 (1,1)。第一个元素相等,所以第二个元素与 3 > 1 进行比较,因此 1.03ii 被认为比 1.1 新
