Bug 481815 - Provide a Windows service for silent updates. r=rstrong.

This commit is contained in:
Brian R. Bondy
2012-01-04 23:19:14 -05:00
parent 0cc3f99865
commit cae5b5518b
67 changed files with 5645 additions and 333 deletions

View File

@@ -61,6 +61,13 @@ INSTALLER_FILES = \
nsis/shared.nsh \
$(NULL)
ifdef MOZ_MAINTENANCE_SERVICE
INSTALLER_FILES += \
nsis/maintenanceservice_installer.nsi \
$(NULL)
endif
BRANDING_FILES = \
branding.nsi \
wizHeader.bmp \
@@ -104,6 +111,17 @@ uninstaller::
--preprocess-locale $(topsrcdir) \
$(PPL_LOCALE_ARGS) $(AB_CD) $(CONFIG_DIR)
# For building the maintenanceservice installer
ifdef MOZ_MAINTENANCE_SERVICE
maintenanceservice_installer::
$(INSTALL) $(addprefix $(srcdir)/,$(INSTALLER_FILES)) $(CONFIG_DIR)
$(PYTHON) $(topsrcdir)/config/Preprocessor.py -Fsubstitution $(DEFINES) $(ACDEFINES) \
$(srcdir)/nsis/defines.nsi.in > $(CONFIG_DIR)/defines.nsi
$(PYTHON) $(topsrcdir)/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py \
--preprocess-locale $(topsrcdir) \
$(PPL_LOCALE_ARGS) $(AB_CD) $(CONFIG_DIR)
endif
$(CONFIG_DIR)/setup.exe::
$(RM) -r $(CONFIG_DIR)
$(MKDIR) $(CONFIG_DIR)

View File

@@ -17,6 +17,9 @@
!define NO_UNINSTALL_SURVEY
!define CERTIFICATE_NAME "Mozilla Corporation"
!define CERTIFICATE_ISSUER "Thawte Code Signing CA - G2"
# LSP_CATEGORIES is the permitted LSP categories for the application. Each LSP
# category value is ANDed together to set multiple permitted categories.
# See http://msdn.microsoft.com/en-us/library/ms742253%28VS.85%29.aspx
@@ -43,6 +46,10 @@
!define MinSupportedVer "Microsoft Windows 2000"
#endif
#ifdef MOZ_MAINTENANCE_SERVICE
!define MOZ_MAINTENANCE_SERVICE
#endif
# File details shared by both the installer and uninstaller
VIProductVersion "1.0.0.0"
VIAddVersionKey "ProductName" "${BrandShortName}"

View File

