browser/installer/windows/nsis/maintenanceservice_installer.nsi

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial