mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
Provides a Version class wrapper around apt_pkg.version_compare. Replaces distutils.version which is deprecated. Closes: #2261. Tests: - Install ejabberd. Signed-off-by: James Valleroy <jvalleroy@mailbox.org> [sunil: Add two more version comparison tests] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
23 lines
514 B
Python
23 lines
514 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Compare Debian package version numbers.
|
|
"""
|
|
|
|
from functools import total_ordering
|
|
|
|
from apt import apt_pkg
|
|
|
|
|
|
@total_ordering
|
|
class Version:
|
|
"""The version number of a Debian package."""
|
|
|
|
def __init__(self, version: str):
|
|
self.version = version
|
|
|
|
def __eq__(self, other):
|
|
return apt_pkg.version_compare(self.version, other.version) == 0
|
|
|
|
def __lt__(self, other):
|
|
return apt_pkg.version_compare(self.version, other.version) < 0
|