mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-18 02:36:02 +08:00
Update NSIS scripts using UltiMaker
Contributes to CURA-9808
This commit is contained in:
parent
61623720ca
commit
3be5581243
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2022 Ultimaker B.V.
|
# Copyright (c) 2022 UltiMaker B.V.
|
||||||
# Cura's build system is released under the terms of the AGPLv3 or higher.
|
# Cura's build system is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
!define APP_NAME "{{ app_name }}"
|
!define APP_NAME "{{ app_name }}"
|
||||||
@ -64,7 +64,7 @@ InstallDir "$PROGRAMFILES64\${APP_NAME}"
|
|||||||
|
|
||||||
!ifdef REG_START_MENU
|
!ifdef REG_START_MENU
|
||||||
!define MUI_STARTMENUPAGE_NODISABLE
|
!define MUI_STARTMENUPAGE_NODISABLE
|
||||||
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Ultimaker Cura"
|
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "UltiMaker Cura"
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${REG_ROOT}"
|
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${REG_ROOT}"
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${UNINSTALL_PATH}"
|
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${UNINSTALL_PATH}"
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${REG_START_MENU}"
|
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${REG_START_MENU}"
|
||||||
@ -113,8 +113,8 @@ CreateShortCut "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP_EXE
|
|||||||
CreateShortCut "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
|
CreateShortCut "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
|
||||||
|
|
||||||
!ifdef WEB_SITE
|
!ifdef WEB_SITE
|
||||||
WriteIniStr "$INSTDIR\Ultimaker Cura website.url" "InternetShortcut" "URL" "${WEB_SITE}"
|
WriteIniStr "$INSTDIR\UltiMaker Cura website.url" "InternetShortcut" "URL" "${WEB_SITE}"
|
||||||
CreateShortCut "$SMPROGRAMS\$SM_Folder\Ultimaker Cura website.lnk" "$INSTDIR\Ultimaker Cura website.url"
|
CreateShortCut "$SMPROGRAMS\$SM_Folder\UltiMaker Cura website.lnk" "$INSTDIR\UltiMaker Cura website.url"
|
||||||
!endif
|
!endif
|
||||||
!insertmacro MUI_STARTMENU_WRITE_END
|
!insertmacro MUI_STARTMENU_WRITE_END
|
||||||
!endif
|
!endif
|
||||||
@ -125,8 +125,8 @@ CreateShortCut "$SMPROGRAMS\{{ app_name }}\${APP_NAME}.lnk" "$INSTDIR\${MAIN_APP
|
|||||||
CreateShortCut "$SMPROGRAMS\{{ app_name }}\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
|
CreateShortCut "$SMPROGRAMS\{{ app_name }}\Uninstall ${APP_NAME}.lnk" "$INSTDIR\uninstall.exe"
|
||||||
|
|
||||||
!ifdef WEB_SITE
|
!ifdef WEB_SITE
|
||||||
WriteIniStr "$INSTDIR\Ultimaker Cura website.url" "InternetShortcut" "URL" "${WEB_SITE}"
|
WriteIniStr "$INSTDIR\UltiMaker Cura website.url" "InternetShortcut" "URL" "${WEB_SITE}"
|
||||||
CreateShortCut "$SMPROGRAMS\{{ app_name }}\Ultimaker Cura website.lnk" "$INSTDIR\Ultimaker Cura website.url"
|
CreateShortCut "$SMPROGRAMS\{{ app_name }}\UltiMaker Cura website.lnk" "$INSTDIR\UltiMaker Cura website.url"
|
||||||
!endif
|
!endif
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ RmDir /r /REBOOTOK "$INSTDIR"
|
|||||||
Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk"
|
Delete "$SMPROGRAMS\$SM_Folder\${APP_NAME}.lnk"
|
||||||
Delete "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk"
|
Delete "$SMPROGRAMS\$SM_Folder\Uninstall ${APP_NAME}.lnk"
|
||||||
!ifdef WEB_SITE
|
!ifdef WEB_SITE
|
||||||
Delete "$SMPROGRAMS\$SM_Folder\Ultimaker Cura website.lnk"
|
Delete "$SMPROGRAMS\$SM_Folder\UltiMaker Cura website.lnk"
|
||||||
!endif
|
!endif
|
||||||
RmDir "$SMPROGRAMS\$SM_Folder"
|
RmDir "$SMPROGRAMS\$SM_Folder"
|
||||||
!endif
|
!endif
|
||||||
@ -179,7 +179,7 @@ RmDir "$SMPROGRAMS\$SM_Folder"
|
|||||||
Delete "$SMPROGRAMS\{{ app_name }}\${APP_NAME}.lnk"
|
Delete "$SMPROGRAMS\{{ app_name }}\${APP_NAME}.lnk"
|
||||||
Delete "$SMPROGRAMS\{{ app_name }}\Uninstall ${APP_NAME}.lnk"
|
Delete "$SMPROGRAMS\{{ app_name }}\Uninstall ${APP_NAME}.lnk"
|
||||||
!ifdef WEB_SITE
|
!ifdef WEB_SITE
|
||||||
Delete "$SMPROGRAMS\{{ app_name }}\Ultimaker Cura website.lnk"
|
Delete "$SMPROGRAMS\{{ app_name }}\UltiMaker Cura website.lnk"
|
||||||
!endif
|
!endif
|
||||||
RmDir "$SMPROGRAMS\{{ app_name }}"
|
RmDir "$SMPROGRAMS\{{ app_name }}"
|
||||||
!endif
|
!endif
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# Copyright (c) 2022 Ultimaker B.V.
|
# Copyright (c) 2022 UltiMaker
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import argparse # Command line arguments parsing and help.
|
import argparse # Command line arguments parsing and help.
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -16,15 +18,15 @@ def generate_nsi(source_path: str, dist_path: str, filename: str):
|
|||||||
dist_loc = Path(os.getcwd(), dist_path)
|
dist_loc = Path(os.getcwd(), dist_path)
|
||||||
source_loc = Path(os.getcwd(), source_path)
|
source_loc = Path(os.getcwd(), source_path)
|
||||||
instdir = Path("$INSTDIR")
|
instdir = Path("$INSTDIR")
|
||||||
dist_paths = [p.relative_to(dist_loc.joinpath("Ultimaker-Cura")) for p in sorted(dist_loc.joinpath("Ultimaker-Cura").rglob("*")) if p.is_file()]
|
dist_paths = [p.relative_to(dist_loc.joinpath("UltiMaker-Cura")) for p in sorted(dist_loc.joinpath("UltiMaker-Cura").rglob("*")) if p.is_file()]
|
||||||
mapped_out_paths = {}
|
mapped_out_paths = {}
|
||||||
for dist_path in dist_paths:
|
for dist_path in dist_paths:
|
||||||
if "__pycache__" not in dist_path.parts:
|
if "__pycache__" not in dist_path.parts:
|
||||||
out_path = instdir.joinpath(dist_path).parent
|
out_path = instdir.joinpath(dist_path).parent
|
||||||
if out_path not in mapped_out_paths:
|
if out_path not in mapped_out_paths:
|
||||||
mapped_out_paths[out_path] = [(dist_loc.joinpath("Ultimaker-Cura", dist_path), instdir.joinpath(dist_path))]
|
mapped_out_paths[out_path] = [(dist_loc.joinpath("UltiMaker-Cura", dist_path), instdir.joinpath(dist_path))]
|
||||||
else:
|
else:
|
||||||
mapped_out_paths[out_path].append((dist_loc.joinpath("Ultimaker-Cura", dist_path), instdir.joinpath(dist_path)))
|
mapped_out_paths[out_path].append((dist_loc.joinpath("UltiMaker-Cura", dist_path), instdir.joinpath(dist_path)))
|
||||||
|
|
||||||
rmdir_paths = set()
|
rmdir_paths = set()
|
||||||
for rmdir_f in mapped_out_paths.values():
|
for rmdir_f in mapped_out_paths.values():
|
||||||
@ -40,13 +42,13 @@ def generate_nsi(source_path: str, dist_path: str, filename: str):
|
|||||||
|
|
||||||
|
|
||||||
nsis_content = template.render(
|
nsis_content = template.render(
|
||||||
app_name = f"Ultimaker Cura {os.getenv('CURA_VERSION_FULL')}",
|
app_name = f"UltiMaker Cura {os.getenv('CURA_VERSION_FULL')}",
|
||||||
main_app = "Ultimaker-Cura.exe",
|
main_app = "UltiMaker-Cura.exe",
|
||||||
version = os.getenv('CURA_VERSION_FULL'),
|
version = os.getenv('CURA_VERSION_FULL'),
|
||||||
version_major = os.environ.get("CURA_VERSION_MAJOR"),
|
version_major = os.environ.get("CURA_VERSION_MAJOR"),
|
||||||
version_minor = os.environ.get("CURA_VERSION_MINOR"),
|
version_minor = os.environ.get("CURA_VERSION_MINOR"),
|
||||||
version_patch = os.environ.get("CURA_VERSION_PATCH"),
|
version_patch = os.environ.get("CURA_VERSION_PATCH"),
|
||||||
company = "Ultimaker B.V.",
|
company = "UltiMaker",
|
||||||
web_site = "https://ultimaker.com",
|
web_site = "https://ultimaker.com",
|
||||||
year = datetime.now().year,
|
year = datetime.now().year,
|
||||||
cura_license_file = str(source_loc.joinpath("packaging", "cura_license.txt")),
|
cura_license_file = str(source_loc.joinpath("packaging", "cura_license.txt")),
|
||||||
@ -58,7 +60,7 @@ def generate_nsi(source_path: str, dist_path: str, filename: str):
|
|||||||
destination = filename
|
destination = filename
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(dist_loc.joinpath("Ultimaker-Cura.nsi"), "w") as f:
|
with open(dist_loc.joinpath("UltiMaker-Cura.nsi"), "w") as f:
|
||||||
f.write(nsis_content)
|
f.write(nsis_content)
|
||||||
|
|
||||||
shutil.copy(source_loc.joinpath("packaging", "NSIS", "fileassoc.nsh"), dist_loc.joinpath("fileassoc.nsh"))
|
shutil.copy(source_loc.joinpath("packaging", "NSIS", "fileassoc.nsh"), dist_loc.joinpath("fileassoc.nsh"))
|
||||||
@ -66,7 +68,7 @@ def generate_nsi(source_path: str, dist_path: str, filename: str):
|
|||||||
|
|
||||||
def build(dist_path: str):
|
def build(dist_path: str):
|
||||||
dist_loc = Path(os.getcwd(), dist_path)
|
dist_loc = Path(os.getcwd(), dist_path)
|
||||||
command = ["makensis", "/V2", "/P4", str(dist_loc.joinpath("Ultimaker-Cura.nsi"))]
|
command = ["makensis", "/V2", "/P4", str(dist_loc.joinpath("UltiMaker-Cura.nsi"))]
|
||||||
subprocess.run(command)
|
subprocess.run(command)
|
||||||
|
|
||||||
|
|
||||||
@ -74,7 +76,7 @@ if __name__ == "__main__":
|
|||||||
parser = argparse.ArgumentParser(description = "Create Windows exe installer of Cura.")
|
parser = argparse.ArgumentParser(description = "Create Windows exe installer of Cura.")
|
||||||
parser.add_argument("source_path", type=str, help="Path to Conan install Cura folder.")
|
parser.add_argument("source_path", type=str, help="Path to Conan install Cura folder.")
|
||||||
parser.add_argument("dist_path", type=str, help="Path to Pyinstaller dist folder")
|
parser.add_argument("dist_path", type=str, help="Path to Pyinstaller dist folder")
|
||||||
parser.add_argument("filename", type = str, help = "Filename of the exe (e.g. 'Ultimaker-Cura-5.1.0-beta-Windows-X64.exe')")
|
parser.add_argument("filename", type = str, help = "Filename of the exe (e.g. 'UltiMaker-Cura-5.1.0-beta-Windows-X64.exe')")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
generate_nsi(args.source_path, args.dist_path, args.filename)
|
generate_nsi(args.source_path, args.dist_path, args.filename)
|
||||||
build(args.dist_path)
|
build(args.dist_path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user