]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/win64_installer/InstallType.nsh
Cleanup Win installer dialog messages a bit
[bacula/bacula] / bacula / src / win32 / win64_installer / InstallType.nsh
1 Function EnterInstallType
2   Push $R0
3   Push $R1
4   Push $R2
5
6   ; Check if this is an upgrade by looking for an uninstaller configured 
7   ; in the registry.
8   ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "UninstallString"
9
10   ${If} "$R0" != ""
11     ; Check registry for new installer
12     ReadRegStr $R1 HKLM "Software\Bacula" "InstallLocation"
13     ${If} "$R1" != ""
14       ; New Installer 
15       StrCpy $OldInstallDir $R1
16       StrCpy $InstallType ${UpgradeInstall}
17
18       SetShellVarContext all
19
20       StrCpy $R1 "$APPDATA\Bacula"
21       StrCpy $R2 "$INSTDIR\Doc"
22
23       ReadRegDWORD $PreviousComponents HKLM "Software\Bacula" "Components"
24
25       WriteINIStr "$PLUGINSDIR\InstallType.ini" "Field 1" "Text" "A previous installation has been found in $OldInstallDir.  Please choose the installation type for any additional components you select."
26       WriteINIStr "$PLUGINSDIR\InstallType.ini" "Field 5" "Text" "The configuration files for additional components will be generated using defaults applicable to most installations."
27       WriteINIStr "$PLUGINSDIR\InstallType.ini" "Field 6" "Text" "The configuration defaults for additional components will be displayed and you will be given the chance to make changes before the configuration files are written."
28
29       ReadRegDWORD $ConfigDirectorDB HKLM Software\Bacula Database
30
31       ${If} $ConfigDirectorDB = 0
32         IntOp $R0 $PreviousComponents & ${ComponentDirector}
33         ${If} $R0 <> 0
34           StrCpy $ConfigDirectorDB 1
35         ${EndIf}
36       ${EndIf}
37     ${Else}
38       ; Processing Upgrade - Get Install Directory
39       ${StrRep} $R0 $R0 '"' ''
40       ${GetParent} $R0 $OldInstallDir
41
42       ; Old Installer 
43       StrCpy $InstallType ${MigrateInstall}
44       StrCpy $R1 "$OldInstallDir\bin"
45       StrCpy $R2 "$OldInstallDir\Doc"
46
47       WriteINIStr "$PLUGINSDIR\InstallType.ini" "Field 1" "Text" "An old installation has been found in $OldInstallDir.  The Configuration will be migrated.  Please choose the installation type for any additional components you select."
48       WriteINIStr "$PLUGINSDIR\InstallType.ini" "Field 5" "Text" "The software will be installed in the default directory $\"C:\Program Files\Bacula$\".  The configuration files for additional components will be generated using defaults applicable to most installations."
49       WriteINIStr "$PLUGINSDIR\InstallType.ini" "Field 6" "Text" "You may choose the installation directory.  The configuration defaults will be displayed and you will be given the chance to make changes before the configuration files are written."
50     ${EndIf}
51   ${Else}
52     ; New Install
53     StrCpy $InstallType ${NewInstall}
54     WriteINIStr "$PLUGINSDIR\InstallType.ini" "Field 5" "Text" "The software will be installed in the default directory $\"C:\Program Files\Bacula$\".  The configuration files will be generated using defaults applicable to most installations."
55   ${EndIf}
56
57   ${If} $InstallType <> ${NewInstall}
58   ${AndIf} $PreviousComponents = 0
59     ${If} ${FileExists} "$R1\bacula-fd.conf"
60       IntOp $PreviousComponents $PreviousComponents | ${ComponentFile}
61     ${EndIf}
62     ${If} ${FileExists} "$R1\bconsole.conf"
63       IntOp $PreviousComponents $PreviousComponents | ${ComponentTextConsole}
64     ${EndIf}
65     ${If} ${FileExists} "$R1\wx-console.conf"
66       IntOp $PreviousComponents $PreviousComponents | ${ComponentGUIConsole}
67     ${EndIf}
68     ${If} ${FileExists} "$R2\bacula.pdf"
69       IntOp $PreviousComponents $PreviousComponents | ${ComponentPDFDocs}
70     ${EndIf}
71     ${If} ${FileExists} "$R2\bacula\bacula.html"
72       IntOp $PreviousComponents $PreviousComponents | ${ComponentHTMLDocs}
73     ${EndIf}
74     ${If} ${FileExists} "$R2\bacula.html"
75       IntOp $PreviousComponents $PreviousComponents | ${ComponentHTMLDocs}
76     ${EndIf}
77   ${EndIf}
78
79   !InsertMacro MUI_HEADER_TEXT "$(TITLE_InstallType)" "$(SUBTITLE_InstallType)"
80   !InsertMacro MUI_INSTALLOPTIONS_INITDIALOG "InstallType.ini"
81   Pop $HDLG ;HWND of dialog
82
83   !insertmacro MUI_INSTALLOPTIONS_SHOW
84
85   ; Process Results
86
87   !insertmacro MUI_INSTALLOPTIONS_READ $R0 "InstallType.ini" "Field 3" "State"
88
89   ${If} $R0 = 1
90     StrCpy $AutomaticInstall 1
91   ${Else}
92     StrCpy $AutomaticInstall 0
93   ${EndIf}
94
95   Pop $R2
96   Pop $R1
97   Pop $R0
98 FunctionEnd