libgeos: Disable build for now
[termux-packages] / scripts / apt-compare-versions
1 #!/usr/bin/env python3
2 # apt-compare-versions: Simple script which takes two arguments and compares
3 # their version according to apt rules. This can be used to verify the ordering
4 # between two versions.
5 #
6 # Note that ~ (tilde) construct, which allows for beta and preview releases.
7 # A version with ~ is considered earlier than one without, so 1.6~beta1 is
8 # considered earlier than 1.6. If both versions contains ~ the version comparison
9 # is made first on the part preceding the tilde, then the part coming after,
10 # so 1.6~beta1 comes before 1.6~beta2.
11
12 import apt_pkg, sys
13 apt_pkg.init_system()
14
15 if len(sys.argv) != 3:
16 sys.exit('usage: apt-compare-versions <first-version> <second-version>')
17
18 version1 = sys.argv[1]
19 version2 = sys.argv[2]
20
21 comparison_result = apt_pkg.version_compare(version1, version2)
22 if comparison_result > 0:
23 operator = ' > '
24 elif comparison_result < 0:
25 operator = ' < '
26 elif comparison_result == 0:
27 operator = ' == '
28
29 print(version1 + operator + version2)