main.nsi 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. Unicode true
  2. !ifdef _DEBUG
  3. SetCompress off
  4. FileBufSize 64
  5. SetDatablockOptimize off
  6. !else
  7. SetDatablockOptimize on
  8. !ifdef lzma
  9. SetCompressor /SOLID lzma
  10. SetCompressorDictSize 16
  11. FileBufSize 64
  12. !else
  13. SetCompressor /SOLID bzip2 ; actually doesnt seem to help :(
  14. !endif
  15. !endif
  16. ReserveFile /plugin "LangDLL.dll"
  17. ReserveFile /plugin "nsDialogs.dll"
  18. ReserveFile /plugin "System.dll"
  19. ; temp hack 2022 (hard-coded to 32-bit release build - might need e.g. a Winamp_x64_Release version later)
  20. !ifndef FILES_PATH
  21. !define FILES_PATH ..\..\..\Build\Winamp_x86_Release
  22. ; change to this when copied to Winamp-Desktop\Src\Build\Winamp_x86_Release\installer\winamp
  23. ; !define FILES_PATH ..\..\..\Winamp_x86_Release
  24. !endif
  25. !define MUI_LANGDLL_REGISTRY_ROOT HKLM
  26. !define MUI_LANGDLL_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${WINAMP}"
  27. !define MUI_LANGDLL_REGISTRY_VALUENAME "LangId"
  28. !define MUI_LANGDLL_WINDOWTITLE $(LANGUAGE_DLL_TITLE)
  29. !define MUI_LANGDLL_INFO $(LANGUAGE_DLL_INFO)
  30. !addincludedir "..\shared\scripts"
  31. !include "MUI2.nsh"
  32. !include "WordFunc.nsh"
  33. !include "WinMessages.nsh"
  34. !include "LogicLib.nsh"
  35. !include ".\parameters.nsh"
  36. !include ".\branding.nsh"
  37. !include "verInfo.nsh"
  38. !include "WinVer.nsh"
  39. Var SETTINGSDIR
  40. Var INSTINI
  41. Var WINAMPINI
  42. Var WINAMPM3U
  43. Var M3UBASEDIR
  44. Var PREVINSTINI
  45. Var RESTARTAGENT
  46. Var FIRSTINSTALL
  47. Var needplaystart
  48. Var IDX_INSTTYPE_STANDARD
  49. Var IDX_INSTTYPE_PREVIOUS
  50. Var IDX_INSTTYPE_FULL
  51. Var /GLOBAL VERSION_REGISTRY
  52. Var /GLOBAL VERSION_MINIMUM
  53. !include ".\utils\wafuncs.nsh"
  54. !ifndef _DEBUG
  55. ; BrandingText "Winamp ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MINOR_SECOND} ${InstallType} -- $(BuiltOn) ${__DATE__} $(at) ${__TIME__}"
  56. BrandingText "Winamp ${VERSION_MAJOR}.${VERSION_MINOR} ${InstallType} -- $(BuiltOn) ${__DATE__} $(at) ${__TIME__}"
  57. !else
  58. BrandingText "Winamp Debug -- internal use only"
  59. !endif
  60. RequestExecutionLevel admin
  61. Caption $(IDS_CAPTION)
  62. Name "${WINAMP}"
  63. InstallDir "$PROGRAMFILES\${WINAMPFOLDER}"
  64. InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${WINAMP}" "UninstallString"
  65. XPStyle on
  66. !define OVERWRITEMODE on
  67. !ifdef _DEBUG
  68. ShowInstDetails show
  69. AutoCloseWindow false
  70. !else
  71. ShowInstDetails nevershow
  72. AutoCloseWindow true
  73. !endif
  74. SetDateSave on
  75. !define SECTIONIN_FULL "SectionIn 1"
  76. !ifdef FULL
  77. !define SECTIONIN_STD "SectionIn 1 2"
  78. !define SECTIONIN_LITE "SectionIn 1 2 3"
  79. !else
  80. !define SECTIONIN_STD "SectionIn 1"
  81. !define SECTIONIN_LITE "SectionIn 1"
  82. !endif
  83. !ifndef INSTALL_NAME
  84. !define INSTALL_NAME "winamp${VERSION_MAJOR}${VERSION_MINOR}${VERSION_MINOR_SECOND}"
  85. !endif
  86. !ifdef _DEBUG
  87. OutFile "wasetup_dbg${LANG_FILESPEC}.exe"
  88. !else
  89. !ifdef LITE
  90. OutFile "$%INSTALL_NAME%_lite${LANG_FILESPEC}.exe"
  91. !else ifdef full
  92. OutFile "$%INSTALL_NAME%_full${LANG_FILESPEC}.exe"
  93. !else
  94. OutFile 'winamp_unknown${LANG_FILESPEC}.exe'
  95. !endif
  96. !endif
  97. !include ".\ui.nsh"
  98. !include ".\sectionsHelper.nsh"
  99. !include ".\wasections.nsh"
  100. !include ".\uninstall\uninstall.nsh"
  101. !include ".\languages.nsh"
  102. Section -LastSection IDX_SECTION_LAST ; keep last section after languages
  103. SectionEnd
  104. !include ".\uiEvents.nsh"
  105. !include ".\descriptionTable.nsh"
  106. Function .onInit
  107. !ifdef WINAMP64
  108. ReadEnvStr $0 PROGRAMW6432
  109. StrCpy $INSTDIR "$0\${WINAMPFOLDER}"
  110. !endif
  111. InitPluginsDir
  112. System::Call "User32::SetProcessDPIAware()"
  113. StrCpy $PREVINSTINI ""
  114. StrCpy $INSTINI "$PLUGINSDIR\install.ini"
  115. !ifdef LANGID
  116. WriteRegStr "${MUI_LANGDLL_REGISTRY_ROOT}" "${MUI_LANGDLL_REGISTRY_KEY}" "${MUI_LANGDLL_REGISTRY_VALUENAME}" ${LANGID}
  117. !endif ; LANGID
  118. !insertmacro MUI_LANGDLL_DISPLAY
  119. ; check Windows version
  120. ; this will need testing...
  121. ${If} ${AtMostWin7}
  122. ${If} ${IsWin7}
  123. ${AndIf} ${AtLeastServicePack} 1
  124. ${Else}
  125. MessageBox MB_OK|MB_ICONEXCLAMATION "$(IDS_MSG_WINDOWS_TOO_OLD)" /SD IDOK
  126. Quit
  127. ${EndIf}
  128. ${EndIf}
  129. ; VC142 runtime required for all installations - pt.1: external
  130. /* ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Version"
  131. ${If} $0 == "v14.29.30139.00"
  132. ${OrIf} $0 == "v14.30.30423.00"
  133. ${OrIf} $0 == "v14.30.30528.00"
  134. ${OrIf} $0 == "v14.30.30704.00"
  135. ${OrIf} $0 == "v14.30.*"
  136. ${OrIf} $0 == "v14.31.30818.00"
  137. ${OrIf} $0 == "v14.31.30919.00"
  138. ${OrIf} $0 == "v14.31.31005.00"
  139. ${OrIf} $0 == "v14.31.31103.00"
  140. ${OrIf} $0 == "v14.31.*"
  141. ${OrIf} $0 == "v14.32.31302.00"
  142. ${OrIf} $0 == "v14.32.31326.00"
  143. ${OrIf} $0 == "v14.32.31332.00"
  144. ${OrIf} $0 == "v14.32.*"
  145. ${OrIf} $0 == "v14.33.31424.00"
  146. ${OrIf} $0 == "v14.33.*"
  147. ${OrIf} $0 == "v14.34.*"
  148. Goto continue
  149. */
  150. ; Get Visual Studio Version
  151. DetailPrint "Getting Visual Studio Version string from registry..."
  152. ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Version"
  153. DetailPrint "Visual Studio Version String: $0"
  154. DetailPrint "Done!"
  155. DetailPrint ""
  156. ; Replace v in Version String
  157. DetailPrint "Replacing v substring in version string..."
  158. ${WordReplace} "$0" "v" "" "+" $0
  159. DetailPrint "Visual Studio Version: $0"
  160. DetailPrint "Done!"
  161. DetailPrint ""
  162. ; Compare Versions
  163. DetailPrint "Comparing Visual Studio Registry and Minimal Versions..."
  164. ; ${VersionCompare} "[Version1]" "[Version2]" $var
  165. ; "[Version1]" ; REGISTRY VERSION
  166. ; "[Version2]" ; MINIMUM VERSION
  167. ; $var ; Result:
  168. ; $var=0 Versions are equal
  169. ; $var=1 Version1 is newer
  170. ; $var=2 Version2 is newer
  171. ; Visual Studio Registry Version
  172. StrCpy $VERSION_REGISTRY $0
  173. DetailPrint " Registry Version: $VERSION_REGISTRY"
  174. ; Visual Studio Minimal Version
  175. StrCpy $VERSION_MINIMUM "14.29.30139.00" ; MINIMUM VERSION!!!
  176. ; ===========================================================
  177. ; --- DEBUG ---
  178. ;StrCpy $VERSION_MINIMUM "14.29.30139.00" ; REGISTRY > MINIMUM
  179. ;StrCpy $VERSION_MINIMUM "14.32.31332.00" ; REGISTRY = MINIMUM
  180. ;StrCpy $VERSION_MINIMUM "14.33.31424.00" ; REGISTRY < MINIMUM -> INSTALLATION REQUIRED!
  181. ; --- DEBUG ---
  182. ; ===========================================================
  183. DetailPrint " Minimum Version: $VERSION_MINIMUM"
  184. ${VersionCompare} "$VERSION_REGISTRY" "$VERSION_MINIMUM" $R0
  185. DetailPrint "Version Compare Result: $R0"
  186. ${If} $R0 == 0
  187. ${OrIf} $R0 == 1
  188. ; Visual C++ Redistributable for Visual Studio 2015 Installation NOT Required!
  189. ${If} $R0 == 0
  190. DetailPrint "VERSIONS ARE EQUAL ($VERSION_REGISTRY = $VERSION_MINIMUM)"
  191. DetailPrint "Visual C++ Redistributable for Visual Studio 2015 Installation NOT Required!"
  192. ${Else}
  193. DetailPrint "REGISTRY VERSION ($VERSION_REGISTRY) > MINIMUM VERSION ($VERSION_MINIMUM)"
  194. DetailPrint "Visual C++ Redistributable for Visual Studio 2015 Installation NOT Required!"
  195. ${EndIf}
  196. ${Else}
  197. ; Visual C++ Redistributable for Visual Studio 2015 Installation Required!
  198. DetailPrint "REGISTRY VERSION ($VERSION_REGISTRY) < MINIMUM VERSION ($VERSION_MINIMUM)"
  199. DetailPrint "Visual C++ Redistributable for Visual Studio 2015 Installation Required!"
  200. ; Code for Download and Install vc_redist.x86.exe...
  201. MessageBox MB_YESNO|MB_ICONQUESTION "$(IDS_MSG_VC_REDIST_LINK_TO_MSDOWNLOAD)$\r$\n$\r$\n$(IDS_VC_REDIST_MSDOWNLOAD_URL)$\r$\n$\r$\n$(IDS_VC_DOWNLOAD)$\r$\n$(IDS_VC_DOWNLOAD_OR_ABORT)" /SD IDYES IDYES download IDNO abortInstaller
  202. download:
  203. SetOutPath "$TEMP"
  204. NSISdl::download "https://aka.ms/vs/16/release/vc_redist.x86.exe" "$TEMP\vc_redist.x86.exe"
  205. ExecWait "$TEMP\vc_redist.x86.exe"
  206. Delete "$TEMP\vc_redist.x86.exe"
  207. Goto continue
  208. abortInstaller:
  209. Quit
  210. continue:
  211. ${EndIf}
  212. ${FrenchRadio_OnInit}
  213. ${If} ${AtLeastWin7}
  214. ${ExpressMode_Initialize}
  215. ${EndIf}
  216. FunctionEnd
  217. Function .onInstSuccess
  218. Delete $PREVINSTINI
  219. Call SaveSelection
  220. DeleteINISec "$INSTINI" "Bundle"
  221. CopyFiles /SILENT "$INSTINI" "$INSTDIR\install.ini"
  222. FunctionEnd
  223. Function un.onInit
  224. !insertmacro MUI_UNGETLANGUAGE
  225. StrCpy $winamp.uninstall.checkFolder "false"
  226. FunctionEnd
  227. ${InitializeGetSectionName}
  228. Function GetLastInstTypeIndex
  229. Push $R0
  230. Push $R1
  231. StrCpy $R0 0
  232. loop:
  233. InstTypeGetText $R0 $R1
  234. StrCmp $R1 '' +3
  235. IntOp $R0 $R0 + 1
  236. goto loop
  237. Pop $R1
  238. IntOp $R0 $R0 - 1
  239. Exch $R0
  240. FunctionEnd
  241. Function ReadSections
  242. Push $R0
  243. Push $R1
  244. Push $R2
  245. Push $R3
  246. Push $R4
  247. Push $R5
  248. Push $R6
  249. Push $R7
  250. Push $R8
  251. StrCpy $R1 ${IDX_SECTION_LAST}
  252. Call GetLastInstTypeIndex
  253. Pop $R5
  254. StrCpy $R0 1
  255. IntOp $R6 $R0 << $R5
  256. IntOp $R6 $R6 ~
  257. StrCpy $R0 0
  258. ReadINIStr $R8 "$INSTINI" "installer" "sectionsVer"
  259. loop:
  260. !ifdef IDX_SEC_ML
  261. StrCmp $R0 ${IDX_SEC_ML} skipRead
  262. !endif
  263. !ifdef IDX_SEC_ML_PMP
  264. StrCmp $R0 ${IDX_SEC_ML_PMP} skipRead
  265. !endif
  266. ${If} $R8 >= 2
  267. ${GetSectionName} $R0 $R2
  268. ${Else}
  269. SectionGetText $R0 $R2
  270. ${EndIf}
  271. StrCmp $R2 "-" skipRead
  272. StrCmp $R2 "" skipRead
  273. SectionGetFlags $R0 $R3
  274. IntOp $R3 $R3 & 0x00000017
  275. IntCmp $R3 1 gotoRead gotoRead
  276. IntOp $R7 $R3 & 0x00000002 ; check if it is section
  277. IntCmp $R7 0 +2
  278. StrCpy $R7 $R0 ;remember section index (we can use it later to make it bold)
  279. goto skipRead ; skip sections, section end and readonly
  280. gotoRead:
  281. ReadINIStr $R4 "$INSTINI" "sections" $R2
  282. ; MessageBox MB_OK "$R2 - $R4"
  283. StrCmp $R4 "" 0 normalRead ;new feature or not?
  284. IntOp $R4 0x00000000 | 0x0000009 ; new feature make it selected and bold
  285. SectionGetFlags $R7 $0
  286. IntOp $0 $0 | 0x0000008
  287. SectionSetFlags $R7 $0
  288. normalRead:
  289. IntOp $R3 $R3 & 0xfffffffe
  290. IntOp $R3 $R3 | $R4
  291. SectionSetFlags $R0 $R3
  292. SectionGetInstTypes $R0 $R3
  293. IntOp $R3 $R3 & $R6
  294. IntOp $R4 $R4 << $R5
  295. IntOp $R3 $R3 | $R4
  296. SectionSetInstTypes $R0 $R3
  297. skipRead:
  298. IntOp $R0 $R0 + 1
  299. IntCmp $R0 $R1 "" loop
  300. Pop $R8
  301. Pop $R7
  302. Pop $R6
  303. Pop $R5
  304. Pop $R4
  305. Pop $R3
  306. Pop $R2
  307. Pop $R1
  308. Pop $R0
  309. FunctionEnd
  310. Function SaveSelection
  311. Push $R0
  312. Push $R1
  313. Push $R2
  314. Push $R3
  315. StrCpy $R1 ${IDX_SECTION_LAST}
  316. StrCpy $R0 0
  317. WriteINIStr "$INSTINI" "installer" "sectionsVer" "2"
  318. DeleteINISec "$INSTINI" "sections"
  319. loop:
  320. !ifdef FULL
  321. StrCmp $R0 ${IDX_SEC_ML} 0 ignore_1
  322. StrCmp $R0 ${IDX_SEC_ML_PMP} 0 ignore_1
  323. !endif ; FULL
  324. ${GetSectionName} $R0 $R2
  325. SectionGetFlags $R0 $R3
  326. IntOp $R3 $R3 & 0x0001
  327. goto force_write
  328. !ifdef FULL
  329. ignore_1:
  330. !endif ; FULL
  331. ${GetSectionName} $R0 $R2
  332. StrCmp $R2 "-" skipWrite
  333. StrCmp $R2 "" skipWrite
  334. SectionGetFlags $R0 $R3
  335. IntOp $R3 $R3 & 0x00000017
  336. IntCmp $R3 1 0 0 skipWrite ; skip sections, section end and readonly
  337. force_write:
  338. WriteINIStr "$INSTINI" "sections" $R2 $R3
  339. skipWrite:
  340. IntOp $R0 $R0 + 1
  341. IntCmp $R0 $R1 "" loop
  342. Pop $R3
  343. Pop $R2
  344. Pop $R1
  345. Pop $R0
  346. FunctionEnd
  347. !ifdef FULL
  348. Function UpdateAutoSelectSection
  349. Exch $1 ; section id
  350. Exch
  351. Exch $0 ; group id
  352. Exch
  353. Push $2
  354. Push $3
  355. Push $4
  356. Push $5
  357. StrCpy $2 "1" ; - nesting counter
  358. StrCpy $3 "0" ; - sel counter
  359. IntOp $0 $0 + 1
  360. ${Do}
  361. SectionGetFlags $0 $4
  362. IntOp $5 $4 & 0x0002 ; test if group start
  363. ${If} $5 <> 0
  364. IntOp $2 $2 + 1
  365. ${EndIf}
  366. IntOp $5 $4 & 0x0004 ; test if group end
  367. ${If} $5 <> 0
  368. IntOp $2 $2 - 1
  369. ${If} $2 == 0
  370. ${ExitDo}
  371. ${EndIf}
  372. ${Else}
  373. IntOp $5 $4 & 0x0041 ; test if selected or partial selected
  374. ${If} $5 <> 0
  375. ${AndIf} $0 <> $1
  376. StrCpy $3 "1"
  377. ${ExitDo}
  378. ${EndIf}
  379. ${EndIf}
  380. IntOp $0 $0 + 1
  381. ${Loop}
  382. SectionGetFlags $1 $4
  383. IntOp $4 $4 & 0xFFEF
  384. ${If} $3 <> 0
  385. IntOp $4 $4 | 0x0011
  386. ${EndIf}
  387. SectionSetFlags $1 $4
  388. Pop $5
  389. Pop $4
  390. Pop $3
  391. Exch $2
  392. Exch
  393. Exch $1
  394. Exch 2
  395. Exch $0
  396. FunctionEnd
  397. !macro UpdateAutoSelectSection __groupId __sectionId
  398. Push ${__groupId}
  399. Push ${__sectionId}
  400. Call UpdateAutoSelectSection
  401. !macroend
  402. !define UpdateAutoSelectSection "!insertmacro 'UpdateAutoSelectSection'"
  403. !endif
  404. Function .onSelChange
  405. !ifdef FULL
  406. ${UpdateAutoSelectSection} ${IDX_GRP_WALIB_PORTABLE} ${IDX_SEC_ML_PMP}
  407. ${UpdateAutoSelectSection} ${IDX_GRP_WALIB} ${IDX_SEC_ML}
  408. !endif
  409. FunctionEnd