No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Enigmail+pEp_Bundle.nsi 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. # Enigmail pEp Bundle
  2. # Reference
  3. # http://nsis.sourceforge.net/Docs/Modern%20UI/Readme.html
  4. # http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html
  5. # http://nsis.sourceforge.net/%22Orange%22_Modern_UI_Theme
  6. !addplugindir NSIS\Plugins\x86-ansi
  7. !include "MUI2.nsh"
  8. # deprecated !include InstallOptions.nsh
  9. Outfile "Enigmail+pEp_Bundle.exe"
  10. Name "pEp Thunderbird with Enigmail Bundle"
  11. InstallDir $APPDATA\pEp\BundleInstaller
  12. # InstallDirRegKey HKCU "Software\Modern UI Test" ""
  13. BrandingText "pEp Foundation. Privacy by Default."
  14. ; Vista+ user|admin
  15. # The only guy that refuses to self-elevate is, wonder wonder... Gpg4win
  16. RequestExecutionLevel user
  17. Var isAdmin
  18. Var EnvComSpec
  19. # Var WINDIR
  20. Var TbProfileDir
  21. Var TbProfileDirFound
  22. Var TbExec
  23. Var TbExecFound
  24. # ReserveFile getProfile.bat
  25. # ReserveFile ioFile.ini
  26. !define MUI_ICON "if_User_No-Frame_97832.ico"
  27. # !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall-nsis.ico"
  28. !define MUI_UNICON ${MUI_ICON}
  29. !define MUI_HEADERIMAGE
  30. !define MUI_HEADERIMAGE_BITMAP "held.bmp"
  31. # !define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
  32. !define MUI_HEADERIMAGE_UNBITMAP "held.bmp"
  33. !define MUI_HEADERIMAGE_UNBITMAP_NOSTRETCH
  34. !define MUI_HEADERIMAGE_RIGHT
  35. # RRGGBBR
  36. # !define MUI_BGCOLOR AAAAAA9
  37. !define MUI_WELCOMEFINISHPAGE_BITMAP "held.bmp"
  38. # !define MUI_WELCOMEFINISHPAGE_BITMAP_NOSTRETCH
  39. !define MUI_UNWELCOMEFINISHPAGE_BITMAP "held.bmp"
  40. # !define MUI_UNWELCOMEFINISHPAGE_BITMAP_NOSTRETCH
  41. # !define MUI_WELCOMEFINISHPAGE_INI nsis-pep.ini
  42. Icon ${MUI_ICON}
  43. UninstallIcon ${MUI_UNICON}
  44. ;--------------------------------
  45. ;Interface Settings
  46. # - bad UX
  47. #!define MUI_ABORTWARNING
  48. !define MUI_UNABORTWARNING
  49. # FIXME TODO: only for debugging:
  50. !define MUI_FINISHPAGE_NOAUTOCLOSE
  51. !define MUI_UNFINISHPAGE_NOAUTOCLOSE
  52. !define Trim "!insertmacro Trim"
  53. !macro Trim ResultVar String
  54. Push "${String}"
  55. Call Trim
  56. Pop "${ResultVar}"
  57. !macroend
  58. ;--------------------------------
  59. ;Pages
  60. !define MUI_WELCOMEPAGE_TITLE "Welcome-Title"
  61. !define MUI_WELCOMEPAGE_TITLE_3LINES "Bla\nBla2\Bla3"
  62. #!define MUI_WELCOMEPAGE_TEXT "Just text"
  63. !insertmacro MUI_PAGE_WELCOME
  64. # # Page custom CustomInstallers nsDialogsPageLeave
  65. # !define MUI_PAGE_CUSTOMFUNCTION_POST DeselectBundleInstall
  66. # !insertmacro MUI_PAGE_INSTFILES
  67. #Function DeselectBundleInstall
  68. # !insertmacro UnselectSection "Bundle Install"
  69. #FunctionEnd
  70. #!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt
  71. !define MUI_PAGE_CUSTOMFUNCTION_PRE ComponentsPre
  72. !define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentsLeave
  73. !insertmacro MUI_PAGE_COMPONENTS
  74. !define MUI_PAGE_CUSTOMFUNCTION_PRE ProfilePre
  75. #!define MUI_PAGE_CUSTOMFUNCTION_LEAVE ProfileLeave
  76. !define MUI_DIRECTORYPAGE_VARIABLE $TbProfileDir
  77. !define MUI_PAGE_HEADER_TEXT "Thunderbird Profile"
  78. !define MUI_PAGE_HEADER_SUBTEXT "Thunderbird Sub-Bla"
  79. !insertmacro MUI_PAGE_DIRECTORY
  80. # Second round
  81. # Page custom CustomInstallers nsDialogsPageLeave
  82. # !define MUI_PAGE_CUSTOMFUNCTION_PRE
  83. !insertmacro MUI_PAGE_INSTFILES
  84. # InstType "Privacy by Default"
  85. # !define CIT_Special 1
  86. # InstType "Online Update"
  87. # http://nsis.sourceforge.net/Reference/Section
  88. # We deliver the package with and without Thunderbird.
  89. Var TbUrl
  90. Var EnvWinDir
  91. Var TbSetupReady
  92. SectionGroup /e "Thunderbird" SECT_TB
  93. Section "Download" INST_TB_DLOAD
  94. #SectionIn 2
  95. SetOutPath $PLUGINSDIR
  96. Push 0
  97. Pop $TbSetupReady
  98. IfFileExists "$INSTDIR\Thunderbird_Setup.exe" TbDownloadOnDisk
  99. StrCpy $TbUrl "https://download.mozilla.org/?product=thunderbird-latest&os=win&lang=en-US"
  100. nsExec::ExecToLog '"$EnvWinDir\System32\bitsadmin.exe" /transfer "Thunderbird" /priority high "$TbUrl" "$INSTDIR\Thunderbird_Setup.exe"'
  101. Pop $TbSetupReady
  102. TbDownloadOnDisk:
  103. SectionEnd
  104. Section "Install" INST_TB
  105. #SectionIn 1 2
  106. MessageBox MB_OK "Install!$\n$0"
  107. StrCmp $TbSetupReady 0 +1 NoTbSetupReady
  108. nsExec::ExecToLog '"$INSTDIR\Thunderbird_Setup.exe" /S'
  109. Pop $0
  110. NoTbSetupReady:
  111. SectionEnd
  112. Section "New Profile" INST_TB_NEWPROF
  113. # SectionIn 1 2
  114. # Repeat
  115. SectionEnd
  116. Section "Select Profile" INST_TB_SELPROF
  117. # SectionIn 1 2
  118. # Repeat
  119. SectionEnd
  120. SectionGroupEnd
  121. Section "Gpg4win" INST_GPGWIN
  122. SectionIn RO
  123. SetOutPath $INSTDIR\gpg4win
  124. File gpg4win.ini
  125. IfFileExists "$PROGRAMFILES32\GnuPG\bin\gpg.exe" Gpg4winInstalled
  126. File gpg4win-3.1.1.exe
  127. File gpg4win_setup.bat
  128. # There are thousand ways gpg4win does NOT what it was asked,
  129. # this way it works but the UAC prompt remains in background :(
  130. nsExec::ExecToLog 'gpg4win_setup.bat gpg4win-3.1.1.exe'
  131. Pop $0
  132. Gpg4winInstalled:
  133. CreateDirectory "$APPDATA\gnupg"
  134. SetOutPath "$APPDATA\gnupg"
  135. IfFileExists gpg.conf +2
  136. File /oname=gpg.conf gpg-pep.conf
  137. IfFileExists gpg-agent.conf +2
  138. File /oname=gpg-agent.conf gpg-agent-pep.conf
  139. IfFileExists gpa.conf +2
  140. File /oname=gpa.conf gpa-pep.conf
  141. SectionEnd
  142. Section "Enigmail" INST_ENIGMAIL
  143. #SectionIn 1 2 RO
  144. SectionIn RO
  145. CreateDirectory $TbProfileDir\extensions\staged
  146. SetOutPath $TbProfileDir\extensions\staged
  147. File "/oname={847b3a00-7ab1-11d4-8f02-006008948af5}.xpi" enigmail-2.0.7.xpi
  148. File "/oname={847b3a00-7ab1-11d4-8f02-006008948af5}.json" staged.json
  149. SectionEnd
  150. Section "pEp Adapter" INST_MDA
  151. #SectionIn 1 2 RO
  152. SectionIn RO
  153. # CreateDirectory
  154. SetOutPath $TbProfileDir
  155. File /a /r pepmda\
  156. SectionEnd
  157. Function ComponentsPre
  158. # Set selected and readonly, deselecting in ComponentsPost
  159. #IntOp $0 ${SF_SELECTED} | ${SF_RO}
  160. #SectionSetFlags ${INST_BUNDLE} $0
  161. # ----------------------------------------------
  162. StrCmp $TbExecFound 0 FoundTb NotFoundTb
  163. FoundTb:
  164. IntOp $0 ${SF_RO} | 0
  165. SectionSetFlags ${INST_TB_DLOAD} $0
  166. # IntOp $0 ${SF_RO} | 0
  167. IntOp $0 0 | 0
  168. SectionSetFlags ${INST_TB} $0
  169. Goto FoundTbEnd
  170. NotFoundTb:
  171. IntOp $0 ${SF_SELECTED} | ${SF_RO}
  172. SectionSetFlags ${INST_TB_DLOAD} $0
  173. IntOp $0 ${SF_SELECTED} | 0
  174. SectionSetFlags ${INST_TB} $0
  175. FoundTbEnd:
  176. # ----------------------------------------------
  177. StrCmp $TbProfileDirFound 0 FoundTbProf NotFoundTbProf
  178. FoundTbProf:
  179. IntOp $0 0 | ${SF_RO}
  180. SectionSetFlags ${INST_TB_NEWPROF} $0
  181. # We keep the Select Profile step always selectable
  182. # but we don't activate it, as the automatic selection
  183. # is OK for most users
  184. IntOp $0 0 | 0
  185. SectionSetFlags ${INST_TB_SELPROF} $0
  186. Goto FoundTbProfEnd
  187. NotFoundTbProf:
  188. IntOp $0 ${SF_SELECTED} | ${SF_RO}
  189. SectionSetFlags ${INST_TB_NEWPROF} $0
  190. IntOp $0 0 | 0
  191. SectionSetFlags ${INST_TB_SELPROF} $0
  192. FoundTbProfEnd:
  193. FunctionEnd
  194. Function ComponentsLeave
  195. #IntOp $0 0 | ${SF_RO}
  196. #SectionSetFlags ${INST_BUNDLE} $0
  197. FunctionEnd
  198. Function ProfilePre
  199. StrCpy $TbExec "TB_NOT_FOUND"
  200. nsExec::ExecToStack '"$EnvComSpec" /C "$PLUGINSDIR\getProfile.bat" getexe'
  201. Pop $TbExecFound
  202. Pop $TbExec
  203. ${Trim} $TbExec $TbExec
  204. nsExec::ExecToLog '"$TbExec" -silent -no-remote -createProfile default'
  205. Pop $0
  206. # TODO: Fail installation if this fails
  207. #WaitForProfile:
  208. # IfFileExists "$INSTDIR\Thunderbird_Setup.exe" TbDownloadOnDisk
  209. StrCpy $TbProfileDir "NO_PROFILE_DIR"
  210. nsExec::ExecToStack '"$EnvComSpec" /C "$PLUGINSDIR\getProfile.bat" getprofile'
  211. Pop $TbProfileDirFound
  212. Pop $TbProfileDir
  213. ${Trim} $TbProfileDir $TbProfileDir
  214. # IfFileExists "$TbProfileDir" +1 WaitForProfile
  215. # Skip the section if component not selected (using default from script)
  216. SectionGetFlags ${INST_TB_SELPROF} $0
  217. IntOp $0 $0 & ${SF_SELECTED}
  218. StrCmp $0 ${SF_SELECTED} +2 +1
  219. Abort
  220. FunctionEnd
  221. Function ProfileLeave
  222. MessageBox MB_OK "On Leave '$0'"
  223. FunctionEnd
  224. !define MUI_FINISHPAGE_RUN $TbExec
  225. !define MUI_FINISHPAGE_RUN_TEXT "Start Thunderbird"
  226. !define MUI_FINISHPAGE_RUN_PARAMETERS
  227. !define MUI_FINISHPAGE_RUN_NOTCHECKED
  228. # !define MUI_FINISHPAGE_RUN_FUNCTION
  229. !define MUI_FINISHPAGE_SHOWREADME https://pep.coop/cryptoparty/bundle-start.html
  230. !define MUI_FINISHPAGE_SHOWREADME_TEXT "Continue with instructions online"
  231. # !define MUI_FINISHPAGE_SHOWREADME_TEXT
  232. # !define MUI_FINISHPAGE_SHOWREADME_FUNCTION fn
  233. !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
  234. !define MUI_FINISHPAGE_LINK "Important: Join and support the pEp Cooperative today!"
  235. !define MUI_FINISHPAGE_LINK_LOCATION https://software.pep.foundation/ping.html
  236. !define MUI_FINISHPAGE_LINK_COLOR 03aa4b
  237. !insertmacro MUI_PAGE_FINISH
  238. # Uninstallers!
  239. !insertmacro MUI_UNPAGE_WELCOME
  240. !insertmacro MUI_UNPAGE_CONFIRM
  241. !insertmacro MUI_UNPAGE_INSTFILES
  242. !insertmacro MUI_UNPAGE_FINISH
  243. ;--------------------------------
  244. ;Languages
  245. !insertmacro MUI_LANGUAGE "English"
  246. ;--------------------------------
  247. ;Installer Sections
  248. #### !insertmacro INSTALLOPTIONS_WRITE "ioFile.ini" "Field #" "Name" "Value"
  249. Function .onInit
  250. #!insertmacro INSTALLOPTIONS_EXTRACT "ioFile.ini"
  251. # StrCpy $1 ${secBSPnew} ; Gotta remember which section we are at now...
  252. # SectionGetFlags ${SecBSPnew} $0
  253. # IntOp $0 $0 | ${SF_SELECTED}
  254. # SectionSetFlags ${SecBSPnew} $0
  255. ExpandEnvStrings $EnvComSpec %COMSPEC%
  256. ExpandEnvStrings $EnvWinDir %WINDIR%
  257. InitPluginsDir
  258. File "/oname=$PLUGINSDIR\getProfile.bat" getProfile.bat
  259. StrCpy $TbExec "TB_NOT_FOUND"
  260. nsExec::ExecToStack '"$EnvComSpec" /C "$PLUGINSDIR\getProfile.bat" getexe'
  261. Pop $TbExecFound
  262. Pop $TbExec
  263. ${Trim} $TbExec $TbExec
  264. nsExec::ExecToStack '"$EnvComSpec" /C "$PLUGINSDIR\getProfile.bat" getprofile'
  265. Pop $TbProfileDirFound
  266. Pop $TbProfileDir
  267. ${Trim} $TbProfileDir $TbProfileDir
  268. nsExec::ExecToStack 'taskkill /F /IM pep-json-server.exe'
  269. Pop $0
  270. Pop $0
  271. # File ioFile.ini
  272. #File getProfile.bat
  273. # File install.bat
  274. # File installSettings.bat
  275. # File staged.json
  276. FunctionEnd
  277. Function .onSelChange
  278. #SectionGetFlags $1 $0
  279. #IntOp $0 $0 & ${SECTION_OFF}
  280. #SectionSetFlags $1 $0
  281. FunctionEnd
  282. Function Trim
  283. Exch $R1 ; Original string
  284. Push $R2
  285. Loop:
  286. StrCpy $R2 "$R1" 1
  287. StrCmp "$R2" " " TrimLeft
  288. StrCmp "$R2" "$\r" TrimLeft
  289. StrCmp "$R2" "$\n" TrimLeft
  290. StrCmp "$R2" "$\t" TrimLeft
  291. GoTo Loop2
  292. TrimLeft:
  293. StrCpy $R1 "$R1" "" 1
  294. Goto Loop
  295. Loop2:
  296. StrCpy $R2 "$R1" 1 -1
  297. StrCmp "$R2" " " TrimRight
  298. StrCmp "$R2" "$\r" TrimRight
  299. StrCmp "$R2" "$\n" TrimRight
  300. StrCmp "$R2" "$\t" TrimRight
  301. GoTo Done
  302. TrimRight:
  303. StrCpy $R1 "$R1" -1
  304. Goto Loop2
  305. Done:
  306. Pop $R2
  307. Exch $R1
  308. FunctionEnd
  309. Section "Uninstall"
  310. Delete $INSTDIR\UninstallInstaller.exe
  311. # RMDir "$INSTDIR"
  312. # DeleteRegKey /ifempty HKCU "Software\Modern UI Test"
  313. SectionEnd