Bug 8361

Summary: opkg compare_versions is broken (old issue #166)
Product: [Yocto Project Subprojects] opkg Reporter: Alejandro del Castillo <alejandro.delcastillo>
Component: opkgAssignee: Alejandro del Castillo <alejandro.delcastillo>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Undecided CC: michael
Version: 0.3.0   
Target Milestone: 0.3.2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Alejandro del Castillo 2015-09-21 01:26:04 UTC
What steps will reproduce the problem?
1. in a shell, run `opkg compare_versions` with various versions and relations.

What is the expected output? What do you see instead?
When comparing things in Linux, it is typical for 0 to be returned if a condition is satisfied and a non-zero value otherwise. The compare_versions command in opkg does the opposite. Furthermore, several checks return the incorrect value (e.g. 1.0 '=' 1.0 and 1.0 '<<' 1.0 will return 0, while 1.0 '>>' 1.0 will return 1). For reference, calling `dpkg --compare-versions 1.0 '=' 1.0` will return 0, while `dpkg --compare-versions 1.0 '<<' 1.0` and `dpkg --compare-versions 1.0 '>>' 1.0` return 1.

What version of the product are you using? On what operating system?
0.3.0, Linux Mint 17.1 x64

Please provide any additional information below.
Functionality for checking versions is also provided in opkg-utils in opkg-compare-versions.c . Since the current implementation in opkg_cmd.c is broken and the proper functionality is included in opkg-utils, perhaps we can pull this command out from opkg and encourage the use of the version comparison functionality in opkg-utils instead?

Originally reported by ericaustinyu, Jul 23, 2015
-----------------------------------------------------------------------------
Comment 1 Michael (test) Halstead 2016-01-20 19:56:35 UTC
Testing comments on opkg bugs with an unprivileged user.
Comment 2 Alejandro del Castillo 2016-03-23 18:41:13 UTC
opkg compare versions logic should follow dpkg's:

lt le eq ne ge gt       (treat empty version as earlier than any version)
lt-nl le-nl ge-nl gt-nl (treat empty version as later than any version)

Once the internal opkg compare version logic gets fixed, the 2 utilities for comparing versions on opkg-utils should be removed.
Comment 3 Alejandro del Castillo 2016-05-02 22:29:57 UTC
fixed on commits by Ross Burton:

3e8521e137f662005edec1e7dd597bdd808624ea
d55020a9eee90b092cc468b458882e84a42be49a
17fe7933fa68d5b208c13ae2f9353cbd5375f253