tor-mingw.nsi.in 9.1 KB

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