WindowsInstaller: multiple improvements and fixes

move windowsinstaller to /package
update artwork
adapt to conda builds
make msvc redist directory optional
automate version information definition
use relative directories for file locations definitions
improve/update readme
partially update Delete.bat for qt6 libpack
add .gitignore
update signing.bat and add hashing command

WindowsInstaller: use --safe-mode in freecadcmd commands [skip ci]

WindowsInstaller: make windows 8 the minimum version [skip ci]

WindowsInstaller: allow configuring some values via command line

windows installer update for qt6 build
This commit is contained in:
Adrián Insaurralde Avalos
2024-03-31 11:49:57 -04:00
committed by Adrian Insaurralde Avalos
parent a847a794c4
commit d466ba037b
64 changed files with 163 additions and 174 deletions

View File

@@ -0,0 +1,112 @@
/*
configure.nsh
Write registry information and configure FreeCAD
*/
#!define SHORTCUT '${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_SHORTCUT_INFO}"'
#--------------------------------
# Registry information
Section -InstallData
# Registry information
WriteRegStr SHCTX ${APP_REGKEY} "" $INSTDIR
WriteRegStr SHCTX ${APP_REGKEY} "Version" "${APP_VERSION_NUMBER}"
# Start Menu shortcut
SetOutPath "$INSTDIR\bin" # this is the folder in which the shortcut is executed
# we must assure that the folder is not empty (happens on silent install and can accidentally happen)
${if} $StartmenuFolder == ""
StrCpy $StartmenuFolder "${APP_DIR}"
${endif}
CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
CreateShortCut "$SMPROGRAMS\$StartmenuFolder\${APP_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_SHORTCUT_INFO}"
# Link to website and Wiki
WriteINIStr "$SMPROGRAMS\$StartmenuFolder\${APP_WEBPAGE_INFO}.url" "InternetShortcut" "URL" "${APP_WEBPAGE}"
WriteINIStr "$SMPROGRAMS\$StartmenuFolder\${APP_WIKI_INFO}.url" "InternetShortcut" "URL" "${APP_WIKI}"
# create desktop icon
${if} $CreateDesktopIcon == "true"
SetOutPath "$INSTDIR\bin"
CreateShortCut "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_SHORTCUT_INFO}"
${endif}
# Uninstaller information
${If} $MultiUser.InstallMode == "CurrentUser"
WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayName" "${APP_NAME} ${APP_VERSION} $(TEXT_INSTALL_CURRENTUSER)"
${Else}
WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayName" "${APP_NAME} ${APP_VERSION}"
${EndIf}
WriteRegStr SHCTX ${APP_UNINST_KEY} "UninstallString" '"$INSTDIR\${SETUP_UNINSTALLER}"'
WriteRegStr SHCTX ${APP_UNINST_KEY} "QuietUninstallString" "$\"$INSTDIR\${SETUP_UNINSTALLER}$\" /S"
WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayVersion" "${APP_VERSION}"
WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayIcon" "$INSTDIR\${APP_RUN}"
WriteRegStr SHCTX ${APP_UNINST_KEY} "URLUpdateInfo" "${APP_WEBPAGE}"
WriteRegStr SHCTX ${APP_UNINST_KEY} "URLInfoAbout" "https://www.freecad.org/"
WriteRegStr SHCTX ${APP_UNINST_KEY} "Publisher" "${APP_NAME} Team"
WriteRegStr SHCTX ${APP_UNINST_KEY} "HelpLink" "https://forum.freecad.org/"
WriteRegDWORD SHCTX ${APP_UNINST_KEY} "NoModify" 0x00000001
WriteRegDWORD SHCTX ${APP_UNINST_KEY} "NoRepair" 0x00000001
WriteRegStr SHCTX ${APP_UNINST_KEY} "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
# if we install over an older existing version, remove the old uninstaller information
# NSIS cannot handle numbers with leading zero, thus cut it off before comparing
StrCpy $1 $OldVersionNumber "" 1
StrCpy $2 ${APP_SERIES_KEY} "" 1
${if} $1 < $2
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}$OldVersionNumber"
DeleteRegKey SHCTX "SOFTWARE\${APP_NAME}$OldVersionNumber"
# also delete in the case of an emergency release
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}$OldVersionNumber1"
DeleteRegKey SHCTX "SOFTWARE\${APP_NAME}$OldVersionNumber1"
${endif}
SectionEnd
#--------------------------------
# Write FreeCAD file associations
Section -Configure
# Associate .FCStd files with FreeCAD for current user or all users
${if} $CreateFileAssociations == "true"
WriteRegStr SHCTX "${APP_DIR_REGKEY}" "" "$INSTDIR\${APP_RUN}"
WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}" "" "${APP_NAME} Document"
WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}\DefaultIcon" "" "$INSTDIR\${APP_RUN},0"
WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}\Shell\open\command" "" '"$INSTDIR\${APP_RUN}" --single-instance "%1"'
# we need to update also the automatically created entry about the FreeCAD.exe
# otherwise .FCStd-files will could be opened with an older FreeCAD version
ReadRegStr $0 SHCTX "Software\Classes\Applications\${BIN_FREECAD}\shell\open\command" ""
${if} $0 != "" # if something was found
WriteRegStr SHCTX "Software\Classes\Applications\${BIN_FREECAD}\shell\open\command" "" '"$INSTDIR\${APP_RUN}" --single-instance "%1"'
${endif}
# .FCStd
WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "" "${APP_REGNAME_DOC}"
WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "Content Type" "${APP_MIME_TYPE}"
# if the user is admin, also install the DLL toe preview .FCStd files
${if} $MultiUser.Privileges == "Admin"
# see https://nsis.sourceforge.io/Docs/AppendixB.html#library_install for a description of InstallLib
!insertmacro InstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED ${FILES_THUMBS}\FCStdThumbnail.dll $SYSDIR\FCStdThumbnail.dll $SYSDIR
${endif}
# in any case remove the FCStdThumbnail.dll
RMDir /r "$INSTDIR\thumbnail"
# Eventually refresh shell icons
${RefreshShellIcons}
${endif}
SectionEnd
#--------------------------------
#
Function StartFreeCAD
Exec "$INSTDIR\${APP_RUN}"
FunctionEnd

