toolkit/components/maintenanceservice/bootstrapinstaller/maintenanceservice_installer.nsi

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

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

mercurial