blob: 97e3f4eaff941b19f36c6eaab81a01b8fa3923a8 [file] [log] [blame]
Edric Milaret34eb9202015-05-14 12:36:41 -04001!define APPNAME "Ring"
2!define COMPANYNAME "Savoir-Faire Linux"
3!define DESCRIPTION "The Ring client for Windows"
4# These three must be integers
Guillaume Roguez5fac25a2016-03-16 22:49:09 -04005!define VERSIONMAJOR 1
6!define VERSIONMINOR 0
Guillaume Roguez106bcad2015-05-15 17:03:16 -04007!define VERSIONBUILD 0
Edric Milaret34eb9202015-05-14 12:36:41 -04008# These will be displayed by the "Click here for support information" link in "Add/Remove Programs"
9# It is possible to use "mailto:" links in here to open the email client
10!define HELPURL "https://projects.savoirfairelinux.com/projects/ring/wiki" # "Support Information" link
11!define UPDATEURL "http://ring.cx/en/documentation/windows-installation" # "Product Updates" link
12!define ABOUTURL "http://ring.cx/en#about" # "Publisher" link
13
14!include "MUI2.nsh"
15
16!define MUI_WELCOMEPAGE
17!define MUI_LICENSEPAGE
18!define MUI_DIRECTORYPAGE
19!define MUI_ABORTWARNING
20!define MUI_UNINSTALLER
21!define MUI_UNCONFIRMPAGE
Edric Milaretc37591c2015-12-11 11:02:58 -050022 !define MUI_FINISHPAGE_RUN
23 !define MUI_FINISHPAGE_RUN_TEXT "Launch Ring"
24 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
25
26!insertmacro MUI_PAGE_WELCOME
27!insertmacro MUI_PAGE_LICENSE "License.rtf"
28!insertmacro MUI_PAGE_DIRECTORY
29!insertmacro MUI_PAGE_INSTFILES
30!insertmacro MUI_PAGE_FINISH
Edric Milaret34eb9202015-05-14 12:36:41 -040031
Edric Milaretab851892016-09-13 11:29:48 -040032!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnWelcome
33!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.LeaveUnWelcome
34!insertmacro MUI_UNPAGE_WELCOME
35!insertmacro MUI_UNPAGE_INSTFILES
36
Edric Milaret34eb9202015-05-14 12:36:41 -040037!insertmacro MUI_LANGUAGE "English"
38
39RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
40
Edric Milaret34eb9202015-05-14 12:36:41 -040041# This will be in the installer/uninstaller's title bar
42Name "${COMPANYNAME} - ${APPNAME}"
43
Edric Milaret9e12e882015-05-21 11:52:05 -040044outFile "ring-windows-nightly.exe"
Edric Milaret34eb9202015-05-14 12:36:41 -040045
46!include LogicLib.nsh
47!include "FileFunc.nsh"
48
Anthony Léonard2c020842017-04-11 11:04:33 -040049Function StrRep
50 Exch $R4 ; $R4 = Replacement String
51 Exch
52 Exch $R3 ; $R3 = String to replace (needle)
53 Exch 2
54 Exch $R1 ; $R1 = String to do replacement in (haystack)
55 Push $R2 ; Replaced haystack
56 Push $R5 ; Len (needle)
57 Push $R6 ; len (haystack)
58 Push $R7 ; Scratch reg
59 StrCpy $R2 ""
60 StrLen $R5 $R3
61 StrLen $R6 $R1
62loop:
63 StrCpy $R7 $R1 $R5
64 StrCmp $R7 $R3 found
65 StrCpy $R7 $R1 1 ; - optimization can be removed if U know len needle=1
66 StrCpy $R2 "$R2$R7"
67 StrCpy $R1 $R1 $R6 1
68 StrCmp $R1 "" done loop
69found:
70 StrCpy $R2 "$R2$R4"
71 StrCpy $R1 $R1 $R6 $R5
72 StrCmp $R1 "" done loop
73done:
74 StrCpy $R3 $R2
75 Pop $R7
76 Pop $R6
77 Pop $R5
78 Pop $R2
79 Pop $R1
80 Pop $R4
81 Exch $R3
82FunctionEnd
83
84!macro _StrReplaceConstructor ORIGINAL_STRING TO_REPLACE REPLACE_BY
85 Push "${ORIGINAL_STRING}"
86 Push "${TO_REPLACE}"
87 Push "${REPLACE_BY}"
88 Call StrRep
89 Pop $0
90!macroend
91
92!define StrReplace '!insertmacro "_StrReplaceConstructor"'
93
Edric Milaret34eb9202015-05-14 12:36:41 -040094!macro VerifyUserIsAdmin
95UserInfo::GetAccountType
96pop $0
97${If} $0 != "admin" ;Require admin rights on NT4+
98 messageBox mb_iconstop "Administrator rights required!"
99 setErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
100 quit
101${EndIf}
102!macroend
103
Edric Milaret06d51572016-04-25 12:13:34 -0400104!include x64.nsh
105
Edric Milaret34eb9202015-05-14 12:36:41 -0400106function .onInit
107 setShellVarContext all
108 !insertmacro VerifyUserIsAdmin
Anthony Léonard2c020842017-04-11 11:04:33 -0400109 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation"
110 StrCmp $0 "" notfound
111 ${StrReplace} $0 "$\"" ""
112 StrCpy $INSTDIR $0
113 Goto done
114notfound:
Edric Milaret06d51572016-04-25 12:13:34 -0400115 StrCpy $INSTDIR "$PROGRAMFILES\${COMPANYNAME}\${APPNAME}"
116 ${If} ${ARCH} == "x64"
117 ${If} ${RunningX64}
118 StrCpy $INSTDIR "$PROGRAMFILES64\${COMPANYNAME}\${APPNAME}"
119 ${EndIf}
120 ${EndIf}
Anthony Léonard2c020842017-04-11 11:04:33 -0400121done:
Edric Milaret34eb9202015-05-14 12:36:41 -0400122functionEnd
123
Edric Milaretc37591c2015-12-11 11:02:58 -0500124Function LaunchLink
125 ExecShell "" "$DESKTOP\Ring.lnk"
126FunctionEnd
127
Edric Milaret34eb9202015-05-14 12:36:41 -0400128section "install"
Olivier SOLDANO1680f702016-11-30 16:11:10 -0500129 !addincludedir "../../NsProcess/Include"
130 !addplugindir "../../NsProcess/Plugin"
131 !include "nsProcess.nsh"
132 # Kill all remaining Ring processes
133 ${nsProcess::FindProcess} "Ring.exe" $R0
134 ${If} $R0 == 0
135 ${nsProcess::KillProcess} "Ring.exe" $R0
136 ${EndIf}
137 Sleep 500
138
Edric Milaret34eb9202015-05-14 12:36:41 -0400139 # Files for the install directory - to build the installer, these should be in the same directory as the install script (this file)
140 setOutPath $INSTDIR
141 # Files added here should be removed by the uninstaller (see section "uninstall")
Edric Milareta34e4ba2015-06-01 14:47:49 -0400142 file "Ring.exe"
Edric Milaret34eb9202015-05-14 12:36:41 -0400143 file "ring.ico"
144 file *.dll
145 setOutPath $INSTDIR\platforms
146 file platforms/*
147 setOutPath $INSTDIR\imageformats
148 file imageformats/*
149 setOutPath $INSTDIR\ringtones
150 file ringtones/*
Edric Milaret53ac6e52015-09-14 13:37:06 -0400151 setOutPath $INSTDIR\share\ring\translations
152 file share/ring/translations/*
153 setOutPath $INSTDIR\share\libringclient\translations
154 file share/libringclient/translations/*
Edric Milaret34eb9202015-05-14 12:36:41 -0400155
156 # Uninstaller - See function un.onInit and section "uninstall" for configuration
157 writeUninstaller "$INSTDIR\uninstall.exe"
158
Edric Milaret465a3142015-06-02 15:02:52 -0400159 SetOutPath $INSTDIR
Edric Milaret34eb9202015-05-14 12:36:41 -0400160 #Desktop
Edric Milareta34e4ba2015-06-01 14:47:49 -0400161 CreateShortCut "$DESKTOP\Ring.lnk" "$INSTDIR\Ring.exe" ""
Edric Milaret34eb9202015-05-14 12:36:41 -0400162
163 # Start Menu
164 createDirectory "$SMPROGRAMS\${COMPANYNAME}"
Edric Milareta34e4ba2015-06-01 14:47:49 -0400165 createShortCut "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk" "$INSTDIR\Ring.exe" "" "$INSTDIR\ring.ico"
Edric Milaret34eb9202015-05-14 12:36:41 -0400166
167 # Registry information for add/remove programs
168 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" ${APPNAME}
169 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
170 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
Anthony Léonard2c020842017-04-11 11:04:33 -0400171 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" $INSTDIR
Edric Milaret34eb9202015-05-14 12:36:41 -0400172 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\ring.ico$\""
173 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "${COMPANYNAME}"
174 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "HelpLink" "$\"${HELPURL}$\""
175 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLUpdateInfo" "$\"${UPDATEURL}$\""
176 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLInfoAbout" "$\"${ABOUTURL}$\""
177 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayVersion" "${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}"
178 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMajor" ${VERSIONMAJOR}
179 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMinor" ${VERSIONMINOR}
180 # There is no option for modifying or repairing the install
181 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoModify" 1
182 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoRepair" 1
183 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
184 IntFmt $0 "0x%08X" $0
185 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "EstimatedSize" "$0"
Edric Milaretfe390942015-08-04 13:41:03 -0400186
187 # Write ring protocol in registry
188 WriteRegStr HKCR "ring" "URL Protocol" "$\"$\""
189 WriteRegStr HKCR "ring\DefaultIcon" "" "$\"$INSTDIR\Ring.exe,1$\""
190 WriteRegStr HKCR "ring\shell\open\command" "" "$\"$INSTDIR\Ring.exe$\" $\"%1$\""
Edric Milaret34eb9202015-05-14 12:36:41 -0400191sectionEnd
192
193# Uninstaller
194
195function un.onInit
196 SetShellVarContext all
197
198 #Verify the uninstaller - last chance to back out
199 MessageBox MB_OKCANCEL "Permanantly remove ${APPNAME}?" IDOK next
200 Abort
201 next:
202 !insertmacro VerifyUserIsAdmin
203functionEnd
204
Edric Milaretab851892016-09-13 11:29:48 -0400205Function un.ModifyUnWelcome
206${NSD_CreateCheckbox} 120u -18u 50% 12u "Remove configuration and history files"
207Pop $1
208SetCtlColors $1 "" ${MUI_BGCOLOR}
209${NSD_Check} $1 ; Check it by default
210FunctionEnd
211
212Function un.LeaveUnWelcome
213${NSD_GetState} $1 $0
214${If} $0 <> 0
215 rmDir /r "$LOCALAPPDATA\${COMPANYNAME}"
216 rmDir /r "$PROFILE\.config\ring"
217 rmDir /r "$PROFILE\.cache\ring"
218 rmDir /r "$PROFILE\.local\share\ring"
219${EndIf}
220FunctionEnd
221
Edric Milaret34eb9202015-05-14 12:36:41 -0400222section "uninstall"
223
224 # Remove Start Menu launcher
225 delete "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk"
226 # Try to remove the Start Menu folder - this will only happen if it is empty
227 rmDir "$SMPROGRAMS\${COMPANYNAME}"
228
229 # Remove files
Edric Milareta34e4ba2015-06-01 14:47:49 -0400230 delete $INSTDIR\Ring.exe
Edric Milaret34eb9202015-05-14 12:36:41 -0400231 delete $INSTDIR\ring.ico
232 delete $INSTDIR\*.dll
233 rmDir /r $INSTDIR\platforms
234 rmDir /r $INSTDIR\imageformats
235 rmDir /r $INSTDIR\ringtones
Edric Milaret53ac6e52015-09-14 13:37:06 -0400236 rmDir /r $INSTDIR\share
Edric Milaret34eb9202015-05-14 12:36:41 -0400237
238 # Always delete uninstaller as the last action
239 delete $INSTDIR\uninstall.exe
240
241 # Try to remove the install directory - this will only happen if it is empty
242
243 rmDir $INSTDIR
244
245 # Remove uninstaller information from the registry
246 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}"
247sectionEnd