xref: /glogg/glogg.nsi (revision 803db976a3c3d04b7f91bf42fc0e6b93abf2065e)
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 release\libgcc_s_dw2-1.dll
64    File COPYING
65    File README
66
67    ; Create the 'sendto' link
68    CreateShortCut "$SENDTO\glogg.lnk" "$INSTDIR\glogg,exe" "" "$INSTDIR\glogg.exe" 0
69
70    ; Register as an otion (but not main handler) for some files (.txt, .Log, .cap)
71    WriteRegStr HKCR "Applications\glogg.exe" "" ""
72    WriteRegStr HKCR "Applications\glogg.exe\shell" "" "open"
73    WriteRegStr HKCR "Applications\glogg.exe\shell\open" "FriendlyAppName" "glogg"
74    WriteRegStr HKCR "Applications\glogg.exe\shell\open\command" "" '"$INSTDIR\glogg.exe" "%1"'
75    WriteRegStr HKCR "*\OpenWithList\glogg.exe" "" ""
76    WriteRegStr HKCR ".txt\OpenWithList\glogg.exe" "" ""
77    WriteRegStr HKCR ".Log\OpenWithList\glogg.exe" "" ""
78    WriteRegStr HKCR ".cap\OpenWithList\glogg.exe" "" ""
79
80    ; Register uninstaller
81    WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg"\
82"UninstallString" '"$INSTDIR\Uninstall.exe"'
83    WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg"\
84"InstallLocation" "$INSTDIR"
85    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "DisplayName" "glogg"
86    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "DisplayVersion" "${VERSION}"
87    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "NoModify" "1"
88    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\glogg" "NoRepair" "1"
89
90    ; Create uninstaller
91    WriteUninstaller "$INSTDIR\Uninstall.exe"
92SectionEnd
93
94Section "Qt4 Runtime libraries" qtlibs
95    SetOutPath $INSTDIR
96    File release\QtCore4.dll
97    File release\QtGui4.dll
98SectionEnd
99
100Section "Create Start menu shortcut" shortcut
101    SetShellVarContext all
102    CreateShortCut "$SMPROGRAMS\glogg.lnk" "$INSTDIR\glogg.exe" "" "$INSTDIR\glogg.exe" 0
103SectionEnd
104
105Section /o "Associate with .log files" associate
106    ${registerExtension} "$INSTDIR\glogg.exe" ".log" "Log file"
107SectionEnd
108
109# Descriptions
110!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
111    !insertmacro MUI_DESCRIPTION_TEXT ${glogg} "The core files required to use glogg."
112    !insertmacro MUI_DESCRIPTION_TEXT ${qtlibs} "Needed by glogg, you have to install these unless \
113you already have the Qt4 development kit installed."
114    !insertmacro MUI_DESCRIPTION_TEXT ${shortcut} "Create a shortcut in the Start menu for glogg."
115    !insertmacro MUI_DESCRIPTION_TEXT ${associate} "Make glogg the default viewer for .log files."
116!insertmacro MUI_FUNCTION_DESCRIPTION_END
117
118# Uninstaller
119Section "Uninstall"
120    Delete "$INSTDIR\Uninstall.exe"
121
122    Delete "$INSTDIR\glogg.exe"
123    Delete "$INSTDIR\README"
124    Delete "$INSTDIR\COPYING"
125    Delete "$INSTDIR\mingwm10.dll"
126    Delete "$INSTDIR\libgcc_s_dw2-1.dll"
127    Delete "$INSTDIR\QtCore4.dll"
128    Delete "$INSTDIR\QtGui4.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