@@ -19,6 +19,7 @@
#
# Contributor(s):
# Robert Strong <robert.bugzilla@gmail.com>
# Brian R. Bondy <netzen@gmail.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -35,11 +36,12 @@
# ***** END LICENSE BLOCK *****
# Required Plugins:
# AppAssocReg http://nsis.sourceforge.net/Application_Association_Registration_plug-in
# ApplicationID http://nsis.sourceforge.net/ApplicationID_plug-in
# CityHash http://mxr.mozilla.org/mozilla-central/source/other-licenses/nsis/Contrib/CityHash
# ShellLink http://nsis.sourceforge.net/ShellLink_plug-in
# UAC http://nsis.sourceforge.net/UAC_plug-in
# AppAssocReg http://nsis.sourceforge.net/Application_Association_Registration_plug-in
# ApplicationID http://nsis.sourceforge.net/ApplicationID_plug-in
# CityHash http://mxr.mozilla.org/mozilla-central/source/other-licenses/nsis/Contrib/CityHash
# ShellLink http://nsis.sourceforge.net/ShellLink_plug-in
# UAC http://nsis.sourceforge.net/UAC_plug-in
# ServicesHelper Mozilla specific plugin that is located in /other-licenses/nsis
; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs
!verbose 3
@@ -59,6 +61,7 @@ Var InstallType
Var AddStartMenuSC
Var AddQuickLaunchSC
Var AddDesktopSC
Var InstallMaintenanceService
Var PageName
; By defining NO_STARTMENU_DIR an installer that doesn't provide an option for
@@ -111,6 +114,7 @@ VIAddVersionKey "OriginalFilename" "setup.exe"
!insertmacro InitHashAppModelId
!insertmacro IsHandlerForInstallDir
!insertmacro IsPinnedToTaskBar
!insertmacro IsUserAdmin
!insertmacro LogDesktopShortcut
!insertmacro LogQuickLaunchShortcut
!insertmacro LogStartMenuShortcut
@@ -183,6 +187,11 @@ Page custom preOptions leaveOptions
!define MUI_DIRECTORYPAGE_VERIFYONLEAVE
!insertmacro MUI_PAGE_DIRECTORY
; Custom Components Page
!ifdef MOZ_MAINTENANCE_SERVICE
Page custom preComponents leaveComponents
!endif
; Custom Shortcuts Page
Page custom preShortcuts leaveShortcuts
@@ -373,6 +382,37 @@ Section "-Application" APP_IDX
${EndIf}
${EndIf}
!ifdef MOZ_MAINTENANCE_SERVICE
; If the maintenance service page was displayed then a value was already
; explicitly selected for installing the maintenance service and
; and so InstallMaintenanceService will already be 0 or 1.
; If the maintenance service page was not displayed then
; InstallMaintenanceService will be equal to "".
${If} $InstallMaintenanceService == ""
Call IsUserAdmin
Pop $R0
${If} $R0 == "true"
; Only proceed if we have HKLM write access
${AndIf} $TmpVal == "HKLM"
; On Windows 2000 we do not install the maintenance service.
${AndIf} ${AtLeastWinXP}
; The user is an admin so we should default to install service yes
StrCpy $InstallMaintenanceService "1"
${Else}
; The user is not admin so we should default to install service no
StrCpy $InstallMaintenanceService "0"
${EndIf}
${EndIf}
${If} $InstallMaintenanceService == "1"
; The user wants to install the maintenance service, so execute
; the pre-packaged maintenance service installer.
; This option can only be turned on if the user is an admin so there
; is no need to use ExecShell w/ verb runas to enforce elevated.
nsExec::Exec "$INSTDIR\maintenanceservice_installer.exe"
${EndIf}
!endif
; These need special handling on uninstall since they may be overwritten by
; an install into a different location.
StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\App Paths\${FileMainEXE}"
@@ -426,7 +466,7 @@ Section "-Application" APP_IDX
${Unless} ${Errors}
GetFunctionAddress $0 FixShortcutAppModelIDs
UAC::ExecCodeSegment $0
${EndIf}
${EndUnless}
; UAC only allows elevating to an Admin account so there is no need to add
; the Start Menu or Desktop shortcuts from the original unelevated process
@@ -482,6 +522,13 @@ Section "-Application" APP_IDX
${EndIf}
${EndUnless}
${EndIf}
!ifdef MOZ_MAINTENANCE_SERVICE
${If} $TmpVal == "HKLM"
; Add the registry keys for allowed certificates.
${AddMaintCertKeys}
${EndIf}
!endif
SectionEnd
; Cleanup operations to perform at the end of the installation.
@@ -799,6 +846,58 @@ Function leaveShortcuts
${EndIf}
FunctionEnd
!ifdef MOZ_MAINTENANCE_SERVICE
Function preComponents
; If the service already exists, don't show this page
ServicesHelper::IsInstalled "MozillaMaintenance"
Pop $R9
${If} $R9 == 1
; The service already exists so don't show this page.
Abort
${EndIf}
; On Windows 2000 we do not install the maintenance service.
${Unless} ${AtLeastWinXP}
Abort
${EndUnless}
; Don't show the custom components page if the
; user is not an admin
Call IsUserAdmin
Pop $R9
${If} $R9 != "true"
Abort
${EndIf}
; Only show the maintenance service page if we have write access to HKLM
ClearErrors
WriteRegStr HKLM "Software\Mozilla" \
"${BrandShortName}InstallerTest" "Write Test"
${If} ${Errors}
ClearErrors
Abort
${Else}
DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
${EndIf}
StrCpy $PageName "Components"
${CheckCustomCommon}
!insertmacro MUI_HEADER_TEXT "$(COMPONENTS_PAGE_TITLE)" "$(COMPONENTS_PAGE_SUBTITLE)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "components.ini"
FunctionEnd
Function leaveComponents
${MUI_INSTALLOPTIONS_READ} $0 "components.ini" "Settings" "State"
${If} $0 != 0
Abort
${EndIf}
${MUI_INSTALLOPTIONS_READ} $InstallMaintenanceService "components.ini" "Field 2" "State"
${If} $InstallType == ${INSTALLTYPE_CUSTOM}
Call CheckExistingInstall
${EndIf}
FunctionEnd
!endif
Function preSummary
StrCpy $PageName "Summary"
; Setup the summary.ini file for the Custom Summary Page
@@ -934,6 +1033,7 @@ Function .onInit
!insertmacro InitInstallOptionsFile "options.ini"
!insertmacro InitInstallOptionsFile "shortcuts.ini"
!insertmacro InitInstallOptionsFile "components.ini"
!insertmacro InitInstallOptionsFile "summary.ini"
WriteINIStr "$PLUGINSDIR\options.ini" "Settings" NumFields "5"
@@ -947,7 +1047,7 @@ Function .onInit
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Type "RadioButton"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Text "$(OPTION_STANDARD_RADIO)"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Left "15"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Left "0"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Right "-1"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Top "25"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Bottom "35"
@@ -956,7 +1056,7 @@ Function .onInit
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Type "RadioButton"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Text "$(OPTION_CUSTOM_RADIO)"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Left "15"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Left "0"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Right "-1"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Top "55"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Bottom "65"
@@ -964,14 +1064,14 @@ Function .onInit
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Type "label"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Text "$(OPTION_STANDARD_DESC)"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Left "30"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Left "15"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Right "-1"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Top "37"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Bottom "57"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Type "label"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Text "$(OPTION_CUSTOM_DESC)"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Left "30"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Left "15"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Right "-1"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Top "67"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Bottom "87"
@@ -993,7 +1093,7 @@ Function .onInit
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Type "checkbox"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Text "$(ICONS_DESKTOP)"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Left "15"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Left "0"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Right "-1"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Top "20"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Bottom "30"
@@ -1002,7 +1102,7 @@ Function .onInit
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Type "checkbox"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Text "$(ICONS_STARTMENU)"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Left "15"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Left "0"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Right "-1"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Top "40"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Bottom "50"
@@ -1012,13 +1112,32 @@ Function .onInit
${Unless} ${AtLeastWin7}
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Type "checkbox"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Text "$(ICONS_QUICKLAUNCH)"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Left "15"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Left "0"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Right "-1"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Top "60"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Bottom "70"
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" State "1"
${EndUnless}
; Setup the components.ini file for the Components Page
WriteINIStr "$PLUGINSDIR\components.ini" "Settings" NumFields "2"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Type "label"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Text "$(OPTIONAL_COMPONENTS_DESC)"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Left "0"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Right "-1"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Top "5"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Bottom "15"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Type "checkbox"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Text "$(MAINTENANCE_SERVICE_CHECKBOX_DESC)"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Left "0"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Right "-1"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Top "20"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Bottom "30"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" State "1"
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Flags "GROUP"
; There must always be a core directory.
${GetSize} "$EXEDIR\core\" "/S=0K" $R5 $R7 $R8
SectionSetSize ${APP_IDX} $R5

