blob: 692ef792ecaa81b18f3c84e0437c8a2244fba09d [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/*
Anthony Léonard88f8d5b2017-08-10 14:42:55 -0400149 setOutPath $INSTDIR\sqldrivers
150 file sqldrivers/*
Edric Milaret34eb9202015-05-14 12:36:41 -0400151 setOutPath $INSTDIR\ringtones
152 file ringtones/*
Edric Milaret53ac6e52015-09-14 13:37:06 -0400153 setOutPath $INSTDIR\share\ring\translations
154 file share/ring/translations/*
155 setOutPath $INSTDIR\share\libringclient\translations
156 file share/libringclient/translations/*
Edric Milaret34eb9202015-05-14 12:36:41 -0400157
158 # Uninstaller - See function un.onInit and section "uninstall" for configuration
159 writeUninstaller "$INSTDIR\uninstall.exe"
160
Edric Milaret465a3142015-06-02 15:02:52 -0400161 SetOutPath $INSTDIR
Edric Milaret34eb9202015-05-14 12:36:41 -0400162 #Desktop
Edric Milareta34e4ba2015-06-01 14:47:49 -0400163 CreateShortCut "$DESKTOP\Ring.lnk" "$INSTDIR\Ring.exe" ""
Edric Milaret34eb9202015-05-14 12:36:41 -0400164
165 # Start Menu
166 createDirectory "$SMPROGRAMS\${COMPANYNAME}"
Edric Milareta34e4ba2015-06-01 14:47:49 -0400167 createShortCut "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk" "$INSTDIR\Ring.exe" "" "$INSTDIR\ring.ico"
Edric Milaret34eb9202015-05-14 12:36:41 -0400168
169 # Registry information for add/remove programs
170 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" ${APPNAME}
171 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
172 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
Anthony Léonard2c020842017-04-11 11:04:33 -0400173 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" $INSTDIR
Edric Milaret34eb9202015-05-14 12:36:41 -0400174 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\ring.ico$\""
175 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "${COMPANYNAME}"
176 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "HelpLink" "$\"${HELPURL}$\""
177 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLUpdateInfo" "$\"${UPDATEURL}$\""
178 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "URLInfoAbout" "$\"${ABOUTURL}$\""
179 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayVersion" "${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}"
180 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMajor" ${VERSIONMAJOR}
181 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "VersionMinor" ${VERSIONMINOR}
182 # There is no option for modifying or repairing the install
183 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoModify" 1
184 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "NoRepair" 1
185 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
186 IntFmt $0 "0x%08X" $0
187 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "EstimatedSize" "$0"
Edric Milaretfe390942015-08-04 13:41:03 -0400188
189 # Write ring protocol in registry
190 WriteRegStr HKCR "ring" "URL Protocol" "$\"$\""
191 WriteRegStr HKCR "ring\DefaultIcon" "" "$\"$INSTDIR\Ring.exe,1$\""
192 WriteRegStr HKCR "ring\shell\open\command" "" "$\"$INSTDIR\Ring.exe$\" $\"%1$\""
Edric Milaret34eb9202015-05-14 12:36:41 -0400193sectionEnd
194
195# Uninstaller
196
197function un.onInit
198 SetShellVarContext all
199
200 #Verify the uninstaller - last chance to back out
Anthony Léonard6572a942017-06-26 14:23:08 -0400201 MessageBox MB_OKCANCEL "Permanently remove ${APPNAME}?" IDOK next
Edric Milaret34eb9202015-05-14 12:36:41 -0400202 Abort
203 next:
204 !insertmacro VerifyUserIsAdmin
205functionEnd
206
Edric Milaretab851892016-09-13 11:29:48 -0400207Function un.ModifyUnWelcome
208${NSD_CreateCheckbox} 120u -18u 50% 12u "Remove configuration and history files"
209Pop $1
210SetCtlColors $1 "" ${MUI_BGCOLOR}
211${NSD_Check} $1 ; Check it by default
212FunctionEnd
213
214Function un.LeaveUnWelcome
215${NSD_GetState} $1 $0
216${If} $0 <> 0
217 rmDir /r "$LOCALAPPDATA\${COMPANYNAME}"
218 rmDir /r "$PROFILE\.config\ring"
219 rmDir /r "$PROFILE\.cache\ring"
220 rmDir /r "$PROFILE\.local\share\ring"
221${EndIf}
222FunctionEnd
223
Edric Milaret34eb9202015-05-14 12:36:41 -0400224section "uninstall"
225
226 # Remove Start Menu launcher
227 delete "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk"
228 # Try to remove the Start Menu folder - this will only happen if it is empty
229 rmDir "$SMPROGRAMS\${COMPANYNAME}"
230
231 # Remove files
Edric Milareta34e4ba2015-06-01 14:47:49 -0400232 delete $INSTDIR\Ring.exe
Edric Milaret34eb9202015-05-14 12:36:41 -0400233 delete $INSTDIR\ring.ico
234 delete $INSTDIR\*.dll
235 rmDir /r $INSTDIR\platforms
236 rmDir /r $INSTDIR\imageformats
237 rmDir /r $INSTDIR\ringtones
Edric Milaret53ac6e52015-09-14 13:37:06 -0400238 rmDir /r $INSTDIR\share
Edric Milaret34eb9202015-05-14 12:36:41 -0400239
240 # Always delete uninstaller as the last action
241 delete $INSTDIR\uninstall.exe
242
243 # Try to remove the install directory - this will only happen if it is empty
244
245 rmDir $INSTDIR
246
247 # Remove uninstaller information from the registry
248 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}"
249sectionEnd