Skip to content

Commit

Permalink
[build]: Update versions_manager.py to make versions map key unique (s…
Browse files Browse the repository at this point in the history
…onic-net#7146)

py2/py3/deb packages names are case insensitive, and the versions map
key should be the same for packages whose name can have different cases.

For example, in files/build/versions/default/versions-py3, package
"click==7.1.2" is pinned; and in
files/build/versions/dockers/docker-sonic-vs/versions-py3, package
"Click==7.0" is pinned.
Without this fix, the aggregated versions-py3 file used for building
docker-sonic-vs looks like below:
...
click==7.1.2
Click==7.0
...
However, we actually want "click==7.0" to overwrite "click==7.1.2" for
docker-sonic-vs build.
  • Loading branch information
baxia-lan authored and Carl Keene committed Aug 7, 2021
1 parent f5aeb8f commit 53d56ee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/versions_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Component:
ctype -- Component Type, such as deb, py2, etc
dist -- Distribution, such as stretch, buster, etc
arch -- Architectrue, such as amd64, arm64, etc
'''
def __init__(self, versions, ctype, dist=ALL_DIST, arch=ALL_ARCH):
self.versions = versions
Expand All @@ -44,6 +44,8 @@ def get_versions(cls, version_file):
offset = line.rfind('==')
if offset > 0:
package = line[:offset].strip()
if 'py2' in version_file.lower() or 'py3' in version_file.lower():
package = package.lower()
version = line[offset+2:].strip()
result[package] = version
return result
Expand Down Expand Up @@ -86,7 +88,7 @@ def dump_to_path(self, file_path, config=False, priority=999):
if config and self.ctype == 'deb':
none_config_file_path = os.path.join(file_path, filename)
self.dump_to_file(none_config_file_path, False, priority)
filename = VERSION_DEB_PREFERENCE
filename = VERSION_DEB_PREFERENCE
file_path = os.path.join(file_path, filename)
self.dump_to_file(file_path, config, priority)

Expand Down

0 comments on commit 53d56ee

Please sign in to comment.