mirror of https://git.48k.eu/ogclient
install: add script to generate the windows metadata information file
Add create_version_file.py, running this script creates a file version_info.txt with the data required for the Windows ogClient binary metadata.master
parent
62b52ff364
commit
ffaf2aac05
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
#
|
||||
# Copyright (C) 2020-2024 Soleta Networks <info@soleta.eu>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the
|
||||
# Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
|
||||
version_template = """
|
||||
VSVersionInfo(
|
||||
ffi=FixedFileInfo(
|
||||
filevers=({major}, {minor}, {patch}, 0),
|
||||
prodvers=({major}, {minor}, {patch}, 0),
|
||||
mask=0x3f,
|
||||
flags=0x0,
|
||||
OS=0x40004,
|
||||
fileType=0x1,
|
||||
subtype=0x0,
|
||||
date=(0, 0)
|
||||
),
|
||||
kids=[
|
||||
StringFileInfo(
|
||||
[
|
||||
StringTable(
|
||||
'040904B0',
|
||||
[
|
||||
StringStruct('CompanyName', 'Soleta Networks'),
|
||||
StringStruct('FileDescription', 'ogClient - OpenGnsys Client Application'),
|
||||
StringStruct('FileVersion', '{version}'),
|
||||
StringStruct('InternalName', 'ogclient'),
|
||||
StringStruct('LegalCopyright', 'Copyright © {year} Soleta Networks'),
|
||||
StringStruct('OriginalFilename', 'ogclient.exe'),
|
||||
StringStruct('ProductName', 'ogClient'),
|
||||
StringStruct('ProductVersion', '{version}')
|
||||
]
|
||||
)
|
||||
]
|
||||
),
|
||||
VarFileInfo([VarStruct('Translation', [1033, 1200])])
|
||||
]
|
||||
)
|
||||
"""
|
||||
|
||||
def get_git_version():
|
||||
try:
|
||||
version = subprocess.check_output(
|
||||
["git", "describe", "--tags", "--always"],
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True
|
||||
).strip()
|
||||
return version
|
||||
except subprocess.CalledProcessError:
|
||||
return "0.0.0"
|
||||
|
||||
def version_to_tuple(version):
|
||||
parts = version.lstrip("v").split("-")[0].split(".")
|
||||
version_tuple = []
|
||||
|
||||
for part in parts:
|
||||
if part.isdigit():
|
||||
version_tuple.append(int(part))
|
||||
else:
|
||||
version_tuple.append(0)
|
||||
return tuple(version_tuple)
|
||||
|
||||
if __name__ == "__main__":
|
||||
version = get_git_version()
|
||||
major, minor, patch = version_to_tuple(version)
|
||||
current_year = datetime.now().year
|
||||
version_file = version_template.format(major=major, minor=minor, patch=patch, version=version, year=current_year)
|
||||
with open('version_info.txt', 'w', encoding='utf-8') as f:
|
||||
f.write(version_file)
|
Loading…
Reference in New Issue