From d91b93b3d7916f1472f3a33a65d0d85781c65f80 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 5 Jul 2022 11:51:35 +0200 Subject: [PATCH] Deal with missing build version number Makes it a bit more messy and weird, but that's what you get when your script has 16 parameters, I guess. Contributes to issue CURA-9365. --- packaging/NSIS/Ultimaker-Cura.nsi.jinja | 2 +- packaging/NSIS/nsis-configurator.py | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/packaging/NSIS/Ultimaker-Cura.nsi.jinja b/packaging/NSIS/Ultimaker-Cura.nsi.jinja index fc7db794d9..56403b70c3 100644 --- a/packaging/NSIS/Ultimaker-Cura.nsi.jinja +++ b/packaging/NSIS/Ultimaker-Cura.nsi.jinja @@ -4,7 +4,7 @@ !define APP_NAME "{{ app_name }} {{ version_major }}.{{ version_minor }}.{{ version_patch }}" !define COMP_NAME "{{ company }}" !define WEB_SITE "{{ web_site }}" -!define VERSION "{{ version_major }}.{{ version_minor }}.{{ version_patch }}.{{ version_build }}" +!define VERSION "{{ version_major }}.{{ version_minor }}.{{ version_patch }}{{ version_build }}" !define COPYRIGHT "Copyright (c) {{ year }} {{ company }}" !define DESCRIPTION "Application" !define LICENSE_TXT "{{ cura_license_file }}" diff --git a/packaging/NSIS/nsis-configurator.py b/packaging/NSIS/nsis-configurator.py index c8986fb118..445be02321 100644 --- a/packaging/NSIS/nsis-configurator.py +++ b/packaging/NSIS/nsis-configurator.py @@ -15,7 +15,7 @@ if __name__ == "__main__": - version_major: Major version number of Semver (e.g. 5). - version_minor: Minor version number of Semver (e.g. 0). - version_patch: Patch version number of Semver (e.g. 0). - - version_build: A version number that gets manually incremented at each build. + - version_build: (optional) A version number that gets manually incremented at each build. - company: Publisher of the application. Should be "Ultimaker B.V." - web_site: Website to find more information. Should be "https://ultimaker.com". - cura_license_file: Path to a license file in Cura. Should point to packaging/cura_license.txt in this repository. @@ -50,23 +50,30 @@ if __name__ == "__main__": with open(jinja_template_path, "r") as f: template = Template(f.read()) + if len(sys.argv) == 15: # No version-build + version_build = "" + use_version_build = 0 + else: + version_build = "." + sys.argv[8] + use_version_build = 1 + nsis_content = template.render( app_name = sys.argv[3], main_app = sys.argv[4], version_major = sys.argv[5], version_minor = sys.argv[6], version_patch = sys.argv[7], - version_build = sys.argv[8], - company = sys.argv[9], - web_site = sys.argv[10], + version_build = version_build, + company = sys.argv[8 + use_version_build], + web_site = sys.argv[9 + use_version_build], year = datetime.now().year, - cura_license_file = Path(sys.argv[11]), - compression_method = sys.argv[12], # ZLIB, BZIP2 or LZMA - cura_banner_img = Path(sys.argv[13]), - cura_icon = Path(sys.argv[14]), + cura_license_file = Path(sys.argv[10 + use_version_build]), + compression_method = sys.argv[11 + use_version_build], # ZLIB, BZIP2 or LZMA + cura_banner_img = Path(sys.argv[12 + use_version_build]), + cura_icon = Path(sys.argv[13 + use_version_build]), mapped_out_paths = mapped_out_paths, rmdir_paths = rmdir_paths, - destination = Path(sys.argv[15]) + destination = Path(sys.argv[14 + use_version_build]) ) with open(dist_loc.parent.joinpath(jinja_template_path.stem), "w") as f: