Project

General

Profile

audacious.nsi.in

Carlo Bramini, September 05, 2013 09:27

 
1
;============================
2
; audacious.nsis.in
3
;
4
; Copyright 2013 Carlo Bramini
5
;
6
; Redistribution and use in source and binary forms, with or without
7
; modification, are permitted provided that the following conditions are met:
8
;
9
; 1. Redistributions of source code must retain the above copyright notice,
10
;    this list of conditions, and the following disclaimer.
11
;
12
; 2. Redistributions in binary form must reproduce the above copyright notice,
13
;    this list of conditions, and the following disclaimer in the documentation
14
;    provided with the distribution.
15
;
16
; This software is provided "as is" and without any warranty, express or
17
; implied. In no event shall the authors be liable for any damages arising from
18
; the use of this software.
19
;============================
20

    
21
; Gain the rights to write in protected directories
22
RequestExecutionLevel admin
23

    
24
; Import global macro
25
!include "MUI2.nsh"
26

    
27
; Import support for multi-user
28
!define MULTIUSER_EXECUTIONLEVEL Highest
29
!define MULTIUSER_MUI
30
!include MultiUser.nsh
31

    
32
Function .onInit
33
  !insertmacro MULTIUSER_INIT
34
FunctionEnd
35

    
36
Function un.onInit
37
  !insertmacro MULTIUSER_UNINIT
38
FunctionEnd
39

    
40
; Import version number from configure
41
!define VERSION "@VERSION@"
42

    
43
; Declare package name
44
!define NAME "Audacious ${VERSION}"
45

    
46
; The name of the installer
47
Name "${NAME}"
48

    
49
; The name of the package
50
!define PACKAGE "Audacious-${VERSION}"
51

    
52
; The name of the uninstaller
53
!define UNINSTALLER "$INSTDIR\Uninstall_audacious.exe"
54

    
55
; The path with the sources
56
!define AUD_SOURCES "..\${PACKAGE}"
57

    
58
; The path with the NSIS resources
59
!define AUD_NSIS "${AUD_SOURCES}\contrib\win32"
60

    
61
; The file to write
62
OutFile "${PACKAGE}.exe"
63

    
64
; The default installation directory
65
InstallDir $PROGRAMFILES\${PACKAGE}
66

    
67
; Assign icon to installer
68
!define MUI_ICON "${AUD_NSIS}\audacious.ico"
69

    
70
; Assign icon to un-installer (TODO)
71
;!define MUI_UNICON "${AUD_NSIS}\audacious.ico"
72

    
73
; Customize the pages
74
!define MUI_COMPONENTSPAGE_SMALLDESC
75

    
76
; Use a customized header bitmap (TODO)
77
;!define MUI_HEADERIMAGE
78
;!define MUI_HEADERIMAGE_BITMAP  "${AUD_NSIS}\header.bmp"
79

    
80
; Use a customized WELCOME bitmap (TODO)
81
;!define MUI_WELCOMEFINISHPAGE_BITMAP "${AUD_NSIS}\welcome.bmp"
82

    
83
; Use a customized FINISH bitmap (TODO)
84
;!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${AUD_NSIS}\finish.bmp"
85

    
86
; Install common pages
87
!insertmacro MUI_PAGE_WELCOME
88
!insertmacro MUI_PAGE_LICENSE share\audacious\COPYING
89
!insertmacro MULTIUSER_PAGE_INSTALLMODE
90
!insertmacro MUI_PAGE_COMPONENTS
91
!insertmacro MUI_PAGE_DIRECTORY
92
!insertmacro MUI_PAGE_INSTFILES
93
!insertmacro MUI_PAGE_FINISH
94

    
95
!insertmacro MUI_UNPAGE_CONFIRM
96
!insertmacro MUI_UNPAGE_INSTFILES
97
!insertmacro MUI_UNPAGE_FINISH
98

    
99
; Languages
100
 
101
!insertmacro MUI_LANGUAGE "English"
102

    
103
;Installer Sections
104

    
105
Section "Audacious (required)" SecPlayer
106
  SectionIn 1 2 RO
107

    
108
  SetOverwrite on
109

    
110
  SetOutPath "$INSTDIR\bin"
111
  File /r "bin\*.*"
112

    
113
  SetOutPath "$INSTDIR\etc"
114
  File /r "etc\*.*"
115

    
116
  SetOutPath "$INSTDIR\lib"
117
  File /r "lib\*.*"
118

    
119
  SetOutPath "$INSTDIR\share"
120
  File /r "share\*.*"
121

    
122
  ; create uninstaller
123
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "DisplayName" "${NAME}"
124
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "UninstallString" '"${UNINSTALLER}"'
125
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "NoModify" 1
126
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "NoRepair" 1
127
  WriteUninstaller ${UNINSTALLER}
128

    
129
SectionEnd
130

    
131
Section "Add to the Start Menu" SecStartMenu
132
  SectionIn 1 2
133

    
134
  ; Create shortcuts
135
  CreateDirectory "$SMPROGRAMS\${NAME}"
136
  CreateShortCut "$SMPROGRAMS\${NAME}\${PACKAGE}.lnk" "$INSTDIR\bin\audacious.exe"
137
  CreateShortCut "$SMPROGRAMS\${NAME}\Uninstall.lnk" "${UNINSTALLER}"
138

    
139
SectionEnd
140

    
141
Section "Add link to desktop" SecDesktopLink
142
  SectionIn 1 2
143

    
144
  CreateShortCut "$DESKTOP\${NAME}.lnk" "$INSTDIR\bin\audacious.exe"
145

    
146
SectionEnd
147

    
148
Section "Uninstall"
149
  Delete ${UNINSTALLER} ; delete self (see explanation below why this works)
150

    
151
  Delete "$SMPROGRAMS\${NAME}\*.*"
152
  RMDir  "$SMPROGRAMS\${NAME}"
153
  Delete "$DESKTOP\${NAME}.lnk"
154

    
155
  RMDir /r $INSTDIR\bin
156
  RMDir /r $INSTDIR\etc
157
  RMDir /r $INSTDIR\lib
158
  RMDir /r $INSTDIR\share
159
  RMDir $INSTDIR
160

    
161
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
162
SectionEnd