tor-mingw.nsi.in 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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.2.1.14-rc"
  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"
  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 it's 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\control-spec.txt"
  150. File "..\doc\spec\control-spec-v0.txt"
  151. File "..\doc\spec\dir-spec.txt"
  152. File "..\doc\spec\dir-spec-v1.txt"
  153. File "..\doc\spec\path-spec.txt"
  154. File "..\doc\spec\rend-spec.txt"
  155. File "..\doc\spec\socks-extensions.txt"
  156. File "..\doc\spec\tor-spec.txt"
  157. File "..\doc\spec\version-spec.txt"
  158. FunctionEnd
  159. Function ExtractHTML
  160. File "..\doc\tor-resolve.html"
  161. File "..\doc\tor-reference.html"
  162. FunctionEnd
  163. Function ExtractDesignDocs
  164. File "..\doc\design-paper\tor-design.pdf"
  165. FunctionEnd
  166. Function ExtractReleaseDocs
  167. File "..\README"
  168. File "..\AUTHORS"
  169. File "..\ChangeLog"
  170. File "..\LICENSE"
  171. FunctionEnd
  172. Function ExtractDocuments
  173. SetOutPath "$INSTDIR\Documents"
  174. Call ExtractSpecs
  175. Call ExtractHTML
  176. Call ExtractDesignDocs
  177. Call ExtractReleaseDocs
  178. FunctionEnd
  179. Function un.InstallFiles
  180. Delete "$DESKTOP\Tor.lnk"
  181. Delete "$INSTDIR\tor.exe"
  182. Delete "$INSTDIR\tor-resolve.exe"
  183. Delete "$INSTDIR\Tor Website.url"
  184. Delete "$INSTDIR\torrc"
  185. Delete "$INSTDIR\torrc.sample"
  186. Delete "$INSTDIR\tor.ico"
  187. Delete "$SMSTARTUP\Tor.lnk"
  188. Delete "$INSTDIR\Uninstall.exe"
  189. FunctionEnd
  190. Function un.InstallDirectories
  191. ${If} $CONFIGDIR == $INSTDIR
  192. RMDir /r $CONFIGDIR
  193. ${EndIf}
  194. RMDir /r "$INSTDIR\Documents"
  195. RMDir $INSTDIR
  196. RMDir /r "$SMPROGRAMS\Tor"
  197. RMDir /r "$APPDATA\Tor"
  198. FunctionEnd
  199. Function un.WriteRegistry
  200. DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Tor"
  201. FunctionEnd
  202. Function un.InstallPackage
  203. Call un.InstallFiles
  204. Call un.InstallDirectories
  205. Call un.WriteRegistry
  206. FunctionEnd
  207. Function CreateTorLinks
  208. CreateDirectory "$SMPROGRAMS\Tor"
  209. CreateShortCut "$SMPROGRAMS\Tor\Tor.lnk" "$INSTDIR\tor.exe" "" "$INSTDIR\tor.ico"
  210. CreateShortCut "$SMPROGRAMS\Tor\Torrc.lnk" "Notepad.exe" "$CONFIGDIR\torrc"
  211. CreateShortCut "$SMPROGRAMS\Tor\Tor Website.lnk" "$INSTDIR\Tor Website.url"
  212. CreateShortCut "$SMPROGRAMS\Tor\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
  213. FunctionEnd
  214. Function CreateDocLinks
  215. CreateDirectory "$SMPROGRAMS\Tor\Documents"
  216. CreateShortCut "$SMPROGRAMS\Tor\Documents\Tor Manual.lnk" "$INSTDIR\Documents\tor-reference.html"
  217. CreateShortCut "$SMPROGRAMS\Tor\Documents\Tor Documentation.lnk" "$INSTDIR\Documents"
  218. CreateShortCut "$SMPROGRAMS\Tor\Documents\Tor Specification.lnk" "$INSTDIR\Documents\tor-spec.txt"
  219. FunctionEnd
  220. Function ParseCmdLine
  221. ${GetParameters} $1
  222. ${If} $1 == "-x" ;Extract All Files
  223. StrCpy $INSTDIR $EXEDIR
  224. Call ExtractBinaries
  225. Call ExtractDocuments
  226. Quit
  227. ${ElseIf} $1 == "-b" ;Extract Binaries Only
  228. StrCpy $INSTDIR $EXEDIR
  229. Call ExtractBinaries
  230. Quit
  231. ${ElseIf} $1 != ""
  232. MessageBox MB_OK|MB_TOPMOST `${Installer} [-x|-b]$\r$\n$\r$\n -x Extract all files$\r$\n -b Extract binary files only`
  233. Quit
  234. ${EndIf}
  235. FunctionEnd