Scintilla update script: strip "a/" and "b/" automatically
[geany-mirror.git] / geany.nsi
blobbe1e4ed813d4543a5af349c9917841bfd525cca0
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ; geany.nsi - this file is part of Geany, a fast and lightweight IDE
4 ; Copyright 2007-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 ; Copyright 2007-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 ; This program is free software; you can redistribute it and/or modify
8 ; it under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation; either version 2 of the License, or
10 ; (at your option) any later version.
12 ; This program is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ; GNU General Public License for more details.
17 ; You should have received a copy of the GNU General Public License
18 ; along with this program; if not, write to the Free Software
19 ; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 ; Installer script for Geany (Windows Installer)
23 ; (Script originally generated by the HM NIS Edit Script Wizard)
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 ; Do a Cyclic Redundancy Check to make sure the installer was not corrupted by the download
28 CRCCheck force
29 RequestExecutionLevel highest ; set execution level for Windows Vista
31 ;;;;;;;;;;;;;;;;;;;
32 ; helper defines ;
33 ;;;;;;;;;;;;;;;;;;;
34 !define PRODUCT_NAME "Geany"
35 !define PRODUCT_VERSION "1.25"
36 !define PRODUCT_VERSION_ID "1.25.0.0"
37 !define PRODUCT_PUBLISHER "The Geany developer team"
38 !define PRODUCT_WEB_SITE "http://www.geany.org/"
39 !define PRODUCT_DIR_REGKEY "Software\Geany"
40 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
41 !define PRODUCT_EXE "$INSTDIR\bin\Geany.exe"
42 !define PRODUCT_REGNAME "Geany.ProjectFile"
43 !define PRODUCT_EXT ".geany"
44 !define RESOURCEDIR "geany-${PRODUCT_VERSION}"
46 ;;;;;;;;;;;;;;;;;;;;;
47 ; Version resource ;
48 ;;;;;;;;;;;;;;;;;;;;;
49 VIProductVersion "${PRODUCT_VERSION_ID}"
50 VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
51 VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}"
52 VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
53 VIAddVersionKey "LegalCopyright" "Copyright 2005-2014 by the Geany developer team"
54 VIAddVersionKey "FileDescription" "${PRODUCT_NAME} Installer"
56 BrandingText "$(^NAME) installer (NSIS 2.46)"
57 InstallDir "$PROGRAMFILES\Geany"
58 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
59 SetCompressor /SOLID lzma
60 ShowInstDetails hide
61 ShowUnInstDetails hide
62 XPStyle on
63 !ifdef INCLUDE_GTK
64 OutFile "geany-${PRODUCT_VERSION}_setup.exe"
65 !else
66 OutFile "geany-${PRODUCT_VERSION}_nogtk_setup.exe"
67 !endif
69 Var Answer
70 Var UserName
71 Var StartmenuFolder
72 Var UNINSTDIR
74 ;;;;;;;;;;;;;;;;
75 ; MUI Settings ;
76 ;;;;;;;;;;;;;;;;
77 !include "MUI2.nsh"
79 !define MUI_ABORTWARNING
80 !define MUI_ICON "icons\geany.ico"
81 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-full.ico"
83 ; Welcome page
84 !insertmacro MUI_PAGE_WELCOME
85 ; License page
86 ;!define MUI_LICENSEPAGE_RADIOBUTTONS
87 !insertmacro MUI_PAGE_LICENSE "${RESOURCEDIR}\Copying.txt"
88 ; Components page
89 !insertmacro MUI_PAGE_COMPONENTS
90 ; Directory page
91 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE OnDirLeave
92 !insertmacro MUI_PAGE_DIRECTORY
93 ; Start menu page
94 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Geany"
95 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
96 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
97 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
98 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} "$StartmenuFolder"
99 ; Instfiles page
100 !insertmacro MUI_PAGE_INSTFILES
101 ; Finish page
102 !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\News.txt"
103 !define MUI_FINISHPAGE_SHOWREADME_TEXT "Show Release Notes"
104 !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
105 !define MUI_FINISHPAGE_RUN "$INSTDIR\bin\Geany.exe"
106 !define MUI_FINISHPAGE_RUN_NOTCHECKED
107 !insertmacro MUI_PAGE_FINISH
109 !insertmacro MUI_UNPAGE_INSTFILES ; Uninstaller page
110 !insertmacro MUI_LANGUAGE "English" ; Language file
112 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
113 ; Sections and InstTypes ;
114 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
115 InstType "Full"
116 InstType "Minimal"
118 Section "!Program Files" SEC01
119 SectionIn RO 1 2
120 SetOverwrite ifnewer
122 SetOutPath "$INSTDIR"
123 File "${RESOURCEDIR}\*.txt"
125 SetOutPath "$INSTDIR\bin"
126 File "${RESOURCEDIR}\bin\Geany.exe"
127 File "${RESOURCEDIR}\bin\Geany*.dll"
129 SetOutPath "$INSTDIR\data"
130 File "${RESOURCEDIR}\data\GPL-2"
131 File "${RESOURCEDIR}\data\file*"
132 File "${RESOURCEDIR}\data\geany.glade"
133 File "${RESOURCEDIR}\data\geany.gtkrc"
134 File "${RESOURCEDIR}\data\snippets.conf"
135 File "${RESOURCEDIR}\data\ui_toolbar.xml"
137 SetOutPath "$INSTDIR\data\templates"
138 File /r "${RESOURCEDIR}\data\templates\*"
140 SetOutPath "$INSTDIR\data\colorschemes"
141 File /r "${RESOURCEDIR}\data\colorschemes\*"
142 # Geany color schemes project, don't bail out if they are missing
143 File /nonfatal /r "..\geany-themes\colorschemes\*.conf"
145 SetOutPath "$INSTDIR\share\icons"
146 File /r "${RESOURCEDIR}\share\icons\*"
148 SetOutPath "$INSTDIR"
150 CreateShortCut "$INSTDIR\Geany.lnk" "$INSTDIR\bin\Geany.exe"
151 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
152 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
153 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Geany.lnk" "$INSTDIR\bin\Geany.exe"
154 !insertmacro MUI_STARTMENU_WRITE_END
156 ; register the extension .geany
157 ; write information about file type
158 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Project File"
159 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE},0"
160 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${PRODUCT_EXE}" "%1"'
161 ; write information about file extensions
162 WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
163 ; refresh shell
164 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (0x08000000, 0, 0, 0)'
165 SectionEnd
167 Section "Plugins" SEC02
168 SectionIn 1
169 SetOverwrite ifnewer
170 SetOutPath "$INSTDIR\lib"
171 File "${RESOURCEDIR}\lib\*.dll"
172 SectionEnd
174 Section "Language Files" SEC03
175 SectionIn 1
176 SetOutPath "$INSTDIR\share\locale"
177 File /r "${RESOURCEDIR}\share\locale\*"
178 !ifdef INCLUDE_GTK
179 SetOutPath "$INSTDIR\share\locale"
180 File /r "gtk\share\locale\*"
181 !endif
182 SectionEnd
184 Section "Documentation" SEC04
185 SectionIn 1
186 SetOverwrite ifnewer
187 SetOutPath "$INSTDIR"
188 File /r "${RESOURCEDIR}\doc"
189 WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" "$INSTDIR\doc\Manual.html"
190 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
191 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Documentation.lnk" "$INSTDIR\Documentation.url"
192 !insertmacro MUI_STARTMENU_WRITE_END
193 SectionEnd
195 Section "Autocompletion Tags" SEC05
196 SectionIn 1
197 SetOutPath "$INSTDIR\data"
198 SetOverwrite ifnewer
199 File "${RESOURCEDIR}\data\php.tags"
200 File "${RESOURCEDIR}\data\pascal.tags"
201 File "${RESOURCEDIR}\data\python.tags"
202 File "${RESOURCEDIR}\data\html_entities.tags"
203 File "${RESOURCEDIR}\data\c99.tags"
204 SectionEnd
206 ; Include GTK runtime library but only if desired from command line
207 !ifdef INCLUDE_GTK
208 Section "GTK 2.24 Runtime Environment" SEC06
209 SectionIn 1
210 SetOverwrite ifnewer
211 SetOutPath "$INSTDIR\bin"
212 File /r "gtk\bin\*"
213 SetOutPath "$INSTDIR\etc"
214 File /r "gtk\etc\*"
215 SetOutPath "$INSTDIR\lib"
216 File /r "gtk\lib\*"
217 SetOutPath "$INSTDIR\share\themes"
218 File /r "gtk\share\themes\*"
219 SectionEnd
220 !endif
222 Section "Context Menus" SEC07
223 SectionIn 1
224 WriteRegStr HKCR "*\shell\OpenWithGeany" "" "Open with Geany"
225 WriteRegStr HKCR "*\shell\OpenWithGeany" "Icon" "$INSTDIR\bin\geany.exe"
226 WriteRegStr HKCR "*\shell\OpenWithGeany\command" "" '"$INSTDIR\bin\geany.exe" "%1"'
227 SectionEnd
229 Section "Desktop Shortcuts" SEC08
230 SectionIn 1
231 CreateShortCut "$DESKTOP\Geany.lnk" "$INSTDIR\bin\Geany.exe"
232 CreateShortCut "$QUICKLAUNCH\Geany.lnk" "$INSTDIR\bin\Geany.exe"
233 SectionEnd
235 ; Development files
236 Section "Development files" SEC09
237 SetOverwrite ifnewer
238 SetOutPath "$INSTDIR\include"
239 File /r "${RESOURCEDIR}\include\*"
241 SetOutPath "$INSTDIR\lib\pkgconfig"
242 File "${RESOURCEDIR}\lib\pkgconfig\geany.pc"
243 SectionEnd
245 Section -AdditionalIcons
246 SetOutPath $INSTDIR
247 !insertmacro MUI_STARTMENU_WRITE_BEGIN ${PRODUCT_NAME}
248 WriteIniStr "$INSTDIR\Website.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
249 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Website.lnk" "$INSTDIR\Website.url"
250 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "$INSTDIR\uninst.exe"
251 !insertmacro MUI_STARTMENU_WRITE_END
252 SectionEnd
254 Section -Post
255 WriteUninstaller "$INSTDIR\uninst.exe"
256 WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" Path "$INSTDIR"
257 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
258 ${if} $Answer == "yes" ; if user is admin
259 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
260 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
261 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\Geany.exe"
262 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
263 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
264 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_WEB_SITE}"
265 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
266 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
267 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
268 ${endif}
269 SectionEnd
271 Section Uninstall
272 Delete "$INSTDIR\Website.url"
273 Delete "$INSTDIR\Documentation.url"
274 Delete "$INSTDIR\uninst.exe"
275 Delete "$INSTDIR\News.txt"
276 Delete "$INSTDIR\ReadMe.txt"
277 Delete "$INSTDIR\Thanks.txt"
278 Delete "$INSTDIR\ToDo.txt"
279 Delete "$INSTDIR\Authors.txt"
280 Delete "$INSTDIR\ChangeLog.txt"
281 Delete "$INSTDIR\Copying.txt"
282 Delete "$INSTDIR\Geany.lnk"
284 ; delete start menu entry
285 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
286 RMDir /r "$0"
288 Delete "$QUICKLAUNCH\Geany.lnk"
289 Delete "$DESKTOP\Geany.lnk"
291 RMDir /r "$INSTDIR\bin"
292 RMDir /r "$INSTDIR\doc"
293 RMDir /r "$INSTDIR\data"
294 RMDir /r "$INSTDIR\etc"
295 RMDir /r "$INSTDIR\include"
296 RMDir /r "$INSTDIR\lib"
297 RMDir /r "$INSTDIR\share"
298 RMDir "$INSTDIR"
300 ; remove .geany file extension
301 ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
302 ${if} $R0 == "${PRODUCT_REGNAME}"
303 DeleteRegKey SHCTX "${PRODUCT_EXT}"
304 DeleteRegKey HKCR "${PRODUCT_EXT}"
305 DeleteRegKey SHCTX "${PRODUCT_REGNAME}"
306 DeleteRegKey HKCR "${PRODUCT_REGNAME}"
307 ${endif}
309 DeleteRegKey HKCR "*\shell\OpenWithGeany"
311 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
312 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
313 DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
314 DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}"
316 SetAutoClose true
317 SectionEnd
319 ;;;;;;;;;;;;;;;;;;;;;;;;;
320 ; Section descriptions ;
321 ;;;;;;;;;;;;;;;;;;;;;;;;;
322 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
323 !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Required program files. You cannot skip these files."
324 !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "Available plugins like 'Version Diff', 'Class Builder' and 'Insert Special Characters'."
325 !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} "Various translations of Geany's interface."
326 !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} "Manual in Text and HTML format."
327 !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} "Symbol lists necessary for auto completion of symbols."
328 !ifdef INCLUDE_GTK
329 !insertmacro MUI_DESCRIPTION_TEXT ${SEC06} "You need these files to run Geany. If you have already installed a GTK Runtime Environment (2.24 or higher), you can skip it."
330 !endif
331 !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} "Add context menu item 'Open With Geany'"
332 !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} "Create shortcuts for Geany on the desktop and in the Quicklaunch Bar"
333 !insertmacro MUI_DESCRIPTION_TEXT ${SEC09} "You need these files only if you want to develop own plugins for Geany. If unsure, you can skip it."
334 !insertmacro MUI_FUNCTION_DESCRIPTION_END
336 ;;;;;;;;;;;;;;;;;;;;;
337 ; helper functions ;
338 ;;;;;;;;;;;;;;;;;;;;;
340 ; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
341 !macro IsUserAdmin Result UName
342 ClearErrors
343 UserInfo::GetName
344 IfErrors Win9x
345 Pop $0
346 StrCpy ${UName} $0
347 UserInfo::GetAccountType
348 Pop $1
349 ${if} $1 == "Admin"
350 StrCpy ${Result} "yes"
351 ${else}
352 StrCpy ${Result} "no"
353 ${endif}
354 Goto done
356 Win9x:
357 StrCpy ${Result} "yes"
358 done:
359 !macroend
361 Function .onInit
362 StrCpy "$StartmenuFolder" "Geany"
364 ; (from http://jabref.svn.sourceforge.net/viewvc/jabref/trunk/jabref/src/windows/nsis/setup.nsi)
365 ; If the user does *not* have administrator privileges, abort
366 StrCpy $Answer ""
367 StrCpy $UserName ""
368 !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
369 ${if} $Answer == "yes"
370 SetShellVarContext all ; set that e.g. shortcuts will be created for all users
371 ${else}
372 SetShellVarContext current
373 ; TODO is this really what we want? $PROGRAMFILES is not much better because
374 ; probably the unprivileged user can't write it anyways
375 StrCpy $INSTDIR "$PROFILE\$(^Name)"
376 ${endif}
378 ; prevent running multiple instances of the installer
379 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "geany_installer") i .r1 ?e'
380 Pop $R0
381 StrCmp $R0 0 +3
382 MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK
383 Abort
384 ; warn about a new install over an existing installation
385 ReadRegStr $R0 SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString"
386 StrCmp $R0 "" finish
388 MessageBox MB_YESNO|MB_ICONEXCLAMATION \
389 "Geany has already been installed. $\nDo you want to remove the previous version before installing $(^Name) ?" \
390 /SD IDYES IDYES remove IDNO finish
392 remove:
393 ; run the uninstaller
394 ClearErrors
395 ; we read the installation path of the old installation from the Registry
396 ReadRegStr $UNINSTDIR SHCTX "${PRODUCT_DIR_REGKEY}" "Path"
397 IfSilent dosilent nonsilent
398 dosilent:
399 ExecWait '$R0 /S _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
400 Goto finish
401 nonsilent:
402 ExecWait '$R0 _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
403 finish:
404 FunctionEnd
406 Function un.onUninstSuccess
407 HideWindow
408 MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." \
409 /SD IDOK
410 FunctionEnd
412 Function un.onInit
413 ; If the user does *not* have administrator privileges, abort
414 StrCpy $Answer ""
415 !insertmacro IsUserAdmin $Answer $UserName
416 ${if} $Answer == "yes"
417 SetShellVarContext all
418 ${else}
419 ; check if the Geany has been installed with admin permisions
420 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
421 ${if} $0 != ""
422 MessageBox MB_OK|MB_ICONSTOP "You need administrator privileges to uninstall Geany!" \
423 /SD IDOK
424 Abort
425 ${endif}
426 SetShellVarContext current
427 ${endif}
429 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" \
430 /SD IDYES IDYES +2
431 Abort
432 FunctionEnd
434 Function OnDirLeave
435 ClearErrors
436 SetOutPath "$INSTDIR" ; what about IfError creating $INSTDIR?
437 GetTempFileName $1 "$INSTDIR" ; creates tmp file (or fails)
438 FileOpen $0 "$1" "w" ; error to open?
439 FileWriteByte $0 "0"
440 IfErrors notPossible possible
442 notPossible:
443 RMDir "$INSTDIR" ; removes folder if empty
444 MessageBox MB_OK "The given directory is not writeable. Please choose another one!" /SD IDOK
445 Abort
446 possible:
447 FileClose $0
448 Delete "$1"
449 FunctionEnd