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