View File

@@ -0,0 +1,283 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is an NSIS installer for the maintenance service
#
# The Initial Developer of the Original Code is
# Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2011
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Brian R. Bondy <netzen@gmail.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
# Required Plugins:
# ServicesHelper Mozilla specific plugin that is located in /other-licenses/nsis
; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs
!verbose 3
; 7-Zip provides better compression than the lzma from NSIS so we add the files
; uncompressed and use 7-Zip to create a SFX archive of it
SetDatablockOptimize on
SetCompress off
CRCCheck on
RequestExecutionLevel admin
!addplugindir ./
; Variables
Var TempMaintServiceName
Var BrandFullNameDA
Var BrandFullName
; Other included files may depend upon these includes!
; The following includes are provided by NSIS.
!include FileFunc.nsh
!include LogicLib.nsh
!include MUI.nsh
!include WinMessages.nsh
!include WinVer.nsh
!include WordFunc.nsh
!insertmacro GetOptions
!insertmacro GetParameters
!insertmacro GetSize
; The test slaves use this fallback key to run tests.
; And anyone that wants to run tests themselves should already have
; this installed.
!define FallbackKey \
"SOFTWARE\Mozilla\MaintenanceService\3932ecacee736d366d6436db0f55bce4"
!define CompanyName "Mozilla Corporation"
!define BrandFullNameInternal ""
; The following includes are custom.
!include defines.nsi
; We keep defines.nsi defined so that we get other things like
; the version number, but we redefine BrandFullName
!define MaintFullName "Mozilla Maintenance Service"
!undef BrandFullName
!define BrandFullName "${MaintFullName}"
!include common.nsh
!include locales.nsi
VIAddVersionKey "FileDescription" "${MaintFullName} Installer"
VIAddVersionKey "OriginalFilename" "maintenanceservice_installer.exe"
Name "${MaintFullName}"
OutFile "maintenanceservice_installer.exe"
; Get installation folder from registry if available
InstallDirRegKey HKLM "Software\Mozilla\MaintenanceService" ""
SetOverwrite on
!define MaintUninstallKey \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\MozillaMaintenanceService"
; The HAVE_64BIT_OS define also means that we have an x64 build,
; not just an x64 OS.
!ifdef HAVE_64BIT_OS
; See below, we actually abort the install for x64 builds currently.
InstallDir "$PROGRAMFILES64\${MaintFullName}\"
!else
InstallDir "$PROGRAMFILES32\${MaintFullName}\"
!endif
ShowUnInstDetails nevershow
################################################################################
# Modern User Interface - MUI
!define MUI_ICON setup.ico
!define MUI_UNICON setup.ico
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_UNWELCOMEFINISHPAGE_BITMAP wizWatermark.bmp
;Interface Settings
!define MUI_ABORTWARNING
; Uninstaller Pages
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
################################################################################
# Language
!insertmacro MOZ_MUI_LANGUAGE 'baseLocale'
!verbose push
!verbose 3
!include "overrideLocale.nsh"
!include "customLocale.nsh"
!verbose pop
; Set this after the locale files to override it if it is in the locale
; using " " for BrandingText will hide the "Nullsoft Install System..." branding
BrandingText " "
Function .onInit
SetSilent silent
!ifdef HAVE_64BIT_OS
; We plan to eventually enable 64bit native builds to use the maintenance
; service, but for the initial release, to reduce testing and development,
; 64-bit builds will not install the maintenanceservice.
Abort
!endif
; On Windows 2000 we do not install the maintenance service.
; We won't run this installer from the parent installer, but just in case
; someone tries to execute it on Windows 2000...
${Unless} ${AtLeastWinXP}
Abort
${EndUnless}
FunctionEnd
Function un.onInit
StrCpy $BrandFullNameDA "${MaintFullName}"
StrCpy $BrandFullName "${MaintFullName}"
FunctionEnd
Section "MaintenanceService"
AllowSkipFiles off
CreateDirectory $INSTDIR
SetOutPath $INSTDIR
; If the service already exists, then stop it if it is running.
ServicesHelper::IsInstalled "MozillaMaintenance"
Pop $R9
${If} $R9 == 1
; Stop the maintenance service so we can overwrite any
; binaries that it uses.
ServicesHelper::Stop "MozillaMaintenance"
${EndIf}
; If we don't have maintenanceservice.exe already installed
; then keep that name. If we do use maintenanceservice_tmp.exe
; which will auto install itself when you call it with the install parameter.
StrCpy $TempMaintServiceName "maintenanceservice.exe"
IfFileExists "$INSTDIR\maintenanceservice.exe" 0 skipAlreadyExists
StrCpy $TempMaintServiceName "maintenanceservice_tmp.exe"
skipAlreadyExists:
; We always write out a copy and then decide whether to install it or
; not via calling its 'install' cmdline which works by version comparison.
CopyFiles "$EXEDIR\maintenanceservice.exe" "$INSTDIR\$TempMaintServiceName"
; Install the application maintenance service.
; If a service already exists, the command line parameter will stop the
; service and only install itself if it is newer than the already installed
; service. If successful it will remove the old maintenanceservice.exe
; and replace it with maintenanceservice_tmp.exe.
ClearErrors
${GetParameters} $0
${GetOptions} "$0" "/Upgrade" $0
${If} ${Errors}
nsExec::Exec '"$INSTDIR\$TempMaintServiceName" install'
${Else}
; The upgrade cmdline is the same as install except
; It will fail if the service isn't already installed.
nsExec::Exec '"$INSTDIR\$TempMaintServiceName" upgrade'
${EndIf}
WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "${MaintUninstallKey}" "DisplayName" "${MaintFullName}"
WriteRegStr HKLM "${MaintUninstallKey}" "UninstallString" \
'"$INSTDIR\uninstall.exe"'
WriteRegStr HKLM "${MaintUninstallKey}" "DisplayIcon" \
"$INSTDIR\Uninstall.exe,0"
WriteRegStr HKLM "${MaintUninstallKey}" "DisplayVersion" "${AppVersion}"
WriteRegStr HKLM "${MaintUninstallKey}" "Publisher" "Mozilla"
WriteRegStr HKLM "${MaintUninstallKey}" "Comments" \
"${BrandFullName} ${AppVersion} (${ARCH} ${AB_CD})"
${GetSize} "$INSTDIR" "/S=0K" $R2 $R3 $R4
WriteRegDWORD HKLM "${MaintUninstallKey}" "EstimatedSize" $R2
; Write out that a maintenance service was attempted.
; We do this because on upgrades we will check this value and we only
; want to install once on the first upgrade to maintenance service.
; Also write out that we are currently installed, preferences will check
; this value to determine if we should show the service update pref.
; Since the Maintenance service can be installed either x86 or x64,
; always use the 64-bit registry for checking if an attempt was made.
SetRegView 64
WriteRegDWORD HKLM "Software\Mozilla\MaintenanceService" "Attempted" 1
WriteRegDWORD HKLM "Software\Mozilla\MaintenanceService" "Installed" 1
; Included here for debug purposes only.
; These keys are used to bypass the installation dir is a valid installation
; check from the service so that tests can be run.
; WriteRegStr HKLM "${FallbackKey}\0" "name" "Mozilla Corporation"
; WriteRegStr HKLM "${FallbackKey}\0" "issuer" "Thawte Code Signing CA - G2"
SetRegView lastused
# The Mozilla/updates directory will have an inherited permission
# which allows any user to write to it. Work items are written there.
SetShellVarContext all
CreateDirectory "$APPDATA\Mozilla\updates"
SectionEnd
; By renaming before deleting we improve things slightly in case
; there is a file in use error. In this case a new install can happen.
Function un.RenameDelete
Pop $9
; If the .moz-delete file already exists previously, delete it
; If it doesn't exist, the call is ignored.
; We don't need to pass /REBOOTOK here since it was already marked that way
; if it exists.
Delete "$9.moz-delete"
Rename "$9" "$9.moz-delete"
${If} ${Errors}
Delete /REBOOTOK "$9"
${Else}
Delete /REBOOTOK "$9.moz-delete"
${EndIf}
ClearErrors
FunctionEnd
Section "Uninstall"
; Delete the service so that no updates will be attempted
nsExec::Exec '"$INSTDIR\maintenanceservice.exe" uninstall'
Push "$INSTDIR\maintenanceservice.exe"
Call un.RenameDelete
Push "$INSTDIR\maintenanceservice_tmp.exe"
Call un.RenameDelete
Push "$INSTDIR\Uninstall.exe"
Call un.RenameDelete
RMDir /REBOOTOK "$INSTDIR"
DeleteRegKey HKLM "${MaintUninstallKey}"
SetRegView 64
DeleteRegValue HKLM "Software\Mozilla\MaintenanceService" "Installed"
DeleteRegKey HKLM "${FallbackKey}\"
SetRegView lastused
SectionEnd

