]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/windowssetup.nsi
Misc. changes to installer including:
[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 "..\..\..\LICENSE.txt"
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   ; If the AccessControl plugin was packaged or part of nsis we would use it instead.
117   ; Also, as cacls.exe is depreciated when icacls.exe exists, try icacls.exe first.
118   IfFileExists "$SYSDIR/icacls.exe" 0 +3
119   ExecWait '"$SYSDIR/icacls.exe" "$INSTDIR" /grant Everyone:(OI)(CI)F'  
120   Goto +3
121   IfFileExists "$SYSDIR/cacls.exe" 0 +2
122   ExecWait '"$SYSDIR/cacls.exe" "$INSTDIR" /E /G Everyone:F'
123   !endif
124 SectionEnd
125
126 !ifdef AUTOUPDATE
127 Section /o "Automatic Update" SECAUTO
128   SetOutPath "$INSTDIR\defaults\preferences"
129   File "client\defaults\preferences\autoupdate.js"
130   File "client\defaults\preferences\autochannel.js"
131   SetOutPath "$INSTDIR"
132 SectionEnd
133 !endif
134
135 !ifdef DEVELOPER
136 Section /o "Developer Options" SECDEV
137   SetOutPath "$INSTDIR\defaults\preferences"
138   File "client\defaults\preferences\developers.js"
139   SetOutPath "$INSTDIR"
140 SectionEnd
141 !endif
142
143 !ifdef PERMACHINE
144 Section /o "Registration Per Machine" SECPERMAC
145   SetOutPath "$INSTDIR\defaults\preferences"
146   File "client\defaults\preferences\aa_per_machine.js"
147   SetOutPath "$INSTDIR"
148 SectionEnd
149 !endif
150
151 Function .onInit
152   !insertmacro MUI_LANGDLL_DISPLAY
153   SectionSetFlags ${SECMAIN} 17
154   ; This is mainly for silent installs
155   !ifdef AUTOUPDATE | DEVELOPER | PERMACHINE
156     Var /GLOBAL CMD_ARGS
157     StrCpy $CMD_ARGS ""
158     ${GetParameters} $CMD_ARGS
159     !ifdef AUTOUPDATE
160       !ifdef AUTOUPDATE_NODEFAULT
161         ${GetOptions} $CMD_ARGS "/autoupdate" $0
162         IfErrors +2 0
163       !else
164         ${GetOptions} $CMD_ARGS "/noautoupdate" $0
165         IfErrors 0 +2
166       !endif
167       SectionSetFlags ${SECAUTO} 1
168     !endif
169     !ifdef PERMACHINE
170       !ifdef PERMACHINE_NODEFAULT
171         ${GetOptions} $CMD_ARGS "/permachine" $0
172         IfErrors +2 0
173       !else
174         ${GetOptions} $CMD_ARGS "/nopermachine" $0
175         IfErrors 0 +2
176       !endif
177       SectionSetFlags ${SECPERMAC} 1
178     !endif
179     !ifdef DEVELOPER
180       ${GetOptions} $CMD_ARGS "/developer" $0
181       IfErrors +2 0
182       SectionSetFlags ${SECDEV} 1
183     !endif
184   !endif
185 FunctionEnd
186
187 Section -AdditionalIcons
188   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
189   WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
190   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
191   CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninst.exe"
192   !insertmacro MUI_STARTMENU_WRITE_END
193 SectionEnd
194
195 Section -Post
196   WriteUninstaller "$INSTDIR\uninst.exe"
197   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\evergreen.exe"
198   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
199   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
200   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\evergreen.exe"
201   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
202   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
203   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
204 SectionEnd
205
206 ; Section descriptions
207 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
208   !insertmacro MUI_DESCRIPTION_TEXT ${SECMAIN} "The Evergreen Staff Client with XULRunner, Required"
209   !ifdef AUTOUPDATE
210   !insertmacro MUI_DESCRIPTION_TEXT ${SECAUTO} "Automatic Update Functionality"
211   !endif
212   !ifdef DEVELOPER
213   !insertmacro MUI_DESCRIPTION_TEXT ${SECDEV}  "Developer Options"
214   !endif
215   !ifdef PERMACHINE
216   !insertmacro MUI_DESCRIPTION_TEXT ${SECPERMAC}  "Default registration and offline storage to per machine instead of per user"
217   !endif
218 !insertmacro MUI_FUNCTION_DESCRIPTION_END
219
220
221 Function un.onUninstSuccess
222   HideWindow
223   MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." /SD IDOK
224 FunctionEnd
225
226 Function un.onInit
227 !insertmacro MUI_UNGETLANGUAGE
228   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
229   Abort
230 FunctionEnd
231
232 Function "un.RemoveFileCheck"
233   StrCmp $R7 "open_ils_staff_client" +5
234   StrCmp $R6 "" +3
235   Delete "$R9"
236   Goto +2
237   RmDir /r "$R9"
238   Push $0
239 FunctionEnd
240
241 Section Uninstall
242   !insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP
243   Delete "$INSTDIR\${PRODUCT_NAME}.url"
244   Delete "$INSTDIR\uninst.exe"
245   Delete "$INSTDIR\evergreen.exe"
246   Delete "$INSTDIR\application.ini"
247   Delete "$INSTDIR\BUILD_ID"
248   Delete "$INSTDIR\STAMP_ID"
249   Delete "$INSTDIR\VERSION"
250   Delete "$INSTDIR\install.rdf"
251   Delete "$INSTDIR\active-update.xml"
252   Delete "$INSTDIR\chrome.manifest"
253   Delete "$INSTDIR\updates.xml"
254   Delete "$INSTDIR\log.txt"
255   Delete "$INSTDIR\evergreen.ico"
256
257   Delete "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk"
258   Delete "$SMPROGRAMS\$ICONS_GROUP\Website.lnk"
259   Delete "$DESKTOP\Evergreen Staff Client ${PRODUCT_TAG}.lnk"
260   Delete "$SMPROGRAMS\$ICONS_GROUP\Evergreen Staff Client.lnk"
261
262   ; External script for removing extra files before we wipe out the install directory
263   !define EXTERNAL_EXTRAS_UNINSTALL
264   !include /NONFATAL "extras.nsi"
265   !undef EXTERNAL_EXTRAS_UNINSTALL
266
267   RMDir "$SMPROGRAMS\$ICONS_GROUP"
268   RMDir /r "$INSTDIR\updates"
269   RMDir /r "$INSTDIR\xulrunner"
270   RMDir /r "$INSTDIR\extensions"
271 ;  RMDir /r "$INSTDIR\chrome" ; We can't wipe out the chrome directory normally. Per-machine info would be lost on upgrade.
272   RMDir /r "$INSTDIR\components"
273   RMDir /r "$INSTDIR\defaults"
274
275   ; Basically, we want to remove everything but "open_ils_staff_client" from the chrome dir
276   ; So we pass over every file and folder in it. If it matches, we leave it alone.
277   ${Locate} "$INSTDIR\chrome" "/G=0" "un.RemoveFileCheck"
278   ; Then, we remove the folder non-recursively, which won't wipe out the folder if it is still there.
279   RMDir "$INSTDIR\chrome"
280
281   RMDir "$INSTDIR"
282
283   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
284   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
285   SetAutoClose true
286 SectionEnd