xref: /glogg/glogg.nsi (revision 9e112cbd2199424e13f5104f45373ffdad7a6d69)
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 admin
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 COPYING
63    File README
64
65    ; Create the 'sendto' link
66    CreateShortCut "$SENDTO\glogg.lnk" "$INSTDIR\glogg,exe" "" "$INSTDIR\glogg.exe" 0
67
68    ; Register as an otion (but not main handler) for some files (.txt, .Log, .cap)
69    WriteRegStr HKCR "Applications\glogg.exe" "" ""
70    WriteRegStr HKCR "Applications\glogg.exe\shell" "" "open"
71    WriteRegStr HKCR "Applications\glogg.exe\shell\open" "FriendlyAppName" "glogg"
72    WriteRegStr HKCR "Applications\glogg.exe\shell\open\command" "" '"$INSTDIR\glogg.exe" "%1"'
73    WriteRegStr HKCR "*\OpenWithList\glogg.exe" "" ""
74    WriteRegStr HKCR ".txt\OpenWithList\glogg.exe" "" ""
75    WriteRegStr HKCR ".Log\OpenWithList\glogg.exe" "" ""
76    WriteRegStr HKCR ".cap\OpenWithList\glogg.exe" "" ""
77
78    ; Register uninstaller
79    WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg"\
80"UninstallString" '"$INSTDIR\Uninstall.exe"'
81    WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg"\
82"InstallLocation" "$INSTDIR"
83    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "DisplayName" "glogg"
84    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "DisplayVersion" "${VERSION}"
85    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "NoModify" "1"
86    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "NoRepair" "1"
87
88    ; Create uninstaller
89    WriteUninstaller "$INSTDIR\Uninstall.exe"
90SectionEnd
91
92Section "Qt4 Runtime libraries" qtlibs
93    SetOutPath $INSTDIR
94    File release\QtCore4.dll
95    File release\QtGui4.dll
96    File release\QtNetwork4.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_DESCRIPTION_TEXT ${associate} "Make glogg the default viewer for .log files."
115!insertmacro MUI_FUNCTION_DESCRIPTION_END
116
117# Uninstaller
118Section "Uninstall"
119    Delete "$INSTDIR\Uninstall.exe"
120
121    Delete "$INSTDIR\glogg.exe"
122    Delete "$INSTDIR\README"
123    Delete "$INSTDIR\COPYING"
124    Delete "$INSTDIR\mingwm10.dll"
125    Delete "$INSTDIR\libgcc_s_dw2-1.dll"
126    Delete "$INSTDIR\QtCore4.dll"
127    Delete "$INSTDIR\QtGui4.dll"
128    Delete "$INSTDIR\QtNetwork4.dll"
129    RMDir "$INSTDIR"
130
131    ; Remove settings in %appdata%
132    Delete "$APPDATA\glogg\glogg.ini"
133    RMDir "$APPDATA\glogg"
134
135    DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg"
136
137    ; Remove settings in the registry (from glogg < 0.9)
138    DeleteRegKey HKCU "Software\glogg"
139
140    ; Remove the file associations
141    ${unregisterExtension} ".log" "Log file"
142
143    DeleteRegKey HKCR "*\OpenWithList\glogg.exe"
144    DeleteRegKey HKCR ".txt\OpenWithList\glogg.exe"
145    DeleteRegKey HKCR ".Log\OpenWithList\glogg.exe"
146    DeleteRegKey HKCR ".cap\OpenWithList\glogg.exe"
147    DeleteRegKey HKCR "Applications\glogg.exe\shell\open\command"
148    DeleteRegKey HKCR "Applications\glogg.exe\shell\open"
149    DeleteRegKey HKCR "Applications\glogg.exe\shell"
150    DeleteRegKey HKCR "Applications\glogg.exe"
151
152    ; Remove the shortcut, if any
153    SetShellVarContext all
154    Delete "$SMPROGRAMS\glogg.lnk"
155SectionEnd
156