View File

@@ -19,6 +19,7 @@
#
# Contributor(s):
# Robert Strong <robert.bugzilla@gmail.com>
# Brian R. Bondy <netzen@gmail.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -105,6 +106,46 @@
${CleanVirtualStore}
${RemoveDeprecatedFiles}
!ifdef MOZ_MAINTENANCE_SERVICE
Call IsUserAdmin
Pop $R0
${If} $R0 == "true"
; Only proceed if we have HKLM write access
${AndIf} $TmpVal == "HKLM"
; On Windows 2000 we do not install the maintenance service.
${AndIf} ${AtLeastWinXP}
; Add the registry keys for allowed certificates.
${AddMaintCertKeys}
; We check to see if the maintenance service install was already attempted.
; Since the Maintenance service can be installed either x86 or x64,
; always use the 64-bit registry for checking if an attempt was made.
SetRegView 64
ReadRegDWORD $5 HKLM "Software\Mozilla\MaintenanceService" "Attempted"
ClearErrors
SetRegView lastused
; If the maintenance service is already installed, do nothing.
; The maintenance service will launch:
; maintenanceservice_installer.exe /Upgrade to upgrade the maintenance
; service if necessary. If the update was done from updater.exe without
; the service (i.e. service is failing), updater.exe will do the update of
; the service. The reasons we do not do it here is because we don't want
; to have to prompt for limited user accounts when the service isn't used
; and we currently call the PostUpdate twice, once for the user and once
; for the SYSTEM account. Also, this would stop the maintenance service
; and we need a return result back to the service when run that way.
${If} $5 == ""
; An install of maintenance service was never attempted.
; We call ExecShell (which is ShellExecute) with the verb "runas"
; to ask for elevation if the user isn't already elevated. If the user
; is already elevated it will just launch the program.
ExecShell "runas" "$INSTDIR\maintenanceservice_installer.exe"
${EndIf}
${EndIf}
!endif
!macroend
!define PostUpdate "!insertmacro PostUpdate"
@@ -437,38 +478,51 @@
!macro SetUninstallKeys
StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} ${AppVersion} (${ARCH} ${AB_CD})"
StrCpy $2 ""
ClearErrors
WriteRegStr HKLM "$0" "${BrandShortName}InstallerTest" "Write Test"
${If} ${Errors}
StrCpy $1 "HKCU"
SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
; If the uninstall keys already exist in HKLM don't create them in HKCU
ClearErrors
ReadRegStr $2 "HKLM" $0 "DisplayName"
${If} $2 == ""
; Otherwise we don't have any keys for this product in HKLM so proceeed
; to create them in HKCU. Better handling for this will be done in:
; Bug 711044 - Better handling for 2 uninstall icons
StrCpy $1 "HKCU"
SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
${EndIf}
ClearErrors
${Else}
StrCpy $1 "HKLM"
SetShellVarContext all ; Set SHCTX to all users (e.g. HKLM)
DeleteRegValue HKLM "$0" "${BrandShortName}InstallerTest"
${EndIf}
${GetLongPath} "$INSTDIR" $8
${If} $2 == ""
${GetLongPath} "$INSTDIR" $8
; Write the uninstall registry keys
${WriteRegStr2} $1 "$0" "Comments" "${BrandFullNameInternal} ${AppVersion} (${ARCH} ${AB_CD})" 0
${WriteRegStr2} $1 "$0" "DisplayIcon" "$8\${FileMainEXE},0" 0
${WriteRegStr2} $1 "$0" "DisplayName" "${BrandFullNameInternal} ${AppVersion} (${ARCH} ${AB_CD})" 0
${WriteRegStr2} $1 "$0" "DisplayVersion" "${AppVersion}" 0
${WriteRegStr2} $1 "$0" "InstallLocation" "$8" 0
${WriteRegStr2} $1 "$0" "Publisher" "Mozilla" 0
${WriteRegStr2} $1 "$0" "UninstallString" "$8\uninstall\helper.exe" 0
${WriteRegStr2} $1 "$0" "URLInfoAbout" "${URLInfoAbout}" 0
${WriteRegStr2} $1 "$0" "URLUpdateInfo" "${URLUpdateInfo}" 0
${WriteRegDWORD2} $1 "$0" "NoModify" 1 0
${WriteRegDWORD2} $1 "$0" "NoRepair" 1 0
; Write the uninstall registry keys
${WriteRegStr2} $1 "$0" "Comments" "${BrandFullNameInternal} ${AppVersion} (${ARCH} ${AB_CD})" 0
${WriteRegStr2} $1 "$0" "DisplayIcon" "$8\${FileMainEXE},0" 0
${WriteRegStr2} $1 "$0" "DisplayName" "${BrandFullNameInternal} ${AppVersion} (${ARCH} ${AB_CD})" 0
${WriteRegStr2} $1 "$0" "DisplayVersion" "${AppVersion}" 0
${WriteRegStr2} $1 "$0" "InstallLocation" "$8" 0
${WriteRegStr2} $1 "$0" "Publisher" "Mozilla" 0
${WriteRegStr2} $1 "$0" "UninstallString" "$8\uninstall\helper.exe" 0
${WriteRegStr2} $1 "$0" "URLInfoAbout" "${URLInfoAbout}" 0
${WriteRegStr2} $1 "$0" "URLUpdateInfo" "${URLUpdateInfo}" 0
${WriteRegDWORD2} $1 "$0" "NoModify" 1 0
${WriteRegDWORD2} $1 "$0" "NoRepair" 1 0
${GetSize} "$8" "/S=0K" $R2 $R3 $R4
${WriteRegDWORD2} $1 "$0" "EstimatedSize" $R2 0
${GetSize} "$8" "/S=0K" $R2 $R3 $R4
${WriteRegDWORD2} $1 "$0" "EstimatedSize" $R2 0
${If} "$TmpVal" == "HKLM"
SetShellVarContext all ; Set SHCTX to all users (e.g. HKLM)
${Else}
SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
${If} "$TmpVal" == "HKLM"
SetShellVarContext all ; Set SHCTX to all users (e.g. HKLM)
${Else}
SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
${EndIf}
${EndIf}
!macroend
!define SetUninstallKeys "!insertmacro SetUninstallKeys"
@@ -547,6 +601,35 @@
!macroend
!define UpdateProtocolHandlers "!insertmacro UpdateProtocolHandlers"
!ifdef MOZ_MAINTENANCE_SERVICE
; Adds maintenance service certificate keys for the install dir.
; For the cert to work, it must also be signed by a trusted cert for the user.
!macro AddMaintCertKeys
Push $R0
; Allow main Mozilla cert information for updates
; This call will push the needed key on the stack
ServicesHelper::PathToUniqueRegistryPath "$INSTDIR"
Pop $R0
${If} $R0 != ""
; More than one certificate can be specified in a different subfolder
; for example: $R0\1, but each individual binary can be signed
; with at most one certificate. A fallback certificate can only be used
; if the binary is replaced with a different certificate.
; We always use the 64bit registry for certs.
; This call is ignored on 32-bit systems.
SetRegView 64
DeleteRegKey HKLM "$R0"
WriteRegStr HKLM "$R0\0" "name" "${CERTIFICATE_NAME}"
WriteRegStr HKLM "$R0\0" "issuer" "${CERTIFICATE_ISSUER}"
SetRegView lastused
ClearErrors
${EndIf}
; Restore the previously used value back
Pop $R0
!macroend
!define AddMaintCertKeys "!insertmacro AddMaintCertKeys"
!endif
; Removes various registry entries for reasons noted below (does not use SHCTX).
!macro RemoveDeprecatedKeys
StrCpy $0 "SOFTWARE\Classes"
@@ -1020,7 +1103,6 @@ Function SetAsDefaultAppUserHKCU
${EndUnless}
${EndIf}
${RemoveDeprecatedKeys}
${PinToTaskBar}
FunctionEnd

