auto-update: Use dpkg to compare versions

To avoid warnings like:
```
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 2:0.8.3 is an invalid version and will not be supported in a future release
```

Signed-off-by: Aditya Alok <alok@termux.dev>
This commit is contained in:
Aditya Alok 2023-01-22 12:44:31 +05:30
parent 119b8a83f2
commit c626262307
No known key found for this signature in database
GPG Key ID: 345AE134142077D8
1 changed files with 1 additions and 12 deletions

View File

@ -10,18 +10,7 @@ termux_pkg_is_update_needed() {
# Compare versions.
# shellcheck disable=SC2091
if $(
cat <<-EOF | python3 -
import sys
from pkg_resources import parse_version
if parse_version("${CURRENT_VERSION}") < parse_version("${LATEST_VERSION}"):
sys.exit(0)
else:
sys.exit(1)
EOF
); then
if dpkg --compare-versions "${LATEST_VERSION}" gt "${CURRENT_VERSION}"; then
return 0 # true. Update needed.
fi
return 1 # false. Update not needed.