xref: /glogg/glogg.nsi (revision 468fe70fbd3e718e8f04f84d79fd86eaf9823bec)
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
20!ifdef ARCH32
21  InstallDir "$PROGRAMFILES\glogg"
22!else
23  InstallDir "$PROGRAMFILES64\glogg"
24!endif
25InstallDirRegKey HKLM Software\glogg ""
26
27; glogg icon
28; !define MUI_ICON glogg.ico
29
30RequestExecutionLevel admin
31
32Name "glogg"
33Caption "glogg ${VERSION} Setup"
34
35# Pages
36!define MUI_WELCOMEPAGE_TITLE "Welcome to the glogg ${VERSION} Setup Wizard"
37!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of glogg\
38, a fast, advanced log explorer.$\r$\n$\r$\n\
39glogg and the Qt libraries are released under the GPL, see \
40the COPYING file.$\r$\n$\r$\n$_CLICK"
41; MUI_FINISHPAGE_LINK_LOCATION "http://nsis.sf.net/"
42
43!insertmacro MUI_PAGE_WELCOME
44;!insertmacro MUI_PAGE_LICENSE "COPYING"
45# !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD...
46!insertmacro MUI_PAGE_COMPONENTS
47!insertmacro MUI_PAGE_DIRECTORY
48!insertmacro MUI_PAGE_INSTFILES
49!insertmacro MUI_PAGE_FINISH
50
51!insertmacro MUI_UNPAGE_WELCOME
52!insertmacro MUI_UNPAGE_CONFIRM
53!insertmacro MUI_UNPAGE_INSTFILES
54!insertmacro MUI_UNPAGE_FINISH
55
56# Languages
57!insertmacro MUI_LANGUAGE "English"
58
59# Installer sections
60Section "glogg" glogg
61    ; Prevent this section from being unselected
62    SectionIn RO
63
64    SetOutPath $INSTDIR
65    File release\glogg.exe
66    File COPYING
67    File README
68
69    ; Create the 'sendto' link
70    CreateShortCut "$SENDTO\glogg.lnk" "$INSTDIR\glogg,exe" "" "$INSTDIR\glogg.exe" 0
71
72    ; Register as an otion (but not main handler) for some files (.txt, .Log, .cap)
73    WriteRegStr HKCR "Applications\glogg.exe" "" ""
74    WriteRegStr HKCR "Applications\glogg.exe\shell" "" "open"
75    WriteRegStr HKCR "Applications\glogg.exe\shell\open" "FriendlyAppName" "glogg"
76    WriteRegStr HKCR "Applications\glogg.exe\shell\open\command" "" '"$INSTDIR\glogg.exe" "%1"'
77    WriteRegStr HKCR "*\OpenWithList\glogg.exe" "" ""
78    WriteRegStr HKCR ".txt\OpenWithList\glogg.exe" "" ""
79    WriteRegStr HKCR ".Log\OpenWithList\glogg.exe" "" ""
80    WriteRegStr HKCR ".cap\OpenWithList\glogg.exe" "" ""
81
82    ; Register uninstaller
83    WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg"\
84"UninstallString" '"$INSTDIR\Uninstall.exe"'
85    WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg"\
86"InstallLocation" "$INSTDIR"
87    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "DisplayName" "glogg"
88    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "DisplayVersion" "${VERSION}"
89    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "NoModify" "1"
90    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "NoRepair" "1"
91
92    ; Create uninstaller
93    WriteUninstaller "$INSTDIR\Uninstall.exe"
94SectionEnd
95
96Section "Qt5 Runtime libraries" qtlibs
97    SetOutPath $INSTDIR
98    File release\Qt5Core.dll
99    File release\Qt5Gui.dll
100    File release\Qt5Network.dll
101    File release\Qt5Widgets.dll
102    File release\libwinpthread-1.dll
103SectionEnd
104
105Section "Create Start menu shortcut" shortcut
106    SetShellVarContext all
107    CreateShortCut "$SMPROGRAMS\glogg.lnk" "$INSTDIR\glogg.exe" "" "$INSTDIR\glogg.exe" 0
108SectionEnd
109
110Section /o "Associate with .log files" associate
111    ${registerExtension} "$INSTDIR\glogg.exe" ".log" "Log file"
112SectionEnd
113
114# Descriptions
115!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
116    !insertmacro MUI_DESCRIPTION_TEXT ${glogg} "The core files required to use glogg."
117    !insertmacro MUI_DESCRIPTION_TEXT ${qtlibs} "Needed by glogg, you have to install these unless \
118you already have the Qt4 development kit installed."
119    !insertmacro MUI_DESCRIPTION_TEXT ${shortcut} "Create a shortcut in the Start menu for glogg."
120    !insertmacro MUI_DESCRIPTION_TEXT ${associate} "Make glogg the default viewer for .log files."
121!insertmacro MUI_FUNCTION_DESCRIPTION_END
122
123# Uninstaller
124Section "Uninstall"
125    Delete "$INSTDIR\Uninstall.exe"
126
127    Delete "$INSTDIR\glogg.exe"
128    Delete "$INSTDIR\README"
129    Delete "$INSTDIR\COPYING"
130    Delete "$INSTDIR\mingwm10.dll"
131    Delete "$INSTDIR\libgcc_s_dw2-1.dll"
132    Delete "$INSTDIR\QtCore4.dll"
133    Delete "$INSTDIR\QtGui4.dll"
134    Delete "$INSTDIR\QtNetwork4.dll"
135    Delete "$INSTDIR\Qt5Core.dll"
136    Delete "$INSTDIR\Qt5Gui.dll"
137    Delete "$INSTDIR\Qt5Network.dll"
138    Delete "$INSTDIR\Qt5Widgets.dll"
139    Delete "$INSTDIR\libwinpthread-1.dll"
140    RMDir "$INSTDIR"
141
142    ; Remove settings in %appdata%
143    Delete "$APPDATA\glogg\glogg.ini"
144    RMDir "$APPDATA\glogg"
145
146    DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg"
147
148    ; Remove settings in the registry (from glogg < 0.9)
149    DeleteRegKey HKCU "Software\glogg"
150
151    ; Remove the file associations
152    ${unregisterExtension} ".log" "Log file"
153
154    DeleteRegKey HKCR "*\OpenWithList\glogg.exe"
155    DeleteRegKey HKCR ".txt\OpenWithList\glogg.exe"
156    DeleteRegKey HKCR ".Log\OpenWithList\glogg.exe"
157    DeleteRegKey HKCR ".cap\OpenWithList\glogg.exe"
158    DeleteRegKey HKCR "Applications\glogg.exe\shell\open\command"
159    DeleteRegKey HKCR "Applications\glogg.exe\shell\open"
160    DeleteRegKey HKCR "Applications\glogg.exe\shell"
161    DeleteRegKey HKCR "Applications\glogg.exe"
162
163    ; Remove the shortcut, if any
164    SetShellVarContext all
165    Delete "$SMPROGRAMS\glogg.lnk"
166SectionEnd
167