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