xref: /glogg/glogg.nsi (revision fca14737515a945830daffc0aa083ae925c4d9a5)
1# NSIS script creating the Windows installer for glogg
2
3# Is passed to the script using -DVERSION=$(git describe) on the command line
4!ifndef VERSION
5    !define VERSION 'anonymous-build'
6!endif
7
8# Headers
9!include "MUI2.nsh"
10!include "FileAssociation.nsh"
11
12# General
13OutFile "glogg-${VERSION}-setup.exe"
14
15XpStyle on
16
17SetCompressor /SOLID lzma
18
19; Registry key to keep track of the directory we are installed in
20InstallDir "$PROGRAMFILES\glogg"
21InstallDirRegKey HKLM Software\glogg ""
22
23; glogg icon
24; !define MUI_ICON glogg.ico
25
26RequestExecutionLevel user
27
28Name "glogg"
29Caption "glogg ${VERSION} Setup"
30
31# Pages
32!define MUI_WELCOMEPAGE_TITLE "Welcome to the glogg ${VERSION} Setup Wizard"
33!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of glogg\
34, a fast, advanced log explorer.$\r$\n$\r$\n\
35glogg and the Qt libraries are released under the GPL, see \
36the COPYING file.$\r$\n$\r$\n$_CLICK"
37; MUI_FINISHPAGE_LINK_LOCATION "http://nsis.sf.net/"
38
39!insertmacro MUI_PAGE_WELCOME
40;!insertmacro MUI_PAGE_LICENSE "COPYING"
41# !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD...
42!insertmacro MUI_PAGE_COMPONENTS
43!insertmacro MUI_PAGE_DIRECTORY
44!insertmacro MUI_PAGE_INSTFILES
45!insertmacro MUI_PAGE_FINISH
46
47!insertmacro MUI_UNPAGE_WELCOME
48!insertmacro MUI_UNPAGE_CONFIRM
49!insertmacro MUI_UNPAGE_INSTFILES
50!insertmacro MUI_UNPAGE_FINISH
51
52# Languages
53!insertmacro MUI_LANGUAGE "English"
54
55# Installer sections
56Section "glogg" glogg
57    ; Prevent this section from being unselected
58    SectionIn RO
59
60    SetOutPath $INSTDIR
61    File release\glogg.exe
62    File release\mingwm10.dll
63    File COPYING
64    File README.textile
65
66    ; Create the 'sendto' link
67    CreateShortCut "$SENDTO\glogg.lnk" "$INSTDIR\glogg,exe" "" "$INSTDIR\glogg.exe" 0
68
69    ; Register as an otion (but not main handler) for some files (.txt, .Log, .cap)
70    WriteRegStr HKCR "Applications\glogg.exe" "" ""
71    WriteRegStr HKCR "Applications\glogg.exe\shell" "" "open"
72    WriteRegStr HKCR "Applications\glogg.exe\shell\open" "FriendlyAppName" "glogg"
73    WriteRegStr HKCR "Applications\glogg.exe\shell\open\command" "" '"$INSTDIR\glogg.exe" "%1"'
74    WriteRegStr HKCR "*\OpenWithList\glogg.exe" "" ""
75    WriteRegStr HKCR ".txt\OpenWithList\glogg.exe" "" ""
76    WriteRegStr HKCR ".Log\OpenWithList\glogg.exe" "" ""
77    WriteRegStr HKCR ".cap\OpenWithList\glogg.exe" "" ""
78
79    ; Register uninstaller
80    WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg"\
81"UninstallString" '"$INSTDIR\Uninstall.exe"'
82    WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg"\
83"InstallLocation" "$INSTDIR"
84    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "DisplayName" "glogg"
85    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "DisplayVersion" "${VERSION}"
86    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "NoModify" "1"
87    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "NoRepair" "1"
88
89    ; Create uninstaller
90    WriteUninstaller "$INSTDIR\Uninstall.exe"
91SectionEnd
92
93Section "Qt4 Runtime libraries" qtlibs
94    SetOutPath $INSTDIR
95    File release\QtCore4.dll
96    File release\QtGui4.dll
97SectionEnd
98
99Section "Create Start menu shortcut" shortcut
100    SetShellVarContext all
101    CreateShortCut "$SMPROGRAMS\glogg.lnk" "$INSTDIR\glogg.exe" "" "$INSTDIR\glogg.exe" 0
102SectionEnd
103
104Section /o "Associate with .log files" associate
105    ${registerExtension} "$INSTDIR\glogg.exe" ".log" "Log file"
106SectionEnd
107
108# Descriptions
109!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
110    !insertmacro MUI_DESCRIPTION_TEXT ${glogg} "The core files required to use glogg."
111    !insertmacro MUI_DESCRIPTION_TEXT ${qtlibs} "Needed by glogg, you have to install these unless \
112you already have the Qt4 development kit installed."
113    !insertmacro MUI_DESCRIPTION_TEXT ${shortcut} "Create a shortcut in the Start menu for glogg."
114!insertmacro MUI_FUNCTION_DESCRIPTION_END
115
116# Uninstaller
117Section "Uninstall"
118    Delete "$INSTDIR\Uninstall.exe"
119
120    Delete "$INSTDIR\glogg.exe"
121    Delete "$INSTDIR\README.textile"
122    Delete "$INSTDIR\COPYING"
123    Delete "$INSTDIR\mingwm10.dll"
124    Delete "$INSTDIR\QtCore4.dll"
125    Delete "$INSTDIR\QtGui4.dll"
126    RMDir "$INSTDIR"
127
128    DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg"
129
130    ; Remove settings
131    DeleteRegKey HKCU "Software\glogg"
132
133    ; Remove the file associations
134    ${unregisterExtension} ".log" "Log file"
135
136    DeleteRegKey HKCR "*\OpenWithList\glogg.exe"
137    DeleteRegKey HKCR ".txt\OpenWithList\glogg.exe"
138    DeleteRegKey HKCR ".Log\OpenWithList\glogg.exe"
139    DeleteRegKey HKCR ".cap\OpenWithList\glogg.exe"
140    DeleteRegKey HKCR "Applications\glogg.exe\shell\open\command"
141    DeleteRegKey HKCR "Applications\glogg.exe\shell\open"
142    DeleteRegKey HKCR "Applications\glogg.exe\shell"
143    DeleteRegKey HKCR "Applications\glogg.exe"
144
145    ; Remove the shortcut, if any
146    SetShellVarContext all
147    Delete "$SMPROGRAMS\glogg.lnk"
148SectionEnd
149