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