View File

@@ -0,0 +1,65 @@
/*
install.nsh
Installation of program files, dictionaries and external components
*/
#--------------------------------
# Program files
!include LogicLib.nsh
Section -ProgramFiles SecProgramFiles
# if the $INSTDIR does not contain "FreeCAD" we must add a subfolder to avoid that FreeCAD will e.g.
# be installed directly to C:\programs - the uninstaller will then delete the whole
# C:\programs directory
StrCpy $String "$INSTDIR"
StrCpy $Search "${APP_NAME}"
Call StrPoint # function from Utils.nsh
${if} $Pointer == "-1"
StrCpy $INSTDIR "$INSTDIR\${APP_DIR}"
${endif}
# turn on logging
# Note that this can first be done here since the log file is written to $INSTDIR
# to $INSTDIR must have a valid path before logging can be turned on
LogSet on
# Install and register the core FreeCAD files
# Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
# $PLUGINSDIR is automatically deleted when the installer exits.
InitPluginsDir
# Binaries
SetOutPath "$INSTDIR\bin"
# recursively copy all files under bin
File /r "${FILES_FREECAD}\bin\*.*"
# MSVC redistributable DLLs
!ifdef FILES_DEPS
!echo "Including MSVC Redist files from ${FILES_DEPS}"
SetOutPath "$INSTDIR\bin"
File "${FILES_DEPS}\*.*"
!endif
# Others
SetOutPath "$INSTDIR\data"
File /r "${FILES_FREECAD}\data\*.*"
SetOutPath "$INSTDIR\doc"
File /r "${FILES_FREECAD}\doc\*.*"
SetOutPath "$INSTDIR\Ext"
File /r "${FILES_FREECAD}\Ext\*.*"
SetOutPath "$INSTDIR\lib"
File /r "${FILES_FREECAD}\lib\*.*"
SetOutPath "$INSTDIR\Mod"
File /r "${FILES_FREECAD}\Mod\*.*"
SetOutPath "$INSTDIR"
File /r "${FILES_THUMBS}"
# Create uninstaller
WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
SectionEnd