View File

@@ -61,6 +61,7 @@ RequestExecutionLevel user
!define NO_LOG
Var TmpVal
Var MaintCertKey
; Other included files may depend upon these includes!
; The following includes are provided by NSIS.
@@ -96,6 +97,7 @@ VIAddVersionKey "OriginalFilename" "helper.exe"
!insertmacro InitHashAppModelId
!insertmacro IsHandlerForInstallDir
!insertmacro IsPinnedToTaskBar
!insertmacro IsUserAdmin
!insertmacro LogDesktopShortcut
!insertmacro LogQuickLaunchShortcut
!insertmacro LogStartMenuShortcut
@@ -380,6 +382,21 @@ Section "Uninstall"
; removed and other ugly things will happen like recreation of the app's
; clients registry key by the OS under some conditions.
System::Call "shell32::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)"
!ifdef MOZ_MAINTENANCE_SERVICE
; Get the path the allowed cert is at and remove it
; Keep this block of code last since it modfies the reg view
ServicesHelper::PathToUniqueRegistryPath "$INSTDIR"
Pop $MaintCertKey
${If} $MaintCertKey != ""
; We always use the 64bit registry for certs
; This call is ignored on 32-bit systems.
SetRegView 64
DeleteRegKey HKLM "$MaintCertKey\"
SetRegView lastused
${EndIf}
!endif
SectionEnd
################################################################################