Wed, 31 Dec 2014 06:55:46 +0100
Added tag TORBROWSER_REPLICA for changeset 6474c204b198
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 file, |
michael@0 | 3 | # You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | |
michael@0 | 5 | # Required Plugins: |
michael@0 | 6 | # ShellLink http://nsis.sourceforge.net/ShellLink_plug-in |
michael@0 | 7 | |
michael@0 | 8 | ; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs |
michael@0 | 9 | !verbose 3 |
michael@0 | 10 | |
michael@0 | 11 | SetDatablockOptimize on |
michael@0 | 12 | CRCCheck on |
michael@0 | 13 | SilentInstall silent |
michael@0 | 14 | |
michael@0 | 15 | RequestExecutionLevel user |
michael@0 | 16 | |
michael@0 | 17 | !addplugindir ./ |
michael@0 | 18 | |
michael@0 | 19 | ; prevents compiling of the reg write logging. |
michael@0 | 20 | !define NO_LOG |
michael@0 | 21 | |
michael@0 | 22 | ; Variables |
michael@0 | 23 | Var AppFilename |
michael@0 | 24 | Var AppName |
michael@0 | 25 | Var AppRTTempDir |
michael@0 | 26 | |
michael@0 | 27 | ; Variables/macros used by common.nsh |
michael@0 | 28 | Var TmpVal |
michael@0 | 29 | !define FileMainEXE "$AppFilename.exe" |
michael@0 | 30 | |
michael@0 | 31 | ; Other included files may depend upon these includes! |
michael@0 | 32 | ; The following includes are provided by NSIS. |
michael@0 | 33 | !include "FileFunc.nsh" |
michael@0 | 34 | !insertmacro GetParameters |
michael@0 | 35 | !insertmacro un.RefreshShellIcons |
michael@0 | 36 | !include "LogicLib.nsh" |
michael@0 | 37 | !include "WinMessages.nsh" |
michael@0 | 38 | !include "WinVer.nsh" |
michael@0 | 39 | !include "WordFunc.nsh" |
michael@0 | 40 | |
michael@0 | 41 | ; File properties, version strings, etc |
michael@0 | 42 | !define CompanyName "Mozilla Corporation" |
michael@0 | 43 | !define UninstallerName "Mozilla Webapp Runtime App Uninstaller" |
michael@0 | 44 | !define UninstallerFilename "webapp-uninstaller.exe" |
michael@0 | 45 | !define AppVersion "@APP_VERSION@" |
michael@0 | 46 | VIProductVersion "1.0.0.0" |
michael@0 | 47 | VIAddVersionKey "ProductName" "${UninstallerName}" |
michael@0 | 48 | VIAddVersionKey "CompanyName" "${CompanyName}" |
michael@0 | 49 | VIAddVersionKey "LegalCopyright" "${CompanyName}" |
michael@0 | 50 | VIAddVersionKey "FileVersion" "${AppVersion}" |
michael@0 | 51 | VIAddVersionKey "ProductVersion" "${AppVersion}" |
michael@0 | 52 | VIAddVersionKey "FileDescription" "${UninstallerName}" |
michael@0 | 53 | VIAddVersionKey "OriginalFilename" "${UninstallerFilename}" |
michael@0 | 54 | |
michael@0 | 55 | ; Mozilla custom include |
michael@0 | 56 | !include "common.nsh" |
michael@0 | 57 | !insertmacro un.DeleteShortcuts |
michael@0 | 58 | !insertmacro un.RegCleanUninstall |
michael@0 | 59 | !insertmacro un.ParseUninstallLog |
michael@0 | 60 | |
michael@0 | 61 | Name "Mozilla Web App Runtime App" |
michael@0 | 62 | OutFile "${UninstallerFilename}" |
michael@0 | 63 | ShowUnInstDetails nevershow |
michael@0 | 64 | |
michael@0 | 65 | # Create a blank page so that the default pages (instfiles) don't appear |
michael@0 | 66 | UninstPage custom un.blankPage |
michael@0 | 67 | |
michael@0 | 68 | ################################################################################ |
michael@0 | 69 | # Install Sections |
michael@0 | 70 | # The "installer" that is generated by this file is a stub that generates the |
michael@0 | 71 | # uninstaller at runtime in a temp directory and launches it. |
michael@0 | 72 | # We call `WriteUninstaller` during `onInit` so this section is empty. |
michael@0 | 73 | Section "" |
michael@0 | 74 | SectionEnd |
michael@0 | 75 | |
michael@0 | 76 | ################################################################################ |
michael@0 | 77 | # This is where uninstallation happens |
michael@0 | 78 | ################################################################################ |
michael@0 | 79 | Function un.webappUninstall |
michael@0 | 80 | ; Delete the app exe to prevent launching the app while we are uninstalling. |
michael@0 | 81 | ClearErrors |
michael@0 | 82 | ${DeleteFile} "$INSTDIR\${FileMainEXE}" |
michael@0 | 83 | ${If} ${Errors} |
michael@0 | 84 | ; If the app is running, rename the EXE out of the way |
michael@0 | 85 | CreateDirectory "$AppRTTempDir" |
michael@0 | 86 | Rename "$INSTDIR\${FileMainEXE}" "$AppRTTempDir\${FileMainEXE}" |
michael@0 | 87 | ClearErrors |
michael@0 | 88 | ${EndIf} |
michael@0 | 89 | |
michael@0 | 90 | SetShellVarContext current ; Set SHCTX to HKCU |
michael@0 | 91 | |
michael@0 | 92 | ; Remove our entry in the "Uninstall" key |
michael@0 | 93 | ${un.RegCleanUninstall} |
michael@0 | 94 | |
michael@0 | 95 | ; Remove our shortcuts from start menu, desktop, and taskbar |
michael@0 | 96 | ${un.DeleteShortcuts} |
michael@0 | 97 | |
michael@0 | 98 | ; Parse the uninstall log to remove all installed |
michael@0 | 99 | ; files / directories this install is responsible for. |
michael@0 | 100 | ${un.ParseUninstallLog} |
michael@0 | 101 | |
michael@0 | 102 | ; Remove the uninstall directory that we control. |
michael@0 | 103 | ; The installer is in the uninstall directory, it generates |
michael@0 | 104 | ; the uninstaller in a temp directory and waits for its |
michael@0 | 105 | ; execution. Thus, we can't remove the uninstall directory |
michael@0 | 106 | ; now and need to wait for a restart. |
michael@0 | 107 | ; See bug 994965. |
michael@0 | 108 | RmDir /r /REBOOTOK "$INSTDIR\uninstall" |
michael@0 | 109 | |
michael@0 | 110 | ; Remove the installation directory if it is empty |
michael@0 | 111 | ${RemoveDir} "$INSTDIR" |
michael@0 | 112 | |
michael@0 | 113 | ; Refresh shell icons to reflect the changes we've made |
michael@0 | 114 | ${un.RefreshShellIcons} |
michael@0 | 115 | FunctionEnd |
michael@0 | 116 | |
michael@0 | 117 | Function un.blankPage |
michael@0 | 118 | MessageBox MB_OKCANCEL "$(UN_CONFIRM_UNINSTALL)" /SD IDOK IDCANCEL done |
michael@0 | 119 | |
michael@0 | 120 | Call un.webappUninstall |
michael@0 | 121 | |
michael@0 | 122 | done: |
michael@0 | 123 | FunctionEnd |
michael@0 | 124 | |
michael@0 | 125 | ################################################################################ |
michael@0 | 126 | # Language |
michael@0 | 127 | |
michael@0 | 128 | !verbose push |
michael@0 | 129 | !verbose 3 |
michael@0 | 130 | !include "webapp-uninstaller-locale.nsh" |
michael@0 | 131 | !verbose pop |
michael@0 | 132 | |
michael@0 | 133 | ; Set this after the locale files to override it if it is in the locale. Using |
michael@0 | 134 | ; " " for BrandingText will hide the "Nullsoft Install System..." branding. |
michael@0 | 135 | BrandingText " " |
michael@0 | 136 | |
michael@0 | 137 | # Initialization Functions |
michael@0 | 138 | Function .onInit |
michael@0 | 139 | ; Remove the current exe directory from the search order. |
michael@0 | 140 | ; This only effects LoadLibrary calls and not implicitly loaded DLLs. |
michael@0 | 141 | System::Call 'kernel32::SetDllDirectoryW(w "")' |
michael@0 | 142 | |
michael@0 | 143 | GetTempFileName $0 |
michael@0 | 144 | Delete "$0" |
michael@0 | 145 | CreateDirectory "$0" |
michael@0 | 146 | SetOutPath "$0" |
michael@0 | 147 | |
michael@0 | 148 | StrCpy $1 "$0\${UninstallerFilename}" |
michael@0 | 149 | WriteUninstaller "$1" |
michael@0 | 150 | |
michael@0 | 151 | ${GetParameters} $2 |
michael@0 | 152 | StrCpy $2 "$2 _?=$EXEDIR" |
michael@0 | 153 | ExecWait '"$1" $2' |
michael@0 | 154 | Quit |
michael@0 | 155 | FunctionEnd |
michael@0 | 156 | |
michael@0 | 157 | Function un.onInit |
michael@0 | 158 | ; Remove the current exe directory from the search order. |
michael@0 | 159 | ; This only effects LoadLibrary calls and not implicitly loaded DLLs. |
michael@0 | 160 | System::Call 'kernel32::SetDllDirectoryW(w "")' |
michael@0 | 161 | |
michael@0 | 162 | StrCpy $LANGUAGE 0 |
michael@0 | 163 | |
michael@0 | 164 | ${un.GetParent} "$INSTDIR" $INSTDIR |
michael@0 | 165 | ${un.GetLongPath} "$INSTDIR" $INSTDIR |
michael@0 | 166 | |
michael@0 | 167 | ReadINIStr $AppFilename "$INSTDIR\webapp.ini" "Webapp" "Executable" |
michael@0 | 168 | ReadINIStr $AppName "$INSTDIR\webapp.ini" "Webapp" "Name" |
michael@0 | 169 | |
michael@0 | 170 | ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}" |
michael@0 | 171 | Abort |
michael@0 | 172 | ${EndUnless} |
michael@0 | 173 | |
michael@0 | 174 | StrCpy $AppRTTempDir "$TEMP\moz_webapprt" |
michael@0 | 175 | RmDir /r "$AppRTTempDir" |
michael@0 | 176 | |
michael@0 | 177 | ${If} ${Silent} |
michael@0 | 178 | Call un.webappUninstall |
michael@0 | 179 | ${EndIf} |
michael@0 | 180 | FunctionEnd |