summaryrefslogtreecommitdiff
path: root/src/installer.nsi
blob: c98c505659a582a71b01db67b124b507fffd47e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
!include "MUI2.nsh"
;!include "FileAssociation.nsh"
;!include "ProtocolAssociation.nsh"
!include "x64.nsh"

;--------------------------------

; The name of the installer
Name "Transmission Remote GTK"

; The file to write
!ifndef REV
OutFile "transmission-remote-gtk-0.6.1-installer.exe"
!else
OutFile "transmission-remote-gtk-${REV}-installer.exe"
!endif

; The default installation directory
!define ProgramFilesDir "Transmission Remote GTK"

RequestExecutionLevel user

;--------------------------------

XPStyle on

Var StartMenuFolder

!define MUI_ICON "transmission_large.ico"
!define MUI_UNICON "transmission_large.ico"
!define MUI_HEADERIMAGE
;!define MUI_HEADERIMAGE_BITMAP "logo.bmp"
;!define MUI_WELCOMEFINISHPAGE_BITMAP "nsis_wizard.bmp"
;!define MUI_UNWELCOMEFINISHPAGE_BITMAP "nsis_wizard.bmp"
;!define MUI_COMPONENTSPAGE_CHECKBITMAP "${NSISDIR}\Contrib\Graphics\Checks\colorful.bmp"
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_ABORTWARNING

;!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt"
;!define MUI_FINISHPAGE_SHOWREADME_TEXT "Show ReadMe"
;!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED

; Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "..\COPYING"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH

;--------------------------------

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL

; English
LangString NAME_SecTransmissionRemoteGTK ${LANG_ENGLISH} "Transmission Remote GTK (required)"
LangString DESC_SecTransmissionRemoteGTK ${LANG_ENGLISH} "The application."
LangString NAME_SecGlibGtkEtc ${LANG_ENGLISH} "Glib, GTK, and other dependencies (recommended)."
LangString DESC_SecGlibGtkEtc ${LANG_ENGLISH} "If unset, you'll need to install these yourself."
LangString NAME_SecDesktopIcon ${LANG_ENGLISH} "Create icon on desktop"
LangString DESC_SecDesktopIcon ${LANG_ENGLISH} "If set, a shortcut for Transmission Remote will be created on the desktop."
;LangString NAME_SecFiletypeAssociations ${LANG_ENGLISH} "Register Filetype Associations"
;LangString DESC_SecFiletypeAssociations ${LANG_ENGLISH} "Register Associations to Transmission Remote"
;LangString NAME_SecRegiterTorrent ${LANG_ENGLISH} "Register .torrent"
;LangString DESC_SecRegiterTorrent ${LANG_ENGLISH} "Register .torrent to Transmission Remote"
;LangString NAME_SecRegiterMagnet ${LANG_ENGLISH} "Register Magnet URI"
;LangString DESC_SecRegiterMagnet ${LANG_ENGLISH} "Register Magnet URI to Transmission Remote"
;LangString DESC_SecGeoIPDatabase ${LANG_ENGLISH} "GeoIP database"
;LangString NAME_SecLanguages ${LANG_ENGLISH} "Languages"
;LangString DESC_SecLanguages ${LANG_ENGLISH} "Languages for Transmission Remote"

;--------------------------------

; The stuff to install
Section $(NAME_SecTransmissionRemoteGTK) SecTransmissionRemoteGTK
  SectionIn RO
  
  SetOutPath $INSTDIR
  
  File /oname=README.TXT "..\README"
  File /oname=COPYING.TXT "..\COPYING"

  ; Set output path to the installation directory.
  SetOutPath $INSTDIR\bin
  
  ; Put file there
  File ".libs\transmission-remote-gtk.exe"
  
  SetOutPath $INSTDIR\etc\gtk-2.0
  
  File "..\..\gtk-2.24-win32-bin\etc\gtk-2.0\gtkrc"
  
  SetOutPath $INSTDIR\share\themes\MS-Windows\gtk-2.0
  
  File "..\..\gtk-2.24-win32-bin\share\themes\MS-Windows\gtk-2.0\gtkrc"

  !ifndef PORTABLE
  ; Write the installation path into the registry
  WriteRegStr HKLM "SOFTWARE\TransmissionRemoteGTK" "Install_Dir" "$INSTDIR"
  
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TransmissionRemoteGTK" "DisplayName" "Transmission Remote GTK"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TransmissionRemoteGTK" "Publisher" "Alan Fitton"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TransmissionRemoteGTK" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TransmissionRemoteGTK" "DisplayIcon" "$INSTDIR\bin\transmission-remote-gtk.exe,0"
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TransmissionRemoteGTK" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TransmissionRemoteGTK" "NoRepair" 1
  WriteUninstaller "uninstall.exe"
