michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: # You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # Required Plugins: michael@0: # ShellLink http://nsis.sourceforge.net/ShellLink_plug-in michael@0: michael@0: ; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs michael@0: !verbose 3 michael@0: michael@0: SetDatablockOptimize on michael@0: CRCCheck on michael@0: SilentInstall silent michael@0: michael@0: RequestExecutionLevel user michael@0: michael@0: !addplugindir ./ michael@0: michael@0: ; prevents compiling of the reg write logging. michael@0: !define NO_LOG michael@0: michael@0: ; Variables michael@0: Var AppFilename michael@0: Var AppName michael@0: Var AppRTTempDir michael@0: michael@0: ; Variables/macros used by common.nsh michael@0: Var TmpVal michael@0: !define FileMainEXE "$AppFilename.exe" michael@0: michael@0: ; Other included files may depend upon these includes! michael@0: ; The following includes are provided by NSIS. michael@0: !include "FileFunc.nsh" michael@0: !insertmacro GetParameters michael@0: !insertmacro un.RefreshShellIcons michael@0: !include "LogicLib.nsh" michael@0: !include "WinMessages.nsh" michael@0: !include "WinVer.nsh" michael@0: !include "WordFunc.nsh" michael@0: michael@0: ; File properties, version strings, etc michael@0: !define CompanyName "Mozilla Corporation" michael@0: !define UninstallerName "Mozilla Webapp Runtime App Uninstaller" michael@0: !define UninstallerFilename "webapp-uninstaller.exe" michael@0: !define AppVersion "@APP_VERSION@" michael@0: VIProductVersion "1.0.0.0" michael@0: VIAddVersionKey "ProductName" "${UninstallerName}" michael@0: VIAddVersionKey "CompanyName" "${CompanyName}" michael@0: VIAddVersionKey "LegalCopyright" "${CompanyName}" michael@0: VIAddVersionKey "FileVersion" "${AppVersion}" michael@0: VIAddVersionKey "ProductVersion" "${AppVersion}" michael@0: VIAddVersionKey "FileDescription" "${UninstallerName}" michael@0: VIAddVersionKey "OriginalFilename" "${UninstallerFilename}" michael@0: michael@0: ; Mozilla custom include michael@0: !include "common.nsh" michael@0: !insertmacro un.DeleteShortcuts michael@0: !insertmacro un.RegCleanUninstall michael@0: !insertmacro un.ParseUninstallLog michael@0: michael@0: Name "Mozilla Web App Runtime App" michael@0: OutFile "${UninstallerFilename}" michael@0: ShowUnInstDetails nevershow michael@0: michael@0: # Create a blank page so that the default pages (instfiles) don't appear michael@0: UninstPage custom un.blankPage michael@0: michael@0: ################################################################################ michael@0: # Install Sections michael@0: # The "installer" that is generated by this file is a stub that generates the michael@0: # uninstaller at runtime in a temp directory and launches it. michael@0: # We call `WriteUninstaller` during `onInit` so this section is empty. michael@0: Section "" michael@0: SectionEnd michael@0: michael@0: ################################################################################ michael@0: # This is where uninstallation happens michael@0: ################################################################################ michael@0: Function un.webappUninstall michael@0: ; Delete the app exe to prevent launching the app while we are uninstalling. michael@0: ClearErrors michael@0: ${DeleteFile} "$INSTDIR\${FileMainEXE}" michael@0: ${If} ${Errors} michael@0: ; If the app is running, rename the EXE out of the way michael@0: CreateDirectory "$AppRTTempDir" michael@0: Rename "$INSTDIR\${FileMainEXE}" "$AppRTTempDir\${FileMainEXE}" michael@0: ClearErrors michael@0: ${EndIf} michael@0: michael@0: SetShellVarContext current ; Set SHCTX to HKCU michael@0: michael@0: ; Remove our entry in the "Uninstall" key michael@0: ${un.RegCleanUninstall} michael@0: michael@0: ; Remove our shortcuts from start menu, desktop, and taskbar michael@0: ${un.DeleteShortcuts} michael@0: michael@0: ; Parse the uninstall log to remove all installed michael@0: ; files / directories this install is responsible for. michael@0: ${un.ParseUninstallLog} michael@0: michael@0: ; Remove the uninstall directory that we control. michael@0: ; The installer is in the uninstall directory, it generates michael@0: ; the uninstaller in a temp directory and waits for its michael@0: ; execution. Thus, we can't remove the uninstall directory michael@0: ; now and need to wait for a restart. michael@0: ; See bug 994965. michael@0: RmDir /r /REBOOTOK "$INSTDIR\uninstall" michael@0: michael@0: ; Remove the installation directory if it is empty michael@0: ${RemoveDir} "$INSTDIR" michael@0: michael@0: ; Refresh shell icons to reflect the changes we've made michael@0: ${un.RefreshShellIcons} michael@0: FunctionEnd michael@0: michael@0: Function un.blankPage michael@0: MessageBox MB_OKCANCEL "$(UN_CONFIRM_UNINSTALL)" /SD IDOK IDCANCEL done michael@0: michael@0: Call un.webappUninstall michael@0: michael@0: done: michael@0: FunctionEnd michael@0: michael@0: ################################################################################ michael@0: # Language michael@0: michael@0: !verbose push michael@0: !verbose 3 michael@0: !include "webapp-uninstaller-locale.nsh" michael@0: !verbose pop michael@0: michael@0: ; Set this after the locale files to override it if it is in the locale. Using michael@0: ; " " for BrandingText will hide the "Nullsoft Install System..." branding. michael@0: BrandingText " " michael@0: michael@0: # Initialization Functions michael@0: Function .onInit michael@0: ; Remove the current exe directory from the search order. michael@0: ; This only effects LoadLibrary calls and not implicitly loaded DLLs. michael@0: System::Call 'kernel32::SetDllDirectoryW(w "")' michael@0: michael@0: GetTempFileName $0 michael@0: Delete "$0" michael@0: CreateDirectory "$0" michael@0: SetOutPath "$0" michael@0: michael@0: StrCpy $1 "$0\${UninstallerFilename}" michael@0: WriteUninstaller "$1" michael@0: michael@0: ${GetParameters} $2 michael@0: StrCpy $2 "$2 _?=$EXEDIR" michael@0: ExecWait '"$1" $2' michael@0: Quit michael@0: FunctionEnd michael@0: michael@0: Function un.onInit michael@0: ; Remove the current exe directory from the search order. michael@0: ; This only effects LoadLibrary calls and not implicitly loaded DLLs. michael@0: System::Call 'kernel32::SetDllDirectoryW(w "")' michael@0: michael@0: StrCpy $LANGUAGE 0 michael@0: michael@0: ${un.GetParent} "$INSTDIR" $INSTDIR michael@0: ${un.GetLongPath} "$INSTDIR" $INSTDIR michael@0: michael@0: ReadINIStr $AppFilename "$INSTDIR\webapp.ini" "Webapp" "Executable" michael@0: ReadINIStr $AppName "$INSTDIR\webapp.ini" "Webapp" "Name" michael@0: michael@0: ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}" michael@0: Abort michael@0: ${EndUnless} michael@0: michael@0: StrCpy $AppRTTempDir "$TEMP\moz_webapprt" michael@0: RmDir /r "$AppRTTempDir" michael@0: michael@0: ${If} ${Silent} michael@0: Call un.webappUninstall michael@0: ${EndIf} michael@0: FunctionEnd