| |
@@ -138,6 +138,9 @@
|
| |
# in public releases
|
| |
# https://www.python.org/dev/peps/pep-0440/#local-version-identifiers
|
| |
|
| |
+ def is_legacy(self):
|
| |
+ return isinstance(self.version, str)
|
| |
+
|
| |
def increment(self):
|
| |
self.version[-1] += 1
|
| |
self.pre = None
|
| |
@@ -146,7 +149,7 @@
|
| |
return self
|
| |
|
| |
def __str__(self):
|
| |
- if isinstance(self.version, str):
|
| |
+ if self.is_legacy():
|
| |
return self.version
|
| |
if self.epoch:
|
| |
rpm_epoch = str(self.epoch) + ':'
|
| |
@@ -172,6 +175,11 @@
|
| |
print('Invalid requirement: {} {} {}'.format(name, operator, version_id), file=stderr)
|
| |
exit(65) # os.EX_DATAERR
|
| |
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:
|
| |
print("*** INVALID_REQUIREMENT_ERROR___SEE_STDERR ***")
|
| |
print('Invalid requirement: {} {} {}'.format(name, operator, version_id), file=stderr)
|
| |
@@ -204,6 +212,11 @@
|
| |
if version_id.endswith('.*'):
|
| |
version_id = version_id[:-2]
|
| |
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_operator = '>='
|
| |
# Prevent dev and pre-releases from satisfying a < requirement
|
| |
@@ -235,12 +248,14 @@
|
| |
operator = '<'
|
| |
else:
|
| |
version = RpmVersion(version_id)
|
| |
- # Prevent dev and pre-releases from satisfying a < requirement
|
| |
- if operator == '<' and not version.pre and not version.dev and not version.post:
|
| |
- version = '{}~~'.format(version)
|
| |
- # Prevent post-releases from satisfying a > requirement
|
| |
- if operator == '>' and not version.pre and not version.dev and not version.post:
|
| |
- version = '{}.0'.format(version)
|
| |
+ # For backwards compatibility, fallback to previous behavior with LegacyVersions
|
| |
+ if not version.is_legacy():
|
| |
+ # Prevent dev and pre-releases from satisfying a < requirement
|
| |
+ if operator == '<' and not version.pre and not version.dev and not version.post:
|
| |
+ version = '{}~~'.format(version)
|
| |
+ # Prevent post-releases from satisfying a > requirement
|
| |
+ if operator == '>' and not version.pre and not version.dev and not version.post:
|
| |
+ version = '{}.0'.format(version)
|
| |
return '{} {} {}'.format(name, operator, version)
|
| |
|
| |
|
| |