View File

@@ -0,0 +1,99 @@
/*
uninstall.nsh
Uninstall
*/
Var FileAssociation
# ----------------------------------
Section "un.FreeCAD" un.SecUnProgramFiles
SectionIn RO
# delete start menu folder
ReadRegStr $0 SHCTX "${APP_UNINST_KEY}" "StartMenu"
RMDir /r "$0"
# delete desktop icon
Delete "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
# remove file extension .FCStd
ReadRegStr $R0 SHCTX "Software\Classes\${APP_EXT}" ""
${if} $R0 == "${APP_REGNAME_DOC}"
DeleteRegKey SHCTX "Software\Classes\${APP_EXT}"
${endif}
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\${APP_EXT}"
# remove further FC-specific file extension
DeleteRegKey SHCTX "Software\Classes\${APP_EXT1}" # .FCStd1
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\${APP_EXT1}"
DeleteRegKey SHCTX "Software\Classes\${APP_EXT_BAK}" # .FCBak
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\${APP_EXT_BAK}"
DeleteRegKey SHCTX "Software\Classes\${APP_EXT_MACRO}" # .FCMacro
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\${APP_EXT_MACRO}"
DeleteRegKey SHCTX "Software\Classes\${APP_EXT_MAT}" # .FCMat
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\${APP_EXT_MAT}"
DeleteRegKey SHCTX "Software\Classes\${APP_EXT_SCRIPT}" # .FCScript
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\${APP_EXT_SCRIPT}"
${if} $MultiUser.Privileges == "Admin"
DeleteRegKey HKCR "${APP_REGNAME_DOC}"
# see https://nsis.sourceforge.io/Docs/AppendixB.html#library_install for a description of UnInstallLib
!insertmacro UnInstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED $SYSDIR\FCStdThumbnail.dll
${endif}
# Uninstaller itself
Delete "$INSTDIR\${SETUP_UNINSTALLER}"
# Application folder
SetOutPath "$TEMP"
RMDir /r "$INSTDIR"
# Registry keys and values
DeleteRegKey SHCTX "${APP_REGKEY_SETUP}"
DeleteRegKey SHCTX "${APP_REGKEY}"
DeleteRegKey SHCTX "${APP_UNINST_KEY}"
DeleteRegKey HKCR "Applications\${BIN_FREECAD}"
DeleteRegValue HKCR "${APP_NAME}.Document\Shell\open\command" ""
DeleteRegValue HKCR "${APP_NAME}.Document\DefaultIcon" ""
# File associations
ReadRegStr $FileAssociation SHELL_CONTEXT "Software\Classes\${APP_EXT}" ""
${If} $FileAssociation == "${APP_REGNAME_DOC}"
DeleteRegKey SHELL_CONTEXT "Software\Classes\${APP_EXT}"
${EndIf}
# clean other registry entry
DeleteRegKey SHCTX "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\${APP_NAME}.exe"
# Eventually refresh shell icons
${RefreshShellIcons}
SectionEnd
#---------------------------------
# user preferences
Section /o "un.$(UnFreeCADPreferencesTitle)" un.SecUnPreferences
# issue a warning dialog
MessageBox MB_YESNO|MB_DEFBUTTON2|MB_ICONEXCLAMATION $(DialogUnPreferences) /SD IDYES IDYES +2 # continue if yes
Goto NotPreferences
# remove FreeCAD's config files
StrCpy $AppSubfolder ${APP_DIR_USERDATA}
Call un.DelAppPathSub # function from Utils.nsh
# remove the registry key that stores the main window parameters
DeleteRegKey HKCU "SOFTWARE\${APP_NAME}"
NotPreferences:
SectionEnd
#---------------------------------
# Section descriptions
!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnPreferences} "$(SecUnPreferencesDescription)"
!insertmacro MUI_DESCRIPTION_TEXT ${un.SecUnProgramFiles} "$(SecUnProgramFilesDescription)"
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END