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
28 RequestExecutionLevel highest
; set execution level for Windows Vista
29 ; NSIS 3 Unicode support
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 GTK_VERSION @GTK_VERSION@
50 VIProductVersion
"${PRODUCT_VERSION_ID}"
51 VIAddVersionKey
"ProductName" "${PRODUCT_NAME}"
52 VIAddVersionKey
"FileVersion" "${PRODUCT_VERSION}"
53 VIAddVersionKey
"ProductVersion" "${PRODUCT_VERSION}"
54 VIAddVersionKey
"LegalCopyright" "Copyright 2005 The Geany contributors"
55 VIAddVersionKey
"FileDescription" "${PRODUCT_NAME} Installer"
57 BrandingText "$(^NAME) installer (NSIS ${NSIS_VERSION})"
58 InstallDir "$PROGRAMFILES64\Geany"
59 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
60 SetCompressor
/SOLID lzma
62 ShowUnInstDetails hide
64 ManifestSupportedOS all
65 !ifndef GEANY_INSTALLER_NAME
66 !define GEANY_INSTALLER_NAME
"geany-${PRODUCT_VERSION}_setup.exe"
68 !ifndef GEANY_RELEASE_DIR
69 !define GEANY_RELEASE_DIR
"geany-${PRODUCT_VERSION}"
71 !ifndef GEANY_THEMES_DIR
72 !define GEANY_THEMES_DIR
"..\geany-themes"
74 !ifndef GTK_BUNDLE_DIR
75 !define GTK_BUNDLE_DIR
"gtk"
78 OutFile "${GEANY_INSTALLER_NAME}"
90 ;Reserve files used in .onInit, for faster start-up
91 ReserveFile
/plugin
"System.dll"
92 ReserveFile
/plugin
"UserInfo.dll"
93 ReserveFile
/plugin
"InstallOptions.dll"
94 ReserveFile
/plugin
"LangDLL.dll"
96 !define MUI_ABORTWARNING
97 !define MUI_ICON
"icons\geany.ico"
98 !define MUI_UNICON
"${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-full.ico"
101 !insertmacro MUI_PAGE_WELCOME
103 ;!define MUI_LICENSEPAGE_RADIOBUTTONS
104 !insertmacro MUI_PAGE_LICENSE
"${GEANY_RELEASE_DIR}\Copying.txt"
106 !insertmacro MUI_PAGE_COMPONENTS
108 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE OnDirLeave
109 !insertmacro MUI_PAGE_DIRECTORY
111 !define MUI_STARTMENUPAGE_DEFAULTFOLDER
"Geany"
112 !define MUI_STARTMENUPAGE_REGISTRY_ROOT
HKLM
113 !define MUI_STARTMENUPAGE_REGISTRY_KEY
"${PRODUCT_UNINST_KEY}"
114 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME
"Start Menu Folder"
115 !insertmacro MUI_PAGE_STARTMENU
${PRODUCT_NAME} "$StartmenuFolder"
117 !insertmacro MUI_PAGE_INSTFILES
119 !define MUI_FINISHPAGE_SHOWREADME
"$INSTDIR\News.txt"
120 !define MUI_FINISHPAGE_SHOWREADME_TEXT
"Show Release Notes"
121 !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
122 !define MUI_FINISHPAGE_RUN
"$INSTDIR\bin\Geany.exe"
123 !define MUI_FINISHPAGE_RUN_NOTCHECKED
124 !insertmacro MUI_PAGE_FINISH
126 !insertmacro MUI_UNPAGE_INSTFILES
; Uninstaller page
127 !insertmacro MUI_LANGUAGE
"English" ; Language file
129 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
130 ; Sections and InstTypes ;
131 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
135 Section "!Program Files" SEC01
139 SetOutPath "$INSTDIR"
140 File "${GEANY_RELEASE_DIR}\*.txt"
142 SetOutPath "$INSTDIR\bin"
143 File "${GEANY_RELEASE_DIR}\bin\Geany.exe"
144 File "${GEANY_RELEASE_DIR}\bin\*Geany*.dll"
145 # non-GTK dependencies
146 File "${GTK_BUNDLE_DIR}\bin\libgcc_s_seh*.dll"
147 File "${GTK_BUNDLE_DIR}\bin\libstdc++-*.dll"
148 File "${GTK_BUNDLE_DIR}\bin\libwinpthread*.dll"
150 SetOutPath "$INSTDIR\libexec"
151 File /r
"${GEANY_RELEASE_DIR}\libexec\*"
153 SetOutPath "$INSTDIR\data"
154 File "${GEANY_RELEASE_DIR}\data\GPL-2"
155 File "${GEANY_RELEASE_DIR}\data\filetype_extensions.conf"
156 File "${GEANY_RELEASE_DIR}\data\geany.glade"
157 File "${GEANY_RELEASE_DIR}\data\geany.css"
158 File "${GEANY_RELEASE_DIR}\data\snippets.conf"
159 File "${GEANY_RELEASE_DIR}\data\ui_toolbar.xml"
161 SetOutPath "$INSTDIR\data\filedefs"
162 File /r
"${GEANY_RELEASE_DIR}\data\filedefs\*"
164 SetOutPath "$INSTDIR\data\templates"
165 File /r
"${GEANY_RELEASE_DIR}\data\templates\*"
167 SetOutPath "$INSTDIR\data\colorschemes"
168 File /r
"${GEANY_RELEASE_DIR}\data\colorschemes\*"
169 # Geany color schemes project, don't bail out if they are missing
170 File /nonfatal
/r
"${GEANY_THEMES_DIR}\colorschemes\*.conf"
172 SetOutPath "$INSTDIR\share\icons"
173 File /r
"${GEANY_RELEASE_DIR}\share\icons\*"
175 SetOutPath "$INSTDIR"
177 CreateShortCut "$INSTDIR\Geany.lnk" "$INSTDIR\bin\Geany.exe"
178 !insertmacro MUI_STARTMENU_WRITE_BEGIN
${PRODUCT_NAME}
179 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
180 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Geany.lnk" "$INSTDIR\bin\Geany.exe"
181 !insertmacro MUI_STARTMENU_WRITE_END
183 ; register the extension .geany
184 ; write information about file type
185 WriteRegStr SHCTX
"Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Project File"
186 WriteRegStr SHCTX
"Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE},0"
187 WriteRegStr SHCTX
"Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${PRODUCT_EXE}" "%1"'
188 ; write information about file extensions
189 WriteRegStr SHCTX
"Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
191 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (0x08000000, 0, 0, 0)'
194 Section "Plugins" SEC02
197 SetOutPath "$INSTDIR\lib\geany"
198 File "${GEANY_RELEASE_DIR}\lib\geany\*.dll"
201 Section "Language Files" SEC03
203 SetOutPath "$INSTDIR\share\locale"
204 File /r
"${GEANY_RELEASE_DIR}\share\locale\*"
205 SetOutPath "$INSTDIR\share\locale"
206 File /r
"${GTK_BUNDLE_DIR}\share\locale\*"
209 Section "Documentation" SEC04
212 SetOutPath "$INSTDIR\share\doc"
213 File /r
"${GEANY_RELEASE_DIR}\share\doc\*"
214 WriteIniStr
"$INSTDIR\Documentation.url" "InternetShortcut" "URL" "$INSTDIR\share\doc\geany\html\index.html"
215 !insertmacro MUI_STARTMENU_WRITE_BEGIN
${PRODUCT_NAME}
216 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Documentation.lnk" "$INSTDIR\Documentation.url"
217 !insertmacro MUI_STARTMENU_WRITE_END
220 Section "Autocompletion Tags" SEC05
223 SetOutPath "$INSTDIR\data\tags"
224 File /r
"${GEANY_RELEASE_DIR}\data\tags\*"
227 ; Include GTK runtime library but only if desired from command line
228 Section "GTK ${GTK_VERSION} Runtime Environment" SEC06
231 SetOutPath "$INSTDIR"
232 File "${GTK_BUNDLE_DIR}\ReadMe.Dependencies.Geany.txt"
233 SetOutPath "$INSTDIR\bin"
234 File /r
"${GTK_BUNDLE_DIR}\bin\*"
235 SetOutPath "$INSTDIR\etc"
236 File /r
"${GTK_BUNDLE_DIR}\etc\*"
237 SetOutPath "$INSTDIR\lib"
238 File /r
"${GTK_BUNDLE_DIR}\lib\*"
239 SetOutPath "$INSTDIR\share"
240 File /r
/x
"*.mo" "${GTK_BUNDLE_DIR}\share\*"
243 Section "Context Menus" SEC07
245 WriteRegStr HKCR "*\shell\OpenWithGeany" "" "Open with Geany"
246 WriteRegStr HKCR "*\shell\OpenWithGeany" "Icon" "$INSTDIR\bin\geany.exe"
247 WriteRegStr HKCR "*\shell\OpenWithGeany\command" "" '"$INSTDIR\bin\geany.exe" "%1"'
250 Section "Desktop Shortcuts" SEC08
252 CreateShortCut "$DESKTOP\Geany.lnk" "$INSTDIR\bin\Geany.exe"
253 CreateShortCut "$QUICKLAUNCH\Geany.lnk" "$INSTDIR\bin\Geany.exe"
257 Section "Development files" SEC09
260 SetOutPath "$INSTDIR\include"
261 File /r
"${GEANY_RELEASE_DIR}\include\*"
263 SetOutPath "$INSTDIR\lib\pkgconfig"
264 File "${GEANY_RELEASE_DIR}\lib\pkgconfig\geany.pc"
267 Section -AdditionalIcons
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
277 Exec '"$INSTDIR\bin\glib-compile-schemas.exe" "$INSTDIR\share\glib-2.0\schemas"'
279 WriteUninstaller "$INSTDIR\uninst.exe"
280 WriteRegStr SHCTX
"${PRODUCT_DIR_REGKEY}" Path
"$INSTDIR"
281 WriteRegStr SHCTX
"${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
282 ${if} $Answer ==
"yes" ; if user is admin
283 WriteRegStr SHCTX
"${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
284 WriteRegStr SHCTX
"${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
285 WriteRegStr SHCTX
"${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\Geany.exe"
286 WriteRegStr SHCTX
"${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
287 WriteRegStr SHCTX
"${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
288 WriteRegStr SHCTX
"${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_WEB_SITE}"
289 WriteRegStr SHCTX
"${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
290 WriteRegDWORD SHCTX
"${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
291 WriteRegDWORD SHCTX
"${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
296 Delete "$INSTDIR\Website.url"
297 Delete "$INSTDIR\Documentation.url"
298 Delete "$INSTDIR\uninst.exe"
299 Delete "$INSTDIR\News.txt"
300 Delete "$INSTDIR\ReadMe.txt"
301 Delete "$INSTDIR\ReadMe.Dependencies.Geany.txt"
302 Delete "$INSTDIR\Thanks.txt"
303 Delete "$INSTDIR\ToDo.txt"
304 Delete "$INSTDIR\Authors.txt"
305 Delete "$INSTDIR\ChangeLog.txt"
306 Delete "$INSTDIR\Copying.txt"
307 Delete "$INSTDIR\Geany.lnk"
309 ; delete start menu entry
310 ReadRegStr $0 SHCTX
"${PRODUCT_UNINST_KEY}" "StartMenu"
313 Delete "$QUICKLAUNCH\Geany.lnk"
314 Delete "$DESKTOP\Geany.lnk"
316 RMDir /r
"$INSTDIR\bin"
317 RMDir /r
"$INSTDIR\data"
318 RMDir /r
"$INSTDIR\etc"
319 RMDir /r
"$INSTDIR\include"
320 RMDir /r
"$INSTDIR\lib"
321 RMDir /r
"$INSTDIR\libexec"
322 RMDir /r
"$INSTDIR\share"
325 ; remove .geany file extension
326 ReadRegStr $R0 SHCTX
"Software\Classes\${PRODUCT_EXT}" ""
327 ${if} $R0 ==
"${PRODUCT_REGNAME}"
328 DeleteRegKey SHCTX
"${PRODUCT_EXT}"
329 DeleteRegKey HKCR "${PRODUCT_EXT}"
330 DeleteRegKey SHCTX
"${PRODUCT_REGNAME}"
331 DeleteRegKey HKCR "${PRODUCT_REGNAME}"
334 DeleteRegKey HKCR "*\shell\OpenWithGeany"
336 DeleteRegKey SHCTX
"${PRODUCT_UNINST_KEY}"
337 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
338 DeleteRegKey SHCTX
"${PRODUCT_DIR_REGKEY}"
339 DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}"
344 ;;;;;;;;;;;;;;;;;;;;;;;;;
345 ; Section descriptions ;
346 ;;;;;;;;;;;;;;;;;;;;;;;;;
347 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
348 !insertmacro MUI_DESCRIPTION_TEXT
${SEC01} "Required program files. You cannot skip these files."
349 !insertmacro MUI_DESCRIPTION_TEXT
${SEC02} "Available plugins like 'Version Diff', 'Class Builder' and 'Insert Special Characters'."
350 !insertmacro MUI_DESCRIPTION_TEXT
${SEC03} "Various translations of Geany's interface."
351 !insertmacro MUI_DESCRIPTION_TEXT
${SEC04} "Manual in Text and HTML format."
352 !insertmacro MUI_DESCRIPTION_TEXT
${SEC05} "Symbol lists necessary for auto completion of symbols."
353 !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."
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 ;;;;;;;;;;;;;;;;;;;;;
361 ;;;;;;;;;;;;;;;;;;;;;
363 ; (from https://github.com/JabRef/jabref/blob/c93c9f68746f387d00c34b6c416fcedf7967095a/src/windows/nsis/setup.nsi)
364 !macro IsUserAdmin Result UName
370 UserInfo::GetAccountType
373 StrCpy ${Result} "yes"
375 StrCpy ${Result} "no"
380 StrCpy ${Result} "yes"
385 StrCpy "$StartmenuFolder" "Geany"
387 ; (from https://github.com/JabRef/jabref/blob/c93c9f68746f387d00c34b6c416fcedf7967095a/src/windows/nsis/setup.nsi)
388 ; If the user does *not* have administrator privileges, abort
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
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)"
401 ; prevent running multiple instances of the installer
402 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "geany_installer") i .r1 ?e'
405 MessageBox MB_OK|
MB_ICONEXCLAMATION "The installer is already running." /SD
IDOK
407 ; warn about a new install over an existing installation
408 ReadRegStr $R0 SHCTX
"${PRODUCT_UNINST_KEY}" "UninstallString"
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
416 ; run the uninstaller
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
422 ExecWait '$R0 /S _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
425 ExecWait '$R0 _?=$UNINSTDIR' ;Do not copy the uninstaller to a temp file
429 Function un
.onUninstSuccess
431 MessageBox MB_ICONINFORMATION|
MB_OK "$(^Name) was successfully removed from your computer." \
436 ; If the user does *not* have administrator privileges, abort
438 !insertmacro IsUserAdmin
$Answer $UserName
439 ${if} $Answer ==
"yes"
440 SetShellVarContext all
442 ; check if the Geany has been installed with admin permisions
443 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
445 MessageBox MB_OK|
MB_ICONSTOP "You need administrator privileges to uninstall Geany!" \
449 SetShellVarContext current
452 MessageBox MB_ICONQUESTION|
MB_YESNO|MB_DEFBUTTON2
"Are you sure you want to completely remove $(^Name) and all of its components?" \
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?
463 IfErrors notPossible possible
466 RMDir "$INSTDIR" ; removes folder if empty
467 MessageBox MB_OK "The given directory is not writeable. Please choose another one!" /SD
IDOK