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
This commit is contained in:
Nick Bolton
2024-09-11 18:19:20 +01:00
committed by GitHub
parent c9eebe0d1a
commit 5914c7c8a5
4 changed files with 28 additions and 11 deletions

View File

@ -1,3 +1,9 @@
# 1.16.1
Enhancements:
- #7503 Make package filenames consistent with previous versions
# 1.16.0
Enhancements:

View File

@ -63,6 +63,7 @@
"synergyd",
"synergys",
"trackpad",
"Trixie",
"unittests",
"Valgrind",
"vcpkg",

View File

@ -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):

View File

@ -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):