]> git.lyx.org Git - features.git/blobdiff - development/Win32/packaging/installer2/src/main.nsh
Consider inset strings in simple find/replaceAll (#12049)
[features.git] / development / Win32 / packaging / installer2 / src / main.nsh
index 9bcd87a3f7ef3bdd6fa43df4a6c6183723522060..76263cbd28bc3c07563035ce23a6d21c984cb292 100644 (file)
@@ -371,6 +371,12 @@ FunctionEnd
 Function RetrieveSMState # Custom function, called after the Startmenu page has been created
   ${IfNot} ${FileExists} "$INSTDIR\Uninstall-LyX.exe"
     Return # Not over-installing
+  ${Else}
+    ${GetFileVersion} "$INSTDIR\Uninstall-LyX.exe" $0
+    StrCpy $0 $0 3 # get only the first 3 chars, e.g. "2.3"
+    ${If} $0 != "${VERSION_MAJOR}.${VERSION_MINOR}"
+      Return # Installing over a wrong version
+    ${EndIf}
   ${EndIf}
 
   Call PrepareShellCTX # Helper function from above
@@ -380,7 +386,10 @@ Function RetrieveSMState # Custom function, called after the Startmenu page has
       StrCpy $StartMenuFolder ">$StartMenuFolder"
     ${Else}
       GetDlgItem $0 $mui.StartMenuPage 1005 # Get the HWND of the checkbox, MUI2 does not provide variable for that
-      SendMessage $0 ${BM_CLICK} 0 0 # NSIS delivers no other possibility here other than to send a click event to the checkbox
+      ${NSD_GetState} $0 $1
+      ${If} $1 = ${BST_UNCHECKED}
+        SendMessage $0 ${BM_CLICK} 0 0 # NSIS delivers no other possibility here other than to send a click event to the checkbox
+      ${EndIf}
     ${EndIf}
   ${EndIf}
 FunctionEnd
@@ -522,6 +531,17 @@ Section -CheckSilent # This section checks if it's a silent install and calls ne
   Call DefaultDesktopFileAssoc
 SectionEnd
 
+Section -UninstallOld
+  ${If} ${FileExists} "$INSTDIR\Uninstall-LyX.exe"
+    ${GetFileVersion} "$INSTDIR\Uninstall-LyX.exe" $0
+    StrCpy $0 $0 3 # get only the first 3 chars, e.g. "2.3"
+    ${If} $0 != "${VERSION_MAJOR}.${VERSION_MINOR}"
+      ExecWait "$INSTDIR\Uninstall-LyX.exe /S _?=$INSTDIR" # silently uninstall old LyX
+      Delete "$INSTDIR\Uninstall-LyX.exe"
+    ${EndIf}
+  ${EndIf}
+SectionEnd
+
 Section -OverInstallReg # If over-installing, we need to delete the registry keys written by the previous installment
   Call PrepareShellCTX # Helper function from above
   StrCpy $1 0
@@ -552,6 +572,7 @@ Section -ProgramFiles
   # Visual C++ redistributable (if native build)
   File "${FILES_DEPS}\bin\concrt140.dll"
   File "${FILES_DEPS}\bin\msvcp140.dll"
+  File "${FILES_DEPS}\bin\msvcp140_1.dll"
   File "${FILES_DEPS}\bin\vcamp140.dll"
   File "${FILES_DEPS}\bin\vccorlib140.dll"
   File "${FILES_DEPS}\bin\vcomp140.dll"
@@ -655,7 +676,7 @@ Section -TexRessources # Section installs cls files from Ressources\tex and upda
     ${If} ${FileExists} "$0\broadway.cls"
       Return
     ${EndIf}
-    CopyFiles "$INSTDIR\Resources\tex\*.*" $0
+    CopyFiles /SILENT "$INSTDIR\Resources\tex\*.*" $0
     ExecWait '$LatexPath\texhash' # Update package file list
 
   ${Else} # Miktex
@@ -956,6 +977,19 @@ Section -UninstallInfoRegistry # Registry information in "SOFTWARE\Microsoft\Win
   WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\LyX${APP_VERSION_DOTLESS}" "EstimatedSize" $0
 SectionEnd
 
+!if ${VERSION_MINOR} > 0 # Only valid for minor releases of the same major release (e.g. not valid for 3.0)
+  Section -CopyOldPreferences # Searches user's preferences (userdir) from previous minor release and copies it if necessary
+    Call PrepareShellCTX
+    SetShellVarContext current # Otherwise $APPDATA would return C:\ProgrammData instead of C:\Users\username\AppData\Roaming
+    
+    IntOp $0 ${VERSION_MINOR} - 1 # only check the direct previous minor release
+    ${If} ${FileExists} "$APPDATA\LyX${VERSION_MAJOR}.$0\lyxrc.defaults"
+    ${AndIfNot} ${FileExists} "$APPDATA\LyX${VERSION_MAJOR}.${VERSION_MINOR}\lyxrc.defaults"
+      CopyFiles /SILENT "$APPDATA\LyX${VERSION_MAJOR}.$0\*.*" "$APPDATA\LyX${VERSION_MAJOR}.${VERSION_MINOR}"
+    ${EndIf}
+  SectionEnd
+!endif
+
 Section -ConfigureScript # Runs the configure.py script
 
   # Manipulate PATH environment of the running installer process, so that configure.py can find all the stuff needed
@@ -987,6 +1021,12 @@ Function DefaultDesktopFileAssoc # Custom function, called before the components
 
   ${IfNot} ${FileExists} "$INSTDIR\Uninstall-LyX.exe"
     Return # Not over-installing
+  ${Else}
+    ${GetFileVersion} "$INSTDIR\Uninstall-LyX.exe" $0
+    StrCpy $0 $0 3 # get only the first 3 chars, e.g. "2.3"
+    ${If} $0 != "${VERSION_MAJOR}.${VERSION_MINOR}"
+      Return # Installing over a wrong version
+    ${EndIf}
   ${EndIf}
 
   Call PrepareShellCTX