!endif
  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
    SetShellVarContext current
    CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
    CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Transmission Remote GTK.lnk" "$INSTDIR\bin\transmission-remote-gtk.exe" "" "$INSTDIR\bin\transmission-remote-gtk.exe" 0 
!ifndef PORTABLE
    SetShellVarContext all
    CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
    CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
    CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Transmission Remote GTK.lnk" "$INSTDIR\bin\transmission-remote-gtk.exe" "" "$INSTDIR\bin\transmission-remote-gtk.exe" 0 
!endif
  !insertmacro MUI_STARTMENU_WRITE_END

SectionEnd

Section $(NAME_SecGlibGtkEtc) SecGlibGtkEtc
  SetOutPath $INSTDIR\bin

  File "..\..\gtk-2.24-win32-bin\bin\freetype6.dll"
  File "..\..\gtk-2.24-win32-bin\bin\intl.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libatk-1.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libcairo-2.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libcurl-4.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libexpat-1.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libfontconfig-1.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libgdk-win32-2.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libgdk_pixbuf-2.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libgio-2.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libglib-2.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libgmodule-2.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libgobject-2.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libgthread-2.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libgtk-win32-2.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libjson-glib-1.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libpango-1.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libpangocairo-1.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libpangoft2-1.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libpangowin32-1.0-0.dll"
  File "..\..\gtk-2.24-win32-bin\bin\libpng14-14.dll"
  File "..\..\gtk-2.24-win32-bin\bin\zlib1.dll"  
    
  SetOutPath $INSTDIR\lib\gtk-2.0\2.10.0\engines
	
  File "..\..\gtk-2.24-win32-bin\lib\gtk-2.0\2.10.0\engines\libpixmap.dll"
  File "..\..\gtk-2.24-win32-bin\lib\gtk-2.0\2.10.0\engines\libwimp.dll"
  
  SetOutPath $INSTDIR\lib\gtk-2.0\modules
  
  File "..\..\gtk-2.24-win32-bin\lib\gtk-2.0\modules\libgail.dll"
SectionEnd

; Optional section (can be disabled by the user)

Section /o $(NAME_SecDesktopIcon) SecDesktopIcon
  SetShellVarContext current
  SetOutPath "$INSTDIR\bin"
  CreateShortCut "$DESKTOP\Transmission Remote GTK.lnk" "$INSTDIR\bin\transmission-remote-gtk.exe" "" "$INSTDIR\bin\transmission-remote-gtk.exe" 0
SectionEnd

;Section "GeoIP Database" SecGeoIPDatabase
;  SetOutPath "$INSTDIR"
;  File "GeoIP.dat"
;SectionEnd

;!ifndef PORTABLE
;SubSection $(NAME_SecFiletypeAssociations) SecFiletypeAssociations

;  Section $(NAME_SecRegiterTorrent) SecRegiterTorrent
;    ${registerExtension} "$INSTDIR\Transmission Remote.exe" ".torrent" "Transmission Remote Torrent"
;  SectionEnd

;  Section $(NAME_SecRegiterMagnet) SecRegiterMagnet
;    ${registerProtocol} "$INSTDIR\Transmission Remote.exe" "magnet" "Magnet URI"
;  SectionEnd

;SubSectionEnd
;!endif

; Translation

;SectionGroup $(NAME_SecLanguages) SecLanguages

;  Section /o "Brazilian Portuguese" SecLanguagesBrazilianPortuguese
;    CreateDirectory "$INSTDIR\pt-BR"
;    SetOutPath "$INSTDIR\pt-BR"
;    File "TransmissionClientNew\bin\Release\pt-BR\Transmission Remote.resources.dll"
;  SectionEnd

 ; Section /o "Chinese" SecLanguagesChinese
 ;   CreateDirectory "$INSTDIR\zh-CN"
 ;   SetOutPath "$INSTDIR\zh-CN"
 ;   File "TransmissionClientNew\bin\Release\zh-CN\Transmission Remote.resources.dll"
 ; SectionEnd
  
;SectionGroupEnd

;--------------------------------

; Uninstaller

Section "Uninstall"

;!ifndef PORTABLE
  ; Unregister File Association
;  ${unregisterExtension} ".torrent" "Transmission Remote Torrent"
;  ${unregisterProtocol} "magnet" "Magnet URI"
  
