]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/windowssetup.nsi
Post-2.5-m1 whitespace fixup
[working/Evergreen.git] / Open-ILS / xul / staff_client / windowssetup.nsi
1 ; Script generated by the HM NIS Edit Script Wizard.
2
3 ; HM NIS Edit Wizard helper defines
4 ; Old versions of makensis don't like this, moved to Makefile
5 ;!define /file PRODUCT_VERSION "client/VERSION"
6 !define PRODUCT_TAG "Master"
7 !define PRODUCT_INSTALL_TAG "${PRODUCT_TAG}"
8 !define UI_IMAGESET "beta"
9 ;!define UI_IMAGESET "release"
10 !define PRODUCT_NAME "Evergreen Staff Client ${PRODUCT_TAG}"
11 !define PRODUCT_PUBLISHER "Evergreen Community"
12 !define PRODUCT_WEB_SITE "http://evergreen-ils.org/"
13 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\evergreen.exe"
14 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
15 !define PRODUCT_UNINST_ROOT_KEY "HKLM"
16 !define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
17 !ifndef PRODUCT_LICENSE
18   !define PRODUCT_LICENSE
19 !endif
20
21 !define MUI_HEADERIMAGE
22 !define MUI_HEADERIMAGE_BITMAP "custom_images\${UI_IMAGESET}\header.bmp"
23 !define MUI_WELCOMEFINISHPAGE_BITMAP "custom_images\${UI_IMAGESET}\install.bmp"
24 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "custom_images\${UI_IMAGESET}\uninstall.bmp"
25
26 ; This should improve compression, and solves some zlib related issues with extensions
27 SetCompressor /SOLID lzma
28
29 ; MUI 1.67 compatible ------
30 !include "MUI.nsh"
31
32 ; File Functions
33 !include "FileFunc.nsh"
34
35 ; MUI Settings
36 !define MUI_ABORTWARNING
37 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
38 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
39
40 ; Language Selection Dialog Settings
41 !define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
42 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
43 !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
44
45 ; Make the welcome page a tad less verbose on the name
46 ; Note: The title bar will still be verbose (full product name + version + "Setup")
47 !define MUI_WELCOMEPAGE_TITLE "Welcome to the Evergreen Staff Client ${PRODUCT_VERSION} Setup Wizard"
48
49 ; Welcome page
50 !insertmacro MUI_PAGE_WELCOME
51 ; License page, if we have one
52 !if "${PRODUCT_LICENSE}" != ""
53   !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE}"
54 !endif
55 ; Components page
56 !ifdef AUTOUPDATE | DEVELOPER | PERMACHINE
57 !insertmacro MUI_PAGE_COMPONENTS
58 !endif
59 ; Directory page
60 !insertmacro MUI_PAGE_DIRECTORY
61 ; Start menu page
62 var ICONS_GROUP
63 !define MUI_STARTMENUPAGE_NODISABLE
64 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Evergreen Staff Client ${PRODUCT_TAG}"
65 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
66 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
67 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
68 !insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
69 ; Instfiles page
70 !insertmacro MUI_PAGE_INSTFILES
71 ; Finish page
72 !define MUI_FINISHPAGE_RUN "$INSTDIR\evergreen.exe"
73 !insertmacro MUI_PAGE_FINISH
74
75 ; Uninstaller pages
76 !insertmacro MUI_UNPAGE_INSTFILES
77
78 ; Language files
79 !insertmacro MUI_LANGUAGE "English"
80
81 ; MUI end ------
82
83 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
84 OutFile "evergreen_staff_client_setup.exe"
85 InstallDir "$PROGRAMFILES\Evergreen Staff Client ${PRODUCT_INSTALL_TAG}"
86 InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "${PRODUCT_INSTALL_TAG}"
87 ShowInstDetails show
88 ShowUnInstDetails show
89 RequestExecutionLevel admin
90
91 Section "Staff Client" SECMAIN
92   SetShellVarContext All ; All Users (for shortcuts)
93   ; Uninstall old (inno) variant?
94   IfFileExists "$INSTDIR/unin000.exe" 0 +3
95     ExecWait '"$INSTDIR/unins000.exe" /VERYSILENT'
96     Sleep 5000 ; Wait five seconds in case the uninstaller returned before it was done
97   ; Uninstall old (nsis) version?
98   IfFileExists "$INSTDIR/uninst.exe" 0 +4
99     ExecWait '"$INSTDIR/uninst.exe" /S _?="$INSTDIR"'
100     Sleep 5000 ; Wait five seconds in case the uninstaller returned before it was done
101     Delete "$INSTDIR/uninst.exe"
102   SetOutPath "$INSTDIR"
103   File /r /x "autoupdate.js" /x "autochannel.js" /x "developers.js" /x "aa_per_machine.js" "client\*"
104
105   ; Shortcuts
106   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
107   CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
108   !ifdef WICON
109   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client.lnk" "$INSTDIR\evergreen.exe" "" "$INSTDIR\evergreen.ico"
110   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client (Standalone).lnk" "$INSTDIR\evergreen.exe" "-ILSoffline" "$INSTDIR\evergreen.ico"
111   !ifdef PROFILES
112   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client Profile Manager.lnk" "$INSTDIR\evergreen.exe" "-profilemanager" "$INSTDIR\evergreen.ico"
113   !endif
114   !else
115   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client.lnk" "$INSTDIR\evergreen.exe"
116   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client (Standalone).lnk" "$INSTDIR\evergreen.exe" "-ILSoffline"
117   !ifdef PROFILES
118   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client Profile Manager.lnk" "$INSTDIR\evergreen.exe" "-profilemanager"
119   !endif
120   !endif
121   CreateShortCut "$DESKTOP\Evergreen Staff Client ${PRODUCT_TAG}.lnk" "$INSTDIR\evergreen.exe"
122   
123   ; External script for extra things.
124   !ifdef EXTRAS
125   !define EXTERNAL_EXTRAS_SECMAIN
126   !include /NONFATAL "extras.nsi"
127   !undef EXTERNAL_EXTRAS_SECMAIN
128   !endif
129
130   !insertmacro MUI_STARTMENU_WRITE_END
131
132   !ifdef AUTOUPDATE | PERMACHINE
133   ; For autoupdate and/or registering per machine, make sure we can write to the install directory.
134   !addplugindir AccessControl/Plugins
135   AccessControl::GrantOnFile "$INSTDIR" "Everyone" "FullAccess"
136   !endif
137 SectionEnd
138
139 !ifdef AUTOUPDATE
140 Section /o "Automatic Update" SECAUTO
141   SetOutPath "$INSTDIR\defaults\preferences"
142   File "client\defaults\preferences\autoupdate.js"
143   File "client\defaults\preferences\autochannel.js"
144   SetOutPath "$INSTDIR"
145 SectionEnd
146 !endif
147
148 !ifdef DEVELOPER
149 Section /o "Developer Options" SECDEV
150   SetOutPath "$INSTDIR\defaults\preferences"
151   File "client\defaults\preferences\developers.js"
152   SetOutPath "$INSTDIR"
153 SectionEnd
154 !endif
155
156 !ifdef PERMACHINE
157 Section /o "Registration Per Machine" SECPERMAC
158   SetOutPath "$INSTDIR\defaults\preferences"
159   File "client\defaults\preferences\aa_per_machine.js"
160   SetOutPath "$INSTDIR"
161 SectionEnd
162 !endif
163
164 Function .onInit
165   !insertmacro MUI_LANGDLL_DISPLAY
166   SectionSetFlags ${SECMAIN} 17
167   ; This is mainly for silent installs
168   !ifdef AUTOUPDATE | DEVELOPER | PERMACHINE
169     Var /GLOBAL CMD_ARGS
170     StrCpy $CMD_ARGS ""
171     ${GetParameters} $CMD_ARGS
172     !ifdef AUTOUPDATE
173       !ifdef AUTOUPDATE_NODEFAULT
174         ${GetOptions} $CMD_ARGS "/autoupdate" $0
175         IfErrors +2 0
176       !else
177         ${GetOptions} $CMD_ARGS "/noautoupdate" $0
178         IfErrors 0 +2
179       !endif
180       SectionSetFlags ${SECAUTO} 1
181     !endif
182     !ifdef PERMACHINE
183       !ifdef PERMACHINE_NODEFAULT
184         ${GetOptions} $CMD_ARGS "/permachine" $0
185         IfErrors +2 0
186       !else
187         ${GetOptions} $CMD_ARGS "/nopermachine" $0
188         IfErrors 0 +2
189       !endif
190       SectionSetFlags ${SECPERMAC} 1
191     !endif
192     !ifdef DEVELOPER
193       ${GetOptions} $CMD_ARGS "/developer" $0
194       IfErrors +2 0
195       SectionSetFlags ${SECDEV} 1
196     !endif
197   !endif
198 FunctionEnd
199
200 Section -AdditionalIcons
201   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
202   WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
203   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
204   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninst.exe"
205   !insertmacro MUI_STARTMENU_WRITE_END
206 SectionEnd
207
208 Section -Post
209   WriteUninstaller "$INSTDIR\uninst.exe"
210   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\evergreen.exe"
211   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
212   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
213   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\evergreen.exe"
214   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
215   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
216   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
217 SectionEnd
218
219 ; Section descriptions
220 !ifdef AUTOUPDATE | DEVELOPER | PERMACHINE
221 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
222   !insertmacro MUI_DESCRIPTION_TEXT ${SECMAIN} "The Evergreen Staff Client with XULRunner, Required"
223   !ifdef AUTOUPDATE
224   !insertmacro MUI_DESCRIPTION_TEXT ${SECAUTO} "Automatic Update Functionality"
225   !endif
226   !ifdef DEVELOPER
227   !insertmacro MUI_DESCRIPTION_TEXT ${SECDEV}  "Developer Options"
228   !endif
229   !ifdef PERMACHINE
230   !insertmacro MUI_DESCRIPTION_TEXT ${SECPERMAC}  "Default registration and offline storage to per machine instead of per user"
231   !endif
232 !insertmacro MUI_FUNCTION_DESCRIPTION_END
233 !endif
234
235 Function un.onUninstSuccess
236   HideWindow
237   MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." /SD IDOK
238 FunctionEnd
239
240 Function un.onInit
241 !insertmacro MUI_UNGETLANGUAGE
242   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" /SD IDYES IDYES +2
243   Abort
244 FunctionEnd
245
246 Function "un.RemoveFileCheck"
247   StrCmp $R7 "open_ils_staff_client" +5
248   StrCmp $R6 "" +3
249   Delete "$R9"
250   Goto +2
251   RmDir /r "$R9"
252   Push $0
253 FunctionEnd
254
255 Section Uninstall
256   SetShellVarContext All ; All Users (for shortcuts)
257   !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP
258   Delete "$INSTDIR\${PRODUCT_NAME}.url"
259   Delete "$INSTDIR\uninst.exe"
260   Delete "$INSTDIR\evergreen.exe"
261   Delete "$INSTDIR\application.ini"
262   Delete "$INSTDIR\BUILD_ID"
263   Delete "$INSTDIR\STAMP_ID"
264   Delete "$INSTDIR\VERSION"
265   Delete "$INSTDIR\install.rdf"
266   Delete "$INSTDIR\active-update.xml"
267   Delete "$INSTDIR\chrome.manifest"
268   Delete "$INSTDIR\updates.xml"
269   Delete "$INSTDIR\log.txt"
270   Delete "$INSTDIR\evergreen.ico"
271
272   Delete "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk"
273   Delete "$SMPROGRAMS\$ICONS_GROUP\Website.lnk"
274   Delete "$DESKTOP\Evergreen Staff Client ${PRODUCT_TAG}.lnk"
275   Delete "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client.lnk"
276   Delete "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client (Standalone).lnk"
277
278   ; External script for removing extra files before we wipe out the install directory
279   !ifdef EXTRAS
280   !define EXTERNAL_EXTRAS_UNINSTALL
281   !include /NONFATAL "extras.nsi"
282   !undef EXTERNAL_EXTRAS_UNINSTALL
283   !endif
284
285   RMDir "$SMPROGRAMS\$ICONS_GROUP"
286   RMDir /r "$INSTDIR\updates"
287   RMDir /r "$INSTDIR\xulrunner"
288   RMDir /r "$INSTDIR\extensions"
289 ;  RMDir /r "$INSTDIR\chrome" ; We can't wipe out the chrome directory normally. Per-machine info would be lost on upgrade.
290   RMDir /r "$INSTDIR\components"
291   RMDir /r "$INSTDIR\defaults"
292
293   ; Basically, we want to remove everything but "open_ils_staff_client" from the chrome dir
294   ; So we pass over every file and folder in it. If it matches, we leave it alone.
295   ${Locate} "$INSTDIR\chrome" "/G=0" "un.RemoveFileCheck"
296   ; Then, we remove the folder non-recursively, which won't wipe out the folder if it is still there.
297   RMDir "$INSTDIR\chrome"
298
299   RMDir "$INSTDIR"
300
301   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
302   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
303   SetAutoClose true
304 SectionEnd