|
1 # This Source Code Form is subject to the terms of the Mozilla Public |
|
2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
4 |
|
5 ; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs |
|
6 !verbose 3 |
|
7 |
|
8 ; 7-Zip provides better compression than the lzma from NSIS so we add the files |
|
9 ; uncompressed and use 7-Zip to create a SFX archive of it |
|
10 SetDatablockOptimize on |
|
11 SetCompress off |
|
12 CRCCheck on |
|
13 |
|
14 RequestExecutionLevel admin |
|
15 |
|
16 ; The commands inside this ifdef require NSIS 3.0a2 or greater so the ifdef can |
|
17 ; be removed after we require NSIS 3.0a2 or greater. |
|
18 !ifdef NSIS_PACKEDVERSION |
|
19 Unicode true |
|
20 ManifestSupportedOS all |
|
21 ManifestDPIAware true |
|
22 !endif |
|
23 |
|
24 !addplugindir ./ |
|
25 |
|
26 ; Variables |
|
27 Var TempMaintServiceName |
|
28 Var BrandFullNameDA |
|
29 Var BrandFullName |
|
30 |
|
31 ; Other included files may depend upon these includes! |
|
32 ; The following includes are provided by NSIS. |
|
33 !include FileFunc.nsh |
|
34 !include LogicLib.nsh |
|
35 !include MUI.nsh |
|
36 !include WinMessages.nsh |
|
37 !include WinVer.nsh |
|
38 !include WordFunc.nsh |
|
39 |
|
40 !insertmacro GetOptions |
|
41 !insertmacro GetParameters |
|
42 !insertmacro GetSize |
|
43 |
|
44 ; The test slaves use this fallback key to run tests. |
|
45 ; And anyone that wants to run tests themselves should already have |
|
46 ; this installed. |
|
47 !define FallbackKey \ |
|
48 "SOFTWARE\Mozilla\MaintenanceService\3932ecacee736d366d6436db0f55bce4" |
|
49 |
|
50 !define CompanyName "Mozilla Corporation" |
|
51 !define BrandFullNameInternal "" |
|
52 |
|
53 ; The following includes are custom. |
|
54 !include defines.nsi |
|
55 ; We keep defines.nsi defined so that we get other things like |
|
56 ; the version number, but we redefine BrandFullName |
|
57 !define MaintFullName "Mozilla Maintenance Service" |
|
58 !undef BrandFullName |
|
59 !define BrandFullName "${MaintFullName}" |
|
60 |
|
61 !include common.nsh |
|
62 !include locales.nsi |
|
63 |
|
64 VIAddVersionKey "FileDescription" "${MaintFullName} Installer" |
|
65 VIAddVersionKey "OriginalFilename" "maintenanceservice_installer.exe" |
|
66 |
|
67 Name "${MaintFullName}" |
|
68 OutFile "maintenanceservice_installer.exe" |
|
69 |
|
70 ; Get installation folder from registry if available |
|
71 InstallDirRegKey HKLM "Software\Mozilla\MaintenanceService" "" |
|
72 |
|
73 SetOverwrite on |
|
74 |
|
75 !define MaintUninstallKey \ |
|
76 "Software\Microsoft\Windows\CurrentVersion\Uninstall\MozillaMaintenanceService" |
|
77 |
|
78 ; The HAVE_64BIT_OS define also means that we have an x64 build, |
|
79 ; not just an x64 OS. |
|
80 !ifdef HAVE_64BIT_OS |
|
81 ; See below, we actually abort the install for x64 builds currently. |
|
82 InstallDir "$PROGRAMFILES64\${MaintFullName}\" |
|
83 !else |
|
84 InstallDir "$PROGRAMFILES32\${MaintFullName}\" |
|
85 !endif |
|
86 ShowUnInstDetails nevershow |
|
87 |
|
88 ################################################################################ |
|
89 # Modern User Interface - MUI |
|
90 |
|
91 !define MUI_ICON setup.ico |
|
92 !define MUI_UNICON setup.ico |
|
93 !define MUI_WELCOMEPAGE_TITLE_3LINES |
|
94 !define MUI_UNWELCOMEFINISHPAGE_BITMAP wizWatermark.bmp |
|
95 |
|
96 ;Interface Settings |
|
97 !define MUI_ABORTWARNING |
|
98 |
|
99 ; Uninstaller Pages |
|
100 !insertmacro MUI_UNPAGE_CONFIRM |
|
101 !insertmacro MUI_UNPAGE_INSTFILES |
|
102 |
|
103 ################################################################################ |
|
104 # Language |
|
105 |
|
106 !insertmacro MOZ_MUI_LANGUAGE 'baseLocale' |
|
107 !verbose push |
|
108 !verbose 3 |
|
109 !include "overrideLocale.nsh" |
|
110 !include "customLocale.nsh" |
|
111 !verbose pop |
|
112 |
|
113 ; Set this after the locale files to override it if it is in the locale |
|
114 ; using " " for BrandingText will hide the "Nullsoft Install System..." branding |
|
115 BrandingText " " |
|
116 |
|
117 Function .onInit |
|
118 ; Remove the current exe directory from the search order. |
|
119 ; This only effects LoadLibrary calls and not implicitly loaded DLLs. |
|
120 System::Call 'kernel32::SetDllDirectoryW(w "")' |
|
121 |
|
122 SetSilent silent |
|
123 |
|
124 !ifdef HAVE_64BIT_OS |
|
125 ; We plan to eventually enable 64bit native builds to use the maintenance |
|
126 ; service, but for the initial release, to reduce testing and development, |
|
127 ; 64-bit builds will not install the maintenanceservice. |
|
128 Abort |
|
129 !endif |
|
130 |
|
131 ; On Windows 2000 we do not install the maintenance service. |
|
132 ; We won't run this installer from the parent installer, but just in case |
|
133 ; someone tries to execute it on Windows 2000... |
|
134 ${Unless} ${AtLeastWinXP} |
|
135 Abort |
|
136 ${EndUnless} |
|
137 FunctionEnd |
|
138 |
|
139 Function un.onInit |
|
140 ; Remove the current exe directory from the search order. |
|
141 ; This only effects LoadLibrary calls and not implicitly loaded DLLs. |
|
142 System::Call 'kernel32::SetDllDirectoryW(w "")' |
|
143 |
|
144 ; The commands inside this ifndef are needed prior to NSIS 3.0a2 and can be |
|
145 ; removed after we require NSIS 3.0a2 or greater. |
|
146 !ifndef NSIS_PACKEDVERSION |
|
147 ${If} ${AtLeastWinVista} |
|
148 System::Call 'user32::SetProcessDPIAware()' |
|
149 ${EndIf} |
|
150 !endif |
|
151 |
|
152 StrCpy $BrandFullNameDA "${MaintFullName}" |
|
153 StrCpy $BrandFullName "${MaintFullName}" |
|
154 FunctionEnd |
|
155 |
|
156 Section "MaintenanceService" |
|
157 AllowSkipFiles off |
|
158 |
|
159 CreateDirectory $INSTDIR |
|
160 SetOutPath $INSTDIR |
|
161 |
|
162 ; If the service already exists, then it will be stopped when upgrading it |
|
163 ; via the maintenanceservice_tmp.exe command executed below. |
|
164 ; The maintenanceservice_tmp.exe command will rename the file to |
|
165 ; maintenanceservice.exe if maintenanceservice_tmp.exe is newer. |
|
166 ; If the service does not exist yet, we install it and drop the file on |
|
167 ; disk as maintenanceservice.exe directly. |
|
168 StrCpy $TempMaintServiceName "maintenanceservice.exe" |
|
169 IfFileExists "$INSTDIR\maintenanceservice.exe" 0 skipAlreadyExists |
|
170 StrCpy $TempMaintServiceName "maintenanceservice_tmp.exe" |
|
171 skipAlreadyExists: |
|
172 |
|
173 ; We always write out a copy and then decide whether to install it or |
|
174 ; not via calling its 'install' cmdline which works by version comparison. |
|
175 CopyFiles "$EXEDIR\maintenanceservice.exe" "$INSTDIR\$TempMaintServiceName" |
|
176 |
|
177 ; The updater.ini file is only used when performing an install or upgrade, |
|
178 ; and only if that install or upgrade is successful. If an old updater.ini |
|
179 ; happened to be copied into the maintenance service installation directory |
|
180 ; but the service was not newer, the updater.ini file would be unused. |
|
181 ; It is used to fill the description of the service on success. |
|
182 CopyFiles "$EXEDIR\updater.ini" "$INSTDIR\updater.ini" |
|
183 |
|
184 ; Install the application maintenance service. |
|
185 ; If a service already exists, the command line parameter will stop the |
|
186 ; service and only install itself if it is newer than the already installed |
|
187 ; service. If successful it will remove the old maintenanceservice.exe |
|
188 ; and replace it with maintenanceservice_tmp.exe. |
|
189 ClearErrors |
|
190 ${GetParameters} $0 |
|
191 ${GetOptions} "$0" "/Upgrade" $0 |
|
192 ${If} ${Errors} |
|
193 nsExec::Exec '"$INSTDIR\$TempMaintServiceName" install' |
|
194 ${Else} |
|
195 ; The upgrade cmdline is the same as install except |
|
196 ; It will fail if the service isn't already installed. |
|
197 nsExec::Exec '"$INSTDIR\$TempMaintServiceName" upgrade' |
|
198 ${EndIf} |
|
199 |
|
200 WriteUninstaller "$INSTDIR\Uninstall.exe" |
|
201 WriteRegStr HKLM "${MaintUninstallKey}" "DisplayName" "${MaintFullName}" |
|
202 WriteRegStr HKLM "${MaintUninstallKey}" "UninstallString" \ |
|
203 '"$INSTDIR\uninstall.exe"' |
|
204 WriteRegStr HKLM "${MaintUninstallKey}" "DisplayIcon" \ |
|
205 "$INSTDIR\Uninstall.exe,0" |
|
206 WriteRegStr HKLM "${MaintUninstallKey}" "DisplayVersion" "${AppVersion}" |
|
207 WriteRegStr HKLM "${MaintUninstallKey}" "Publisher" "Mozilla" |
|
208 WriteRegStr HKLM "${MaintUninstallKey}" "Comments" \ |
|
209 "${BrandFullName} ${AppVersion} (${ARCH} ${AB_CD})" |
|
210 WriteRegDWORD HKLM "${MaintUninstallKey}" "NoModify" 1 |
|
211 ${GetSize} "$INSTDIR" "/S=0K" $R2 $R3 $R4 |
|
212 WriteRegDWORD HKLM "${MaintUninstallKey}" "EstimatedSize" $R2 |
|
213 |
|
214 ; Write out that a maintenance service was attempted. |
|
215 ; We do this because on upgrades we will check this value and we only |
|
216 ; want to install once on the first upgrade to maintenance service. |
|
217 ; Also write out that we are currently installed, preferences will check |
|
218 ; this value to determine if we should show the service update pref. |
|
219 ; Since the Maintenance service can be installed either x86 or x64, |
|
220 ; always use the 64-bit registry for checking if an attempt was made. |
|
221 ${If} ${RunningX64} |
|
222 SetRegView 64 |
|
223 ${EndIf} |
|
224 WriteRegDWORD HKLM "Software\Mozilla\MaintenanceService" "Attempted" 1 |
|
225 WriteRegDWORD HKLM "Software\Mozilla\MaintenanceService" "Installed" 1 |
|
226 DeleteRegValue HKLM "Software\Mozilla\MaintenanceService" "FFPrefetchDisabled" |
|
227 |
|
228 ; Included here for debug purposes only. |
|
229 ; These keys are used to bypass the installation dir is a valid installation |
|
230 ; check from the service so that tests can be run. |
|
231 ; WriteRegStr HKLM "${FallbackKey}\0" "name" "Mozilla Corporation" |
|
232 ; WriteRegStr HKLM "${FallbackKey}\0" "issuer" "DigiCert Assured ID Code Signing CA-1" |
|
233 ${If} ${RunningX64} |
|
234 SetRegView lastused |
|
235 ${EndIf} |
|
236 SectionEnd |
|
237 |
|
238 ; By renaming before deleting we improve things slightly in case |
|
239 ; there is a file in use error. In this case a new install can happen. |
|
240 Function un.RenameDelete |
|
241 Pop $9 |
|
242 ; If the .moz-delete file already exists previously, delete it |
|
243 ; If it doesn't exist, the call is ignored. |
|
244 ; We don't need to pass /REBOOTOK here since it was already marked that way |
|
245 ; if it exists. |
|
246 Delete "$9.moz-delete" |
|
247 Rename "$9" "$9.moz-delete" |
|
248 ${If} ${Errors} |
|
249 Delete /REBOOTOK "$9" |
|
250 ${Else} |
|
251 Delete /REBOOTOK "$9.moz-delete" |
|
252 ${EndIf} |
|
253 ClearErrors |
|
254 FunctionEnd |
|
255 |
|
256 Section "Uninstall" |
|
257 ; Delete the service so that no updates will be attempted |
|
258 nsExec::Exec '"$INSTDIR\maintenanceservice.exe" uninstall' |
|
259 |
|
260 Push "$INSTDIR\updater.ini" |
|
261 Call un.RenameDelete |
|
262 Push "$INSTDIR\maintenanceservice.exe" |
|
263 Call un.RenameDelete |
|
264 Push "$INSTDIR\maintenanceservice_tmp.exe" |
|
265 Call un.RenameDelete |
|
266 Push "$INSTDIR\maintenanceservice.old" |
|
267 Call un.RenameDelete |
|
268 Push "$INSTDIR\Uninstall.exe" |
|
269 Call un.RenameDelete |
|
270 Push "$INSTDIR\update\updater.ini" |
|
271 Call un.RenameDelete |
|
272 Push "$INSTDIR\update\updater.exe" |
|
273 Call un.RenameDelete |
|
274 RMDir /REBOOTOK "$INSTDIR\update" |
|
275 RMDir /REBOOTOK "$INSTDIR" |
|
276 |
|
277 DeleteRegKey HKLM "${MaintUninstallKey}" |
|
278 |
|
279 ${If} ${RunningX64} |
|
280 SetRegView 64 |
|
281 ${EndIf} |
|
282 DeleteRegValue HKLM "Software\Mozilla\MaintenanceService" "Installed" |
|
283 DeleteRegValue HKLM "Software\Mozilla\MaintenanceService" "FFPrefetchDisabled" |
|
284 DeleteRegKey HKLM "${FallbackKey}\" |
|
285 ${If} ${RunningX64} |
|
286 SetRegView lastused |
|
287 ${EndIf} |
|
288 SectionEnd |