;!endif

  ; Remove files and uninstaller
  Delete "$INSTDIR\COPYING.txt"
  Delete "$INSTDIR\README.txt"
  Delete "$INSTDIR\uninstall.exe"
  Delete "$INSTDIR\bin\transmission-remote-gtk.exe"
  Delete "$INSTDIR\bin\freetype6.dll"
  Delete "$INSTDIR\bin\intl.dll"
  Delete "$INSTDIR\bin\libatk-1.0-0.dll"
  Delete "$INSTDIR\bin\libcairo-2.dll"
  Delete "$INSTDIR\bin\libcurl-4.dll"
  Delete "$INSTDIR\bin\libexpat-1.dll"
  Delete "$INSTDIR\bin\libfontconfig-1.dll"
  Delete "$INSTDIR\bin\libgdk-win32-2.0-0.dll"
  Delete "$INSTDIR\bin\libgdk_pixbuf-2.0-0.dll"
  Delete "$INSTDIR\bin\libgio-2.0-0.dll"
  Delete "$INSTDIR\bin\libglib-2.0-0.dll"
  Delete "$INSTDIR\bin\libgmodule-2.0-0.dll"
  Delete "$INSTDIR\bin\libgobject-2.0-0.dll"
  Delete "$INSTDIR\bin\libgthread-2.0-0.dll"
  Delete "$INSTDIR\bin\libgtk-win32-2.0-0.dll"
  Delete "$INSTDIR\bin\libjson-glib-1.0-0.dll"
  Delete "$INSTDIR\bin\libpango-1.0-0.dll"
  Delete "$INSTDIR\bin\libpangocairo-1.0-0.dll"
  Delete "$INSTDIR\bin\libpangoft2-1.0-0.dll"
  Delete "$INSTDIR\bin\libpangowin32-1.0-0.dll"
  Delete "$INSTDIR\bin\libpng14-14.dll"
  Delete "$INSTDIR\bin\zlib1.dll"  
  Delete "$INSTDIR\lib\gtk-2.0\2.10.0\engines\libpixmap.dll"
  Delete "$INSTDIR\lib\gtk-2.0\2.10.0\engines\libwimp.dll"
  Delete "$INSTDIR\lib\gtk-2.0\modules\libgail.dll"
  Delete "$INSTDIR\etc\gtk-2.0\gtkrc"
  Delete "$INSTDIR\share\themes\MS-Windows\gtk-2.0\gtkrc"
  
  ; Remove shortcuts, if any
  !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
  SetShellVarContext current
  Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
  RMDir "$SMPROGRAMS\$StartMenuFolder"
!ifndef PORTABLE
  SetShellVarContext all
  Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
  RMDir "$SMPROGRAMS\$StartMenuFolder"
!endif

  ; Remove directories used
  RMDir "$INSTDIR\share\themes\MS-Windows\gtk-2.0"
  RMDir "$INSTDIR\share\themes\MS-Windows"
  RMDir "$INSTDIR\share\themes"
  RMDir "$INSTDIR\share"
  RMDir "$INSTDIR\etc\gtk-2.0"
  RMDir "$INSTDIR\etc"
  RMDir "$INSTDIR\lib\gtk-2.0\modules"
  RMDir "$INSTDIR\lib\gtk-2.0\2.10.0\engines"
  RMDir "$INSTDIR\lib\gtk-2.0\2.10.0"
  RMDir "$INSTDIR\lib\gtk-2.0"
  RMDir "$INSTDIR\lib"
  RMDir "$INSTDIR\bin"
  RMDir "$INSTDIR"

  DeleteRegKey /ifempty HKCU "SOFTWARE\TransmissionRemoteGTKGTK"
!ifndef PORTABLE
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TransmissionRemoteGTK"
!endif

SectionEnd

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SecTransmissionRemoteGTK} $(DESC_SecTransmissionRemoteGTK)
  !insertmacro MUI_DESCRIPTION_TEXT ${SecGlibGtkEtc} $(DESC_SecGlibGtkEtc)
  !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopIcon} $(DESC_SecDesktopIcon)
;  !insertmacro MUI_DESCRIPTION_TEXT ${SecFiletypeAssociations} $(DESC_SecFiletypeAssociations)
;  !insertmacro MUI_DESCRIPTION_TEXT ${SecGeoIPDatabase} $(DESC_SecGeoIPDatabase)
;  !insertmacro MUI_DESCRIPTION_TEXT ${SecLanguages} $(DESC_SecLanguages)
;  !insertmacro MUI_DESCRIPTION_TEXT ${SecRegiterTorrent} $(DESC_SecRegiterTorrent)
;  !insertmacro MUI_DESCRIPTION_TEXT ${SecRegiterMagnet} $(DESC_SecRegiterMagnet)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

Function .onInit
  System::Call 'kernel32::CreateMutexA(i 0, i 0, t "Transmission Remote GTK") ?e'
  Pop $R0
  StrCmp $R0 0 +3
    MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
    Abort

  !insertmacro MUI_LANGDLL_DISPLAY
!ifdef PORTABLE
  StrCpy $INSTDIR "\${ProgramFilesDir}"
!else
  ${If} ${RunningX64}
      StrCpy $INSTDIR "$PROGRAMFILES64\${ProgramFilesDir}"
  ${Else}
      StrCpy $INSTDIR "$PROGRAMFILES\${ProgramFilesDir}"
  ${Endif}
!endif
FunctionEnd