1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/webapprt/win/webapp-uninstaller.nsi.in Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,180 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 +# You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +# Required Plugins: 1.9 +# ShellLink http://nsis.sourceforge.net/ShellLink_plug-in 1.10 + 1.11 +; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs 1.12 +!verbose 3 1.13 + 1.14 +SetDatablockOptimize on 1.15 +CRCCheck on 1.16 +SilentInstall silent 1.17 + 1.18 +RequestExecutionLevel user 1.19 + 1.20 +!addplugindir ./ 1.21 + 1.22 +; prevents compiling of the reg write logging. 1.23 +!define NO_LOG 1.24 + 1.25 +; Variables 1.26 +Var AppFilename 1.27 +Var AppName 1.28 +Var AppRTTempDir 1.29 + 1.30 +; Variables/macros used by common.nsh 1.31 +Var TmpVal 1.32 +!define FileMainEXE "$AppFilename.exe" 1.33 + 1.34 +; Other included files may depend upon these includes! 1.35 +; The following includes are provided by NSIS. 1.36 +!include "FileFunc.nsh" 1.37 +!insertmacro GetParameters 1.38 +!insertmacro un.RefreshShellIcons 1.39 +!include "LogicLib.nsh" 1.40 +!include "WinMessages.nsh" 1.41 +!include "WinVer.nsh" 1.42 +!include "WordFunc.nsh" 1.43 + 1.44 +; File properties, version strings, etc 1.45 +!define CompanyName "Mozilla Corporation" 1.46 +!define UninstallerName "Mozilla Webapp Runtime App Uninstaller" 1.47 +!define UninstallerFilename "webapp-uninstaller.exe" 1.48 +!define AppVersion "@APP_VERSION@" 1.49 +VIProductVersion "1.0.0.0" 1.50 +VIAddVersionKey "ProductName" "${UninstallerName}" 1.51 +VIAddVersionKey "CompanyName" "${CompanyName}" 1.52 +VIAddVersionKey "LegalCopyright" "${CompanyName}" 1.53 +VIAddVersionKey "FileVersion" "${AppVersion}" 1.54 +VIAddVersionKey "ProductVersion" "${AppVersion}" 1.55 +VIAddVersionKey "FileDescription" "${UninstallerName}" 1.56 +VIAddVersionKey "OriginalFilename" "${UninstallerFilename}" 1.57 + 1.58 +; Mozilla custom include 1.59 +!include "common.nsh" 1.60 +!insertmacro un.DeleteShortcuts 1.61 +!insertmacro un.RegCleanUninstall 1.62 +!insertmacro un.ParseUninstallLog 1.63 + 1.64 +Name "Mozilla Web App Runtime App" 1.65 +OutFile "${UninstallerFilename}" 1.66 +ShowUnInstDetails nevershow 1.67 + 1.68 +# Create a blank page so that the default pages (instfiles) don't appear 1.69 +UninstPage custom un.blankPage 1.70 + 1.71 +################################################################################ 1.72 +# Install Sections 1.73 +# The "installer" that is generated by this file is a stub that generates the 1.74 +# uninstaller at runtime in a temp directory and launches it. 1.75 +# We call `WriteUninstaller` during `onInit` so this section is empty. 1.76 +Section "" 1.77 +SectionEnd 1.78 + 1.79 +################################################################################ 1.80 +# This is where uninstallation happens 1.81 +################################################################################ 1.82 +Function un.webappUninstall 1.83 + ; Delete the app exe to prevent launching the app while we are uninstalling. 1.84 + ClearErrors 1.85 + ${DeleteFile} "$INSTDIR\${FileMainEXE}" 1.86 + ${If} ${Errors} 1.87 + ; If the app is running, rename the EXE out of the way 1.88 + CreateDirectory "$AppRTTempDir" 1.89 + Rename "$INSTDIR\${FileMainEXE}" "$AppRTTempDir\${FileMainEXE}" 1.90 + ClearErrors 1.91 + ${EndIf} 1.92 + 1.93 + SetShellVarContext current ; Set SHCTX to HKCU 1.94 + 1.95 + ; Remove our entry in the "Uninstall" key 1.96 + ${un.RegCleanUninstall} 1.97 + 1.98 + ; Remove our shortcuts from start menu, desktop, and taskbar 1.99 + ${un.DeleteShortcuts} 1.100 + 1.101 + ; Parse the uninstall log to remove all installed 1.102 + ; files / directories this install is responsible for. 1.103 + ${un.ParseUninstallLog} 1.104 + 1.105 + ; Remove the uninstall directory that we control. 1.106 + ; The installer is in the uninstall directory, it generates 1.107 + ; the uninstaller in a temp directory and waits for its 1.108 + ; execution. Thus, we can't remove the uninstall directory 1.109 + ; now and need to wait for a restart. 1.110 + ; See bug 994965. 1.111 + RmDir /r /REBOOTOK "$INSTDIR\uninstall" 1.112 + 1.113 + ; Remove the installation directory if it is empty 1.114 + ${RemoveDir} "$INSTDIR" 1.115 + 1.116 + ; Refresh shell icons to reflect the changes we've made 1.117 + ${un.RefreshShellIcons} 1.118 +FunctionEnd 1.119 + 1.120 +Function un.blankPage 1.121 + MessageBox MB_OKCANCEL "$(UN_CONFIRM_UNINSTALL)" /SD IDOK IDCANCEL done 1.122 + 1.123 + Call un.webappUninstall 1.124 + 1.125 + done: 1.126 +FunctionEnd 1.127 + 1.128 +################################################################################ 1.129 +# Language 1.130 + 1.131 +!verbose push 1.132 +!verbose 3 1.133 +!include "webapp-uninstaller-locale.nsh" 1.134 +!verbose pop 1.135 + 1.136 +; Set this after the locale files to override it if it is in the locale. Using 1.137 +; " " for BrandingText will hide the "Nullsoft Install System..." branding. 1.138 +BrandingText " " 1.139 + 1.140 +# Initialization Functions 1.141 +Function .onInit 1.142 + ; Remove the current exe directory from the search order. 1.143 + ; This only effects LoadLibrary calls and not implicitly loaded DLLs. 1.144 + System::Call 'kernel32::SetDllDirectoryW(w "")' 1.145 + 1.146 + GetTempFileName $0 1.147 + Delete "$0" 1.148 + CreateDirectory "$0" 1.149 + SetOutPath "$0" 1.150 + 1.151 + StrCpy $1 "$0\${UninstallerFilename}" 1.152 + WriteUninstaller "$1" 1.153 + 1.154 + ${GetParameters} $2 1.155 + StrCpy $2 "$2 _?=$EXEDIR" 1.156 + ExecWait '"$1" $2' 1.157 + Quit 1.158 +FunctionEnd 1.159 + 1.160 +Function un.onInit 1.161 + ; Remove the current exe directory from the search order. 1.162 + ; This only effects LoadLibrary calls and not implicitly loaded DLLs. 1.163 + System::Call 'kernel32::SetDllDirectoryW(w "")' 1.164 + 1.165 + StrCpy $LANGUAGE 0 1.166 + 1.167 + ${un.GetParent} "$INSTDIR" $INSTDIR 1.168 + ${un.GetLongPath} "$INSTDIR" $INSTDIR 1.169 + 1.170 + ReadINIStr $AppFilename "$INSTDIR\webapp.ini" "Webapp" "Executable" 1.171 + ReadINIStr $AppName "$INSTDIR\webapp.ini" "Webapp" "Name" 1.172 + 1.173 + ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}" 1.174 + Abort 1.175 + ${EndUnless} 1.176 + 1.177 + StrCpy $AppRTTempDir "$TEMP\moz_webapprt" 1.178 + RmDir /r "$AppRTTempDir" 1.179 + 1.180 + ${If} ${Silent} 1.181 + Call un.webappUninstall 1.182 + ${EndIf} 1.183 +FunctionEnd