From 771a3fdbfe3056fe99fc684f2123f13c15c75b26 Mon Sep 17 00:00:00 2001 From: Yilan Date: Tue, 30 Mar 2021 08:34:25 -0700 Subject: [PATCH] [build]: Update versions_manager.py to make versions map key unique (#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. --- scripts/versions_manager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/versions_manager.py b/scripts/versions_manager.py index 336568bfb4e0..a59d85dd8a96 100755 --- a/scripts/versions_manager.py +++ b/scripts/versions_manager.py @@ -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 @@ -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 @@ -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)