-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for comparing Red Hat versions locally (#1355)
This adds support for comparing versions in the Red Hat ecosystem locally, in the same manner as the native `rpm` tool does. Huge shout out to @jantman whose fantastically concise [blog post](https://blog.jasonantman.com/2014/07/how-yum-and-rpm-compare-versions/#how-rpm-compares-version-parts) on how the comparator works provided just about everything I needed to implement this without involvement from other sources - the only thing it was missing is the caret special character, which I assume was added (probably long) after that blog post was written. I did have a peek at his PR for Puppet and some of the original sources for the manual test fixtures, but I appreciated not having to actively dig into the C code like I had to with Alpine 😅 Note that for the first time such a pull request for `semantic` does _not_ include a fixture generator because there are so many advisories/packages/versions in the osv.dev database that the file came out as over 1mb, so I'm going to do a dedicated pull request for the generator which will avoid committing the actual file but instead rely on the weekly `semantic` runs. Also, I believe some of the other ecosystems use this format under the hood (AlmaLinux and SUSE were mentioned by @hogo6002 , and I feel like I heard somewhere that Rocky Linux also might use `rpm`?); I have purposely not looked into those since I'm not familiar with this part of the digital world and ultimately support for them would be best landed in a dedicated pull request. Resolves #1336
- Loading branch information
Showing
4 changed files
with
407 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
1.0 = 1.0 | ||
1.0 < 2.0 | ||
2.0 > 1.0 | ||
2.0.1 = 2.0.1 | ||
2.0 < 2.0.1 | ||
2.0.1 > 2.0 | ||
2.0.1a = 2.0.1a | ||
2.0.1a > 2.0.1 | ||
2.0.1 < 2.0.1a | ||
5.5p1 = 5.5p1 | ||
5.5p1 < 5.5p2 | ||
5.5p2 > 5.5p1 | ||
5.5p10 = 5.5p10 | ||
5.5p1 < 5.5p10 | ||
5.5p10 > 5.5p1 | ||
10xyz < 10.1xyz | ||
10.1xyz > 10xyz | ||
xyz10 = xyz10 | ||
xyz10 < xyz10.1 | ||
xyz10.1 > xyz10 | ||
xyz.4 = xyz.4 | ||
xyz.4 < 8 | ||
8 > xyz.4 | ||
xyz.4 < 2 | ||
2 > xyz.4 | ||
5.5p2 < 5.6p1 | ||
5.6p1 > 5.5p2 | ||
5.6p1 < 6.5p1 | ||
6.5p1 > 5.6p1 | ||
6.0.rc1 > 6.0 | ||
6.0 < 6.0.rc1 | ||
10b2 > 10a1 | ||
10a2 < 10b2 | ||
1.0aa = 1.0aa | ||
1.0a < 1.0aa | ||
1.0aa > 1.0a | ||
10.0001 = 10.0001 | ||
10.0001 = 10.1 | ||
10.1 = 10.0001 | ||
10.0001 < 10.0039 | ||
10.0039 > 10.0001 | ||
4.999.9 < 5.0 | ||
5.0 > 4.999.9 | ||
20101121 = 20101121 | ||
20101121 < 20101122 | ||
20101122 > 20101121 | ||
2_0 = 2_0 | ||
2.0 = 2_0 | ||
2_0 = 2.0 | ||
a = a | ||
a+ = a+ | ||
a+ = a_ | ||
a_ = a+ | ||
+a = +a | ||
+a = _a | ||
_a = +a | ||
+_ = +_ | ||
_+ = +_ | ||
_+ = _+ | ||
+ = _ | ||
_ = + | ||
1.0~rc1 = 1.0~rc1 | ||
|
||
1.0~rc1 < 1.0 | ||
1.0 > 1.0~rc1 | ||
|
||
1.0~rc1 < 1.0~rc2 | ||
1.0~rc2 > 1.0~rc1 | ||
|
||
1.0~rc1~git123 = 1.0~rc1~git123 | ||
1.0~rc1~git123 < 1.0~rc1 | ||
1.0~rc1 < 1.0arc1 | ||
|
||
# epochs | ||
1:1 = 1:1 | ||
0:1 < 1:1 | ||
0:1 < 1:2 | ||
0:1~1 < 1:2 | ||
3:1~1 > 1:2 | ||
1~1 < 1:2 | ||
3 < 1:2 | ||
13 < 14:2 | ||
13:5 < 14:2 | ||
13:5 > 04:2 | ||
13:5 > 004:2 | ||
013:5 > 004:2 | ||
130:5 > 004:2 | ||
184:2 > 177:5 | ||
01:2 = 1:2 | ||
|
||
a:1 = a:1 | ||
a:1 < b:1 | ||
a:1 < a:2 | ||
a:1~1 < a:2 | ||
c:1~1 > a:2 | ||
|
||
a1:1 = a1:1 | ||
a1:1 < b1:1 | ||
a1:1 < a1:2 | ||
a2:1 > a1:2 | ||
|
||
b1:1 > a2:1 | ||
a:1 < a1:1 | ||
b:1 > a1:1 | ||
b~1:1 > a1:1 | ||
|
||
# releases | ||
1-123 > 1-2 | ||
1-1 = 1-1 | ||
1-2 > 1-1 | ||
1 < 1-1 | ||
1 < 1-0 | ||
1 < 1- | ||
1- = 1- | ||
|
||
1-123 > 1-1.el7 | ||
|
||
# arch | ||
0:3.10.0-229.el7 < 0:3.10.0-229.1.2.ael7b | ||
0:2.4.21-9.EL < 0:2.4.21-9.0.1.EL | ||
|
||
0:3.10.0-229.el7 < 0:3.10.0-229.1.2.ael7b | ||
1-1.a > 1-1. | ||
1-1. = 1-1. | ||
1-1. = 1-1 | ||
1-1 < 1-1.1 | ||
1. = 1 | ||
1-1.a = 1-1.a | ||
1-1.a < 1-1.e | ||
1-1.c > 1-1.b | ||
1-1.4 > 1-1.3 | ||
1-1.1 < 1-1.2 | ||
1-1.ael7b < 1-1.el7 | ||
0:3.10.0-229.1.2.ael7b < 0:3.10.0-229.1.2.el7 | ||
|
||
1 < 1- | ||
0:3.10.0-229.1.2.ael7b < 0:3.10.0-229.4.2.ael7b | ||
|
||
1.0^ = 1.0^ | ||
1.0^ > 1.0 | ||
1.0 < 1.0^ | ||
1.0^git1 = 1.0^git1 | ||
1.0^git1 > 1.0 | ||
1.0 < 1.0^git1 | ||
1.0^git1 < 1.0^git2 | ||
1.0^git2 > 1.0^git1 | ||
1.0^git1 < 1.01 | ||
1.01 > 1.0^git1 | ||
1.0^20160101 = 1.0^20160101 | ||
1.0^20160101 < 1.0.1 | ||
1.0.1 > 1.0^20160101 | ||
1.0^20160101^git1 = 1.0^20160101^git1 | ||
1.0^20160102 > 1.0^20160101^git1 | ||
1.0^20160101^git1 < 1.0^20160102 | ||
|
||
1.0~rc1^git1 = 1.0~rc1^git1 | ||
1.0~rc1^git1 > 1.0~rc1 | ||
1.0~rc1 < 1.0~rc1^git1 | ||
1.0^git1~pre = 1.0^git1~pre | ||
1.0^git1 > 1.0^git1~pre | ||
1.0^git1~pre < 1.0^git1 | ||
|
||
1.1.α = 1.1.α | ||
1.1.α = 1.1.β | ||
1.1.β = 1.1.α | ||
1.1.αα = 1.1.α | ||
1.1.α = 1.1.ββ | ||
1.1.ββ = 1.1.αα | ||
|
||
1.1.a < 1.2.ββ | ||
1.1.a < 0:1.2.ββ | ||
1.1.α < 1.1.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.