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