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