|
From: | Plamen Totev |
Subject: | [bug #42844] version_find_latest function in grub-mkconfig_lib produces wrong results |
Date: | Sun, 04 Jan 2015 15:30:45 +0000 |
User-agent: | Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 |
Follow-up Comment #3, bug #42844 (project grub): version_find_latest function uses version_test_gt to sort the list. version_test_gt uses version_test_numeric to compare two versions. version_test_numeric depends on sort -V (if present but it is indeed present on CentOS) to determine the order of two versions. The problem is how sort -V works. This is excerpt From the info page(sorry but I didn't found an online version to give a link): Version-sorted strings are compared such that if VER1 and VER2 are version numbers and PREFIX and SUFFIX (SUFFIX matching the regular expression '(.[A-Za-z~][A-Za-z0-9~]*)*') are strings then VER1 < VER2 implies that the name composed of "PREFIX VER1 SUFFIX" sorts before "PREFIX VER2 SUFFIX". Some suffixes will not be matched by the regular expression mentioned above. Consequently these examples may not sort as you expect: abc-1.2.3.4.7z abc-1.2.3.7z abc-1.2.3.4.x86_64.rpm abc-1.2.3.x86_64.rpm The CentOS kernel images fall under the later exception - they end with .x86_64 - the '_' character is not recognized as suffix so vmlinuz-3.10.0-123.4.2.el7.x86_64 is before vmlinuz-3.10.0-123.el7.x86_64 ('4' is before 'e') and thus is sorted as older version. I've attached a patch that fixes this issue. It just strips the subversion groups after the first subversion group that does not begin with digit before passing the version string to version_test_numeric. ex: 3.10.0-123.4.2.el7.x86_64 becomes 3.10.0-123.4.2 and 3.10.0-123.el7.x86_64 becomes 3.10.0-123 so now they can be properly sorted with sort -V Some notes on the patch: * It does not solve http://savannah.gnu.org/bugs/?42921 but this bug is not exactly the same anyway. * Maybe it's safer to compare the suffixes of the two version and to strip them only if they are the same. As you can see from the point above some suffixes have special meaning for the version ordering. But even they are not stripped the current code does not work so it's better this suffixes to be handler separately (like the .old). _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?42844> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |