Handle legacy version specifiers that would previously raise exceptions.
This commit is contained in:
parent
a3ad67b505
commit
2c2f8bd984
@ -1,7 +1,7 @@
|
|||||||
Name: python-rpm-generators
|
Name: python-rpm-generators
|
||||||
Summary: Dependency generators for Python RPMs
|
Summary: Dependency generators for Python RPMs
|
||||||
Version: 12
|
Version: 12
|
||||||
Release: 10%{?dist}
|
Release: 11%{?dist}
|
||||||
|
|
||||||
# Originally all those files were part of RPM, so license is kept here
|
# Originally all those files were part of RPM, so license is kept here
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
@ -47,6 +47,9 @@ install -Dpm0755 -t %{buildroot}%{_rpmconfigdir} *.py
|
|||||||
%{_rpmconfigdir}/pythonbundles.py
|
%{_rpmconfigdir}/pythonbundles.py
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sun Dec 19 2021 Gordon Messmer <gordon.messmer@gmail.com> - 12-11
|
||||||
|
- Handle legacy version specifiers that would previously raise exceptions.
|
||||||
|
|
||||||
* Fri Oct 29 2021 Gordon Messmer <gordon.messmer@gmail.com> - 12-10
|
* Fri Oct 29 2021 Gordon Messmer <gordon.messmer@gmail.com> - 12-10
|
||||||
- Additional fix for dev releases.
|
- Additional fix for dev releases.
|
||||||
|
|
||||||
|
@ -138,6 +138,9 @@ class RpmVersion():
|
|||||||
# in public releases
|
# in public releases
|
||||||
# https://www.python.org/dev/peps/pep-0440/#local-version-identifiers
|
# https://www.python.org/dev/peps/pep-0440/#local-version-identifiers
|
||||||
|
|
||||||
|
def is_legacy(self):
|
||||||
|
return isinstance(self.version, str)
|
||||||
|
|
||||||
def increment(self):
|
def increment(self):
|
||||||
self.version[-1] += 1
|
self.version[-1] += 1
|
||||||
self.pre = None
|
self.pre = None
|
||||||
@ -146,7 +149,7 @@ class RpmVersion():
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if isinstance(self.version, str):
|
if self.is_legacy():
|
||||||
return self.version
|
return self.version
|
||||||
if self.epoch:
|
if self.epoch:
|
||||||
rpm_epoch = str(self.epoch) + ':'
|
rpm_epoch = str(self.epoch) + ':'
|
||||||
@ -172,6 +175,11 @@ def convert_compatible(name, operator, version_id):
|
|||||||
print('Invalid requirement: {} {} {}'.format(name, operator, version_id), file=stderr)
|
print('Invalid requirement: {} {} {}'.format(name, operator, version_id), file=stderr)
|
||||||
exit(65) # os.EX_DATAERR
|
exit(65) # os.EX_DATAERR
|
||||||
version = RpmVersion(version_id)
|
version = RpmVersion(version_id)
|
||||||
|
if version.is_legacy():
|
||||||
|
# LegacyVersions are not supported in this context
|
||||||
|
print("*** INVALID_REQUIREMENT_ERROR___SEE_STDERR ***")
|
||||||
|
print('Invalid requirement: {} {} {}'.format(name, operator, version_id), file=stderr)
|
||||||
|
exit(65) # os.EX_DATAERR
|
||||||
if len(version.version) == 1:
|
if len(version.version) == 1:
|
||||||
print("*** INVALID_REQUIREMENT_ERROR___SEE_STDERR ***")
|
print("*** INVALID_REQUIREMENT_ERROR___SEE_STDERR ***")
|
||||||
print('Invalid requirement: {} {} {}'.format(name, operator, version_id), file=stderr)
|
print('Invalid requirement: {} {} {}'.format(name, operator, version_id), file=stderr)
|
||||||
@ -204,6 +212,11 @@ def convert_not_equal(name, operator, version_id):
|
|||||||
if version_id.endswith('.*'):
|
if version_id.endswith('.*'):
|
||||||
version_id = version_id[:-2]
|
version_id = version_id[:-2]
|
||||||
version = RpmVersion(version_id)
|
version = RpmVersion(version_id)
|
||||||
|
if version.is_legacy():
|
||||||
|
# LegacyVersions are not supported in this context
|
||||||
|
print("*** INVALID_REQUIREMENT_ERROR___SEE_STDERR ***")
|
||||||
|
print('Invalid requirement: {} {} {}'.format(name, operator, version_id), file=stderr)
|
||||||
|
exit(65) # os.EX_DATAERR
|
||||||
version_gt = RpmVersion(version_id).increment()
|
version_gt = RpmVersion(version_id).increment()
|
||||||
version_gt_operator = '>='
|
version_gt_operator = '>='
|
||||||
# Prevent dev and pre-releases from satisfying a < requirement
|
# Prevent dev and pre-releases from satisfying a < requirement
|
||||||
@ -235,6 +248,8 @@ def convert_ordered(name, operator, version_id):
|
|||||||
operator = '<'
|
operator = '<'
|
||||||
else:
|
else:
|
||||||
version = RpmVersion(version_id)
|
version = RpmVersion(version_id)
|
||||||
|
# For backwards compatibility, fallback to previous behavior with LegacyVersions
|
||||||
|
if not version.is_legacy():
|
||||||
# Prevent dev and pre-releases from satisfying a < requirement
|
# Prevent dev and pre-releases from satisfying a < requirement
|
||||||
if operator == '<' and not version.pre and not version.dev and not version.post:
|
if operator == '<' and not version.pre and not version.dev and not version.post:
|
||||||
version = '{}~~'.format(version)
|
version = '{}~~'.format(version)
|
||||||
|
Loading…
Reference in New Issue
Block a user