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