1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/maintenanceservice/bootstrapinstaller/maintenanceservice_installer.nsi Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,258 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs 1.9 +!verbose 3 1.10 + 1.11 +; 7-Zip provides better compression than the lzma from NSIS so we add the files 1.12 +; uncompressed and use 7-Zip to create a SFX archive of it 1.13 +SetDatablockOptimize on 1.14 +SetCompress off 1.15 +CRCCheck on 1.16 + 1.17 +RequestExecutionLevel admin 1.18 +!addplugindir ./ 1.19 + 1.20 +; Variables 1.21 +Var TempMaintServiceName 1.22 +Var BrandFullNameDA 1.23 +Var BrandFullName 1.24 + 1.25 +; Other included files may depend upon these includes! 1.26 +; The following includes are provided by NSIS. 1.27 +!include FileFunc.nsh 1.28 +!include LogicLib.nsh 1.29 +!include MUI.nsh 1.30 +!include WinMessages.nsh 1.31 +!include WinVer.nsh 1.32 +!include WordFunc.nsh 1.33 + 1.34 +!insertmacro GetOptions 1.35 +!insertmacro GetParameters 1.36 +!insertmacro GetSize 1.37 + 1.38 +; The test slaves use this fallback key to run tests. 1.39 +; And anyone that wants to run tests themselves should already have 1.40 +; this installed. 1.41 +!define FallbackKey \ 1.42 + "SOFTWARE\Mozilla\MaintenanceService\3932ecacee736d366d6436db0f55bce4" 1.43 + 1.44 +!define CompanyName "Mozilla Corporation" 1.45 +!define BrandFullNameInternal "" 1.46 + 1.47 +; The following includes are custom. 1.48 +!include defines.nsi 1.49 +; We keep defines.nsi defined so that we get other things like 1.50 +; the version number, but we redefine BrandFullName 1.51 +!define MaintFullName "Mozilla Maintenance Service" 1.52 +!undef BrandFullName 1.53 +!define BrandFullName "${MaintFullName}" 1.54 + 1.55 +!include common.nsh 1.56 +!include locales.nsi 1.57 + 1.58 +VIAddVersionKey "FileDescription" "${MaintFullName} Installer" 1.59 +VIAddVersionKey "OriginalFilename" "maintenanceservice_installer.exe" 1.60 + 1.61 +Name "${MaintFullName}" 1.62 +OutFile "maintenanceservice_installer.exe" 1.63 + 1.64 +; Get installation folder from registry if available 1.65 +InstallDirRegKey HKLM "Software\Mozilla\MaintenanceService" "" 1.66 + 1.67 +SetOverwrite on 1.68 + 1.69 +!define MaintUninstallKey \ 1.70 + "Software\Microsoft\Windows\CurrentVersion\Uninstall\MozillaMaintenanceService" 1.71 + 1.72 +; The HAVE_64BIT_OS define also means that we have an x64 build, 1.73 +; not just an x64 OS. 1.74 +!ifdef HAVE_64BIT_OS 1.75 + ; See below, we actually abort the install for x64 builds currently. 1.76 + InstallDir "$PROGRAMFILES64\${MaintFullName}\" 1.77 +!else 1.78 + InstallDir "$PROGRAMFILES32\${MaintFullName}\" 1.79 +!endif 1.80 +ShowUnInstDetails nevershow 1.81 + 1.82 +################################################################################ 1.83 +# Modern User Interface - MUI 1.84 + 1.85 +!define MUI_ICON setup.ico 1.86 +!define MUI_UNICON setup.ico 1.87 +!define MUI_WELCOMEPAGE_TITLE_3LINES 1.88 +!define MUI_UNWELCOMEFINISHPAGE_BITMAP wizWatermark.bmp 1.89 + 1.90 +;Interface Settings 1.91 +!define MUI_ABORTWARNING 1.92 + 1.93 +; Uninstaller Pages 1.94 +!insertmacro MUI_UNPAGE_CONFIRM 1.95 +!insertmacro MUI_UNPAGE_INSTFILES 1.96 + 1.97 +################################################################################ 1.98 +# Language 1.99 + 1.100 +!insertmacro MOZ_MUI_LANGUAGE 'baseLocale' 1.101 +!verbose push 1.102 +!verbose 3 1.103 +!include "overrideLocale.nsh" 1.104 +!include "customLocale.nsh" 1.105 +!verbose pop 1.106 + 1.107 +; Set this after the locale files to override it if it is in the locale 1.108 +; using " " for BrandingText will hide the "Nullsoft Install System..." branding 1.109 +BrandingText " " 1.110 + 1.111 +Function .onInit 1.112 + SetSilent silent 1.113 +!ifdef HAVE_64BIT_OS 1.114 + ; We plan to eventually enable 64bit native builds to use the maintenance 1.115 + ; service, but for the initial release, to reduce testing and development, 1.116 + ; 64-bit builds will not install the maintenanceservice. 1.117 + Abort 1.118 +!endif 1.119 + 1.120 + ; On Windows 2000 we do not install the maintenance service. 1.121 + ; We won't run this installer from the parent installer, but just in case 1.122 + ; someone tries to execute it on Windows 2000... 1.123 + ${Unless} ${AtLeastWinXP} 1.124 + Abort 1.125 + ${EndUnless} 1.126 +FunctionEnd 1.127 + 1.128 +Function un.onInit 1.129 + StrCpy $BrandFullNameDA "${MaintFullName}" 1.130 + StrCpy $BrandFullName "${MaintFullName}" 1.131 +FunctionEnd 1.132 + 1.133 +Section "MaintenanceService" 1.134 + AllowSkipFiles off 1.135 + 1.136 + CreateDirectory $INSTDIR 1.137 + SetOutPath $INSTDIR 1.138 + 1.139 + ; If the service already exists, then it will be stopped when upgrading it 1.140 + ; via the maintenanceservice_tmp.exe command executed below. 1.141 + ; The maintenanceservice_tmp.exe command will rename the file to 1.142 + ; maintenanceservice.exe if maintenanceservice_tmp.exe is newer. 1.143 + ; If the service does not exist yet, we install it and drop the file on 1.144 + ; disk as maintenanceservice.exe directly. 1.145 + StrCpy $TempMaintServiceName "maintenanceservice.exe" 1.146 + IfFileExists "$INSTDIR\maintenanceservice.exe" 0 skipAlreadyExists 1.147 + StrCpy $TempMaintServiceName "maintenanceservice_tmp.exe" 1.148 + skipAlreadyExists: 1.149 + 1.150 + ; We always write out a copy and then decide whether to install it or 1.151 + ; not via calling its 'install' cmdline which works by version comparison. 1.152 + CopyFiles "$EXEDIR\maintenanceservice.exe" "$INSTDIR\$TempMaintServiceName" 1.153 + 1.154 + ; The updater.ini file is only used when performing an install or upgrade, 1.155 + ; and only if that install or upgrade is successful. If an old updater.ini 1.156 + ; happened to be copied into the maintenance service installation directory 1.157 + ; but the service was not newer, the updater.ini file would be unused. 1.158 + ; It is used to fill the description of the service on success. 1.159 + CopyFiles "$EXEDIR\updater.ini" "$INSTDIR\updater.ini" 1.160 + 1.161 + ; Install the application maintenance service. 1.162 + ; If a service already exists, the command line parameter will stop the 1.163 + ; service and only install itself if it is newer than the already installed 1.164 + ; service. If successful it will remove the old maintenanceservice.exe 1.165 + ; and replace it with maintenanceservice_tmp.exe. 1.166 + ClearErrors 1.167 + ;${GetParameters} $0 1.168 + ;${GetOptions} "$0" "/Upgrade" $0 1.169 + ;${If} ${Errors} 1.170 + nsExec::Exec '"$INSTDIR\$TempMaintServiceName" forceinstall' 1.171 + ;${Else} 1.172 + ; The upgrade cmdline is the same as install except 1.173 + ; It will fail if the service isn't already installed. 1.174 + ; nsExec::Exec '"$INSTDIR\$TempMaintServiceName" upgrade' 1.175 + ;${EndIf} 1.176 + 1.177 + WriteUninstaller "$INSTDIR\Uninstall.exe" 1.178 + WriteRegStr HKLM "${MaintUninstallKey}" "DisplayName" "${MaintFullName}" 1.179 + WriteRegStr HKLM "${MaintUninstallKey}" "UninstallString" \ 1.180 + '"$INSTDIR\uninstall.exe"' 1.181 + WriteRegStr HKLM "${MaintUninstallKey}" "DisplayIcon" \ 1.182 + "$INSTDIR\Uninstall.exe,0" 1.183 + WriteRegStr HKLM "${MaintUninstallKey}" "DisplayVersion" "${AppVersion}" 1.184 + WriteRegStr HKLM "${MaintUninstallKey}" "Publisher" "Mozilla" 1.185 + WriteRegStr HKLM "${MaintUninstallKey}" "Comments" \ 1.186 + "${BrandFullName} ${AppVersion} (${ARCH} ${AB_CD})" 1.187 + WriteRegDWORD HKLM "${MaintUninstallKey}" "NoModify" 1 1.188 + ${GetSize} "$INSTDIR" "/S=0K" $R2 $R3 $R4 1.189 + WriteRegDWORD HKLM "${MaintUninstallKey}" "EstimatedSize" $R2 1.190 + 1.191 + ; Write out that a maintenance service was attempted. 1.192 + ; We do this because on upgrades we will check this value and we only 1.193 + ; want to install once on the first upgrade to maintenance service. 1.194 + ; Also write out that we are currently installed, preferences will check 1.195 + ; this value to determine if we should show the service update pref. 1.196 + ; Since the Maintenance service can be installed either x86 or x64, 1.197 + ; always use the 64-bit registry for checking if an attempt was made. 1.198 + ${If} ${RunningX64} 1.199 + SetRegView 64 1.200 + ${EndIf} 1.201 + WriteRegDWORD HKLM "Software\Mozilla\MaintenanceService" "Attempted" 1 1.202 + WriteRegDWORD HKLM "Software\Mozilla\MaintenanceService" "Installed" 1 1.203 + 1.204 + ; Included here for debug purposes only. 1.205 + ; These keys are used to bypass the installation dir is a valid installation 1.206 + ; check from the service so that tests can be run. 1.207 + WriteRegStr HKLM "${FallbackKey}\0" "name" "Mozilla Corporation" 1.208 + WriteRegStr HKLM "${FallbackKey}\0" "issuer" "DigiCert Assured ID Code Signing CA-1" 1.209 + WriteRegStr HKLM "${FallbackKey}\1" "name" "Mozilla Fake SPC" 1.210 + WriteRegStr HKLM "${FallbackKey}\1" "issuer" "Mozilla Fake CA" 1.211 + ${If} ${RunningX64} 1.212 + SetRegView lastused 1.213 + ${EndIf} 1.214 +SectionEnd 1.215 + 1.216 +; By renaming before deleting we improve things slightly in case 1.217 +; there is a file in use error. In this case a new install can happen. 1.218 +Function un.RenameDelete 1.219 + Pop $9 1.220 + ; If the .moz-delete file already exists previously, delete it 1.221 + ; If it doesn't exist, the call is ignored. 1.222 + ; We don't need to pass /REBOOTOK here since it was already marked that way 1.223 + ; if it exists. 1.224 + Delete "$9.moz-delete" 1.225 + Rename "$9" "$9.moz-delete" 1.226 + ${If} ${Errors} 1.227 + Delete /REBOOTOK "$9" 1.228 + ${Else} 1.229 + Delete /REBOOTOK "$9.moz-delete" 1.230 + ${EndIf} 1.231 + ClearErrors 1.232 +FunctionEnd 1.233 + 1.234 +Section "Uninstall" 1.235 + ; Delete the service so that no updates will be attempted 1.236 + nsExec::Exec '"$INSTDIR\maintenanceservice.exe" uninstall' 1.237 + 1.238 + Push "$INSTDIR\updater.ini" 1.239 + Call un.RenameDelete 1.240 + Push "$INSTDIR\maintenanceservice.exe" 1.241 + Call un.RenameDelete 1.242 + Push "$INSTDIR\maintenanceservice_tmp.exe" 1.243 + Call un.RenameDelete 1.244 + Push "$INSTDIR\maintenanceservice.old" 1.245 + Call un.RenameDelete 1.246 + Push "$INSTDIR\Uninstall.exe" 1.247 + Call un.RenameDelete 1.248 + RMDir /REBOOTOK "$INSTDIR" 1.249 + 1.250 + DeleteRegKey HKLM "${MaintUninstallKey}" 1.251 + 1.252 + ${If} ${RunningX64} 1.253 + SetRegView 64 1.254 + ${EndIf} 1.255 + DeleteRegValue HKLM "Software\Mozilla\MaintenanceService" "Installed" 1.256 + DeleteRegKey HKLM "${FallbackKey}\" 1.257 + ${If} ${RunningX64} 1.258 + SetRegView lastused 1.259 + ${EndIf} 1.260 +SectionEnd 1.261 +