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