bump stable to 0.1.2.19
[tor.git] / contrib / tor-mingw.nsi.in
bloba1acad254c45051cbc6d246b6c5f6893012f894a
1 ;tor.nsi - A basic win32 installer for Tor
2 ; Originally written by J Doe.
3 ; Modified by Steve Topletz
4 ; See the Tor LICENSE for licensing information
5 ;-----------------------------------------
7 !include "MUI.nsh"
8 !include "LogicLib.nsh"
9 !include "FileFunc.nsh"
10 !insertmacro GetParameters
12 !define VERSION "0.1.2.19"
13 !define INSTALLER "tor-${VERSION}-win32.exe"
14 !define WEBSITE "https://www.torproject.org/"
15 !define LICENSE "LICENSE"
16 !define BIN "..\bin" ;BIN is where it expects to find tor.exe, tor-resolve.exe
19 SetCompressor /SOLID LZMA ;Tighter compression
20 RequestExecutionLevel user ;Updated for Vista compatibility
21 OutFile ${INSTALLER}
22 InstallDir $PROGRAMFILES\Tor
23 SetOverWrite ifnewer
24 Name "Tor"
25 Caption "Tor ${VERSION} Setup"
26 BrandingText "The Onion Router"
27 CRCCheck on
28 XPStyle on
29 VIProductVersion "${VERSION}"
30 VIAddVersionKey "ProductName" "The Onion Router: Tor"
31 VIAddVersionKey "Comments" "${WEBSITE}"
32 VIAddVersionKey "LegalTrademarks" "Three line BSD"
33 VIAddVersionKey "LegalCopyright" "©2004-2008, Roger Dingledine, Nick Mathewson"
34 VIAddVersionKey "FileDescription" "Tor is an implementation of Onion Routing. You can read more at ${WEBSITE}"
35 VIAddVersionKey "FileVersion" "${VERSION}"
37 !define MUI_WELCOMEPAGE_TITLE "Welcome to the Tor Setup Wizard"
38 !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Tor ${VERSION}.\r\n\r\nIf you have previously installed Tor and it is currently running, please exit Tor first before continuing this installation.\r\n\r\n$_CLICK"
39 !define MUI_ABORTWARNING
40 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\win-install.ico"
41 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\win-uninstall.ico"
42 !define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\win.bmp"
43 !define MUI_FINISHPAGE_RUN "$INSTDIR\tor.exe"
44 !define MUI_FINISHPAGE_LINK "Visit the Tor website for the latest updates."
45 !define MUI_FINISHPAGE_LINK_LOCATION ${WEBSITE}
47 !insertmacro MUI_PAGE_WELCOME
48 ; There's no point in having a clickthrough license: Our license adds
49 ; certain rights, but doesn't remove them.
50 ; !insertmacro MUI_PAGE_LICENSE "${LICENSE}"
51 !insertmacro MUI_PAGE_COMPONENTS
52 !insertmacro MUI_PAGE_DIRECTORY
53 !insertmacro MUI_PAGE_INSTFILES
54 !insertmacro MUI_PAGE_FINISH
55 !insertmacro MUI_UNPAGE_WELCOME
56 !insertmacro MUI_UNPAGE_CONFIRM
57 !insertmacro MUI_UNPAGE_INSTFILES
58 !insertmacro MUI_UNPAGE_FINISH
59 !insertmacro MUI_LANGUAGE "English"
61 Var CONFIGDIR
62 Var CONFIGFILE
64 Function .onInit
65 Call ParseCmdLine
66 FunctionEnd
68 ;Sections
69 ;--------
71 Section "Tor" Tor
72 ;Files that have to be installed for tor to run and that the user
73 ;cannot choose not to install
74 SectionIn RO
75 SetOutPath $INSTDIR
76 Call ExtractBinaries
77 Call ExtractIcon
78 WriteINIStr "$INSTDIR\Tor Website.url" "InternetShortcut" "URL" ${WEBSITE}
80 StrCpy $CONFIGFILE "torrc"
81 StrCpy $CONFIGDIR $APPDATA\Tor
82 ; ;If $APPDATA isn't valid here (Early win95 releases with no updated
83 ; ; shfolder.dll) then we put it in the program directory instead.
84 ; StrCmp $APPDATA "" "" +2
85 ; StrCpy $CONFIGDIR $INSTDIR
86 SetOutPath $CONFIGDIR
87 ;If there's already a torrc config file, ask if they want to
88 ;overwrite it with the new one.
89 ${If} ${FileExists} "$CONFIGDIR\torrc"
90 MessageBox MB_ICONQUESTION|MB_YESNO "You already have a Tor config file.$\r$\nDo you want to overwrite it with the default sample config file?" IDYES Yes IDNO No
91 Yes:
92 Delete $CONFIGDIR\torrc
93 Goto Next
94 No:
95 StrCpy $CONFIGFILE "torrc.sample"
96 Next:
97 ${EndIf}
98 File /oname=$CONFIGFILE "..\src\config\torrc.sample"
99 SectionEnd
101 Section "Documents" Docs
102 Call ExtractDocuments
103 SectionEnd
105 SubSection /e "Shortcuts" Shortcuts
107 Section "Start Menu" StartMenu
108 SetOutPath $INSTDIR
109 ${If} ${FileExists} "$SMPROGRAMS\Tor\*.*"
110 RMDir /r "$SMPROGRAMS\Tor"
111 ${EndIf}
112 Call CreateTorLinks
113 ${If} ${FileExists} "$INSTDIR\Documents\*.*"
114 Call CreateDocLinks
115 ${EndIf}
116 endifdocs:
117 SectionEnd
119 Section "Desktop" Desktop
120 SetOutPath $INSTDIR
121 CreateShortCut "$DESKTOP\Tor.lnk" "$INSTDIR\tor.exe" "" "$INSTDIR\tor.ico"
122 SectionEnd
124 Section /o "Run at startup" Startup
125 SetOutPath $INSTDIR
126 CreateShortCut "$SMSTARTUP\Tor.lnk" "$INSTDIR\tor.exe" "" "$INSTDIR\tor.ico" "" SW_SHOWMINIMIZED
127 SectionEnd
129 SubSectionEnd
131 Section "Uninstall"
132 Call un.InstallPackage
133 SectionEnd
135 Section -End
136 WriteUninstaller "$INSTDIR\Uninstall.exe"
137 ;The registry entries simply add the Tor uninstaller to the Windows
138 ;uninstall list.
139 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tor" "DisplayName" "Tor (remove only)"
140 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tor" "UninstallString" '"$INSTDIR\Uninstall.exe"'
141 SectionEnd
143 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
144 !insertmacro MUI_DESCRIPTION_TEXT ${Tor} "The core executable and config files needed for Tor to run."
145 !insertmacro MUI_DESCRIPTION_TEXT ${Docs} "Documentation about Tor."
146 !insertmacro MUI_DESCRIPTION_TEXT ${ShortCuts} "Shortcuts to easily start Tor"
147 !insertmacro MUI_DESCRIPTION_TEXT ${StartMenu} "Shortcuts to access Tor and it's documentation from the Start Menu"
148 !insertmacro MUI_DESCRIPTION_TEXT ${Desktop} "A shortcut to start Tor from the desktop"
149 !insertmacro MUI_DESCRIPTION_TEXT ${Startup} "Launches Tor automatically at startup in a minimized window"
150 !insertmacro MUI_FUNCTION_DESCRIPTION_END
152 ;####################Functions#########################
154 Function ExtractBinaries
155 File "${BIN}\tor.exe"
156 File "${BIN}\tor-resolve.exe"
157 FunctionEnd
159 Function ExtractIcon
160 File "${BIN}\tor.ico"
161 FunctionEnd
163 Function ExtractSpecs
164 ;File "doc\FAQ"
165 File "..\doc\HACKING"
166 File "..\doc\spec\address-spec.txt"
167 File "..\doc\spec\control-spec.txt"
168 File "..\doc\spec\control-spec-v0.txt"
169 File "..\doc\spec\dir-spec.txt"
170 File "..\doc\spec\dir-spec-v1.txt"
171 File "..\doc\spec\path-spec.txt"
172 File "..\doc\spec\rend-spec.txt"
173 File "..\doc\spec\socks-extensions.txt"
174 File "..\doc\spec\tor-spec.txt"
175 File "..\doc\spec\version-spec.txt"
176 FunctionEnd
178 Function ExtractHTML
179 File "..\doc\tor-resolve.html"
180 File "..\doc\tor-reference.html"
181 FunctionEnd
183 Function ExtractDesignDocs
184 File "..\doc\design-paper\tor-design.pdf"
185 FunctionEnd
187 Function ExtractReleaseDocs
188 File "..\README"
189 File "..\AUTHORS"
190 File "..\ChangeLog"
191 File "..\LICENSE"
192 FunctionEnd
194 Function ExtractDocuments
195 SetOutPath "$INSTDIR\Documents"
196 Call ExtractSpecs
197 Call ExtractHTML
198 Call ExtractDesignDocs
199 Call ExtractReleaseDocs
200 FunctionEnd
202 Function un.InstallFiles
203 Delete "$DESKTOP\Tor.lnk"
204 Delete "$INSTDIR\tor.exe"
205 Delete "$INSTDIR\tor-resolve.exe"
206 Delete "$INSTDIR\Tor Website.url"
207 Delete "$INSTDIR\torrc"
208 Delete "$INSTDIR\torrc.sample"
209 Delete "$INSTDIR\tor.ico"
210 Delete "$SMSTARTUP\Tor.lnk"
211 Delete "$INSTDIR\Uninstall.exe"
212 FunctionEnd
214 Function un.InstallDirectories
215 ${If} $CONFIGDIR == $INSTDIR
216 RMDir /r $CONFIGDIR
217 ${EndIf}
218 RMDir /r "$INSTDIR\Documents"
219 RMDir $INSTDIR
220 RMDir /r "$SMPROGRAMS\Tor"
221 RMDir /r "$APPDATA\Tor"
222 FunctionEnd
224 Function un.WriteRegistry
225 DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Tor"
226 FunctionEnd
228 Function un.InstallPackage
229 Call un.InstallFiles
230 Call un.InstallDirectories
231 Call un.WriteRegistry
232 FunctionEnd
234 Function CreateTorLinks
235 CreateDirectory "$SMPROGRAMS\Tor"
236 CreateShortCut "$SMPROGRAMS\Tor\Tor.lnk" "$INSTDIR\tor.exe" "" "$INSTDIR\tor.ico"
237 CreateShortCut "$SMPROGRAMS\Tor\Torrc.lnk" "Notepad.exe" "$CONFIGDIR\torrc"
238 CreateShortCut "$SMPROGRAMS\Tor\Tor Website.lnk" "$INSTDIR\Tor Website.url"
239 CreateShortCut "$SMPROGRAMS\Tor\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
240 FunctionEnd
242 Function CreateDocLinks
243 CreateDirectory "$SMPROGRAMS\Tor\Documents"
244 CreateShortCut "$SMPROGRAMS\Tor\Documents\Tor Manual.lnk" "$INSTDIR\Documents\tor-reference.html"
245 CreateShortCut "$SMPROGRAMS\Tor\Documents\Tor Documentation.lnk" "$INSTDIR\Documents"
246 CreateShortCut "$SMPROGRAMS\Tor\Documents\Tor Specification.lnk" "$INSTDIR\Documents\tor-spec.txt"
247 FunctionEnd
249 Function ParseCmdLine
250 ${GetParameters} $1
251 ${If} $1 == "-x" ;Extract All Files
252 StrCpy $INSTDIR $EXEDIR
253 Call ExtractBinaries
254 Call ExtractDocuments
255 Quit
256 ${ElseIf} $1 == "-b" ;Extract Binaries Only
257 StrCpy $INSTDIR $EXEDIR
258 Call ExtractBinaries
259 Quit
260 ${ElseIf} $1 != ""
261 MessageBox MB_OK|MB_TOPMOST `${Installer} [-x|-b]$\r$\n$\r$\n -x Extract all files$\r$\n -b Extract binary files only`
262 Quit
263 ${EndIf}
264 FunctionEnd