From 5914c7c8a58cd03844572c0d3c9f097e9759dd3f Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 11 Sep 2024 18:19:20 +0100 Subject: [PATCH] Make package filenames consistent with previous versions (#7503) * Return Linux version codename if no version ID * Use underscores and put version at start * Use `-` instead of `.` for version * Use more consistent arch names in filenames * Update ChangeLog --- ChangeLog | 6 ++++++ cspell.json | 1 + scripts/lib/env.py | 9 ++++++--- scripts/package.py | 23 +++++++++++++++-------- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index d336a705d..cca22edfb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +# 1.16.1 + +Enhancements: + +- #7503 Make package filenames consistent with previous versions + # 1.16.0 Enhancements: diff --git a/cspell.json b/cspell.json index 38caa3183..3ad8b7efd 100644 --- a/cspell.json +++ b/cspell.json @@ -63,6 +63,7 @@ "synergyd", "synergys", "trackpad", + "Trixie", "unittests", "Valgrind", "vcpkg", diff --git a/scripts/lib/env.py b/scripts/lib/env.py index 4a208816b..6dba75040 100644 --- a/scripts/lib/env.py +++ b/scripts/lib/env.py @@ -58,7 +58,8 @@ def get_linux_distro(): os_file = "/etc/os-release" name = None name_like = None - version = None + version_id = None + version_codename = None if os.path.isfile(os_file): with open(os_file) as f: @@ -68,9 +69,11 @@ def get_linux_distro(): elif line.startswith("ID_LIKE="): name_like = line.strip().split("=")[1].strip('"') elif line.startswith("VERSION_ID="): - version = line.strip().split("=")[1].strip('"') + version_id = line.strip().split("=")[1].strip('"') + elif line.startswith("VERSION_CODENAME="): + version_codename = line.strip().split("=")[1].strip('"') - return name, name_like, version + return name, name_like, version_id or version_codename def get_env(name, required=True, default=None): diff --git a/scripts/package.py b/scripts/package.py index 67b1bb616..6a073a3f7 100755 --- a/scripts/package.py +++ b/scripts/package.py @@ -57,6 +57,7 @@ def get_filename_base(version, use_linux_distro=True): os = env.get_os() machine = platform.machine().lower() package_base = env.get_env("SYNERGY_PACKAGE_PREFIX", default=default_package_prefix) + os_part = os if os == "linux" and use_linux_distro: distro_name, _distro_like, distro_version = env.get_linux_distro() @@ -64,19 +65,25 @@ def get_filename_base(version, use_linux_distro=True): raise RuntimeError("Failed to detect Linux distro") if distro_version: - version_for_filename = distro_version.replace(".", "_") - distro = f"{distro_name}-{version_for_filename}" + version_for_filename = distro_version.replace(".", "-") + os_part = f"{distro_name}-{version_for_filename}" else: - distro = distro_name + os_part = distro_name - return f"{package_base}-{distro}-{machine}-{version}" + # For consistency with existing filenames, we'll use 'amd64' instead of 'x86_64'. + # Also, that's what Linux distros tend to call that architecture anyway. + if machine == "x86_64": + machine = "amd64" else: - # some windows users get confused by 'amd64' and think it's 'arm64', - # so we'll use intel's 'x64' branding (even though it's wrong). - if machine == "amd64": + # Some Windows users get confused by 'amd64' and think it's 'arm64', + # so we'll use Intel's 'x64' branding (even though it's wrong). + # Also replace 'x86_64' with 'x64' for consistency. + if machine == "amd64" or machine == "x86_64": machine = "x64" - return f"{package_base}-{os}-{machine}-{version}" + # Underscore is used to delimit different parts of the filename (e.g. version, OS, etc). + # Dashes are used to delimit spaces, e.g. "debian-trixie" for "Debian Trixie". + return f"{package_base}_{version}_{os_part}_{machine}" def windows_package(filename_base):