I have a .txt file with this lines:
Also I have this files at the ${srcdir} before I make an installer:
List of files always changes so I need to manually correct the nsi-script.
How can I make checkbox-list at custom page with listview which depends on file.txt?
Now I'm using component page and simple construction to check for files.
SectionGroup /e "Installing apps" SecApps
!if /FileExists "E:\src\app.dll"
Section "Install app1"
SetOutPath "$InstDir"
File "E:\src\app.dll"
SectionEnd
!endif
!if /FileExists "E:\src\app2.dll"
Section "Install app2"
SetOutPath "$InstDir"
File "E:\src\app2.dll"
SectionEnd
!endif
!if /FileExists "E:\src\app3.dll"
Section "Install app3"
SetOutPath "$InstDir"
File "E:\src\app3.dll"
SectionEnd
!endif
SectionGroupEnd
When you want to do something advanced at compile-time the best option is usually to call an external script/application with !system
:
!define srcdir "."
; Make some dummy files for this example
!appendfile "${srcdir}\foo.txt" "!"
!appendfile "${srcdir}\bar.txt" "!"
!delfile /nonfatal "${srcdir}\filelist.txt"
!appendfile "${srcdir}\filelist.txt" "foo.txt$\r$\n"
!appendfile "${srcdir}\filelist.txt" "bar.txt$\r$\n"
; Make batch file for this example (In a real installer you probably don't want to generate the .bat on the fly like this)
!define /redef batch "${__FILE__}\..\parsefile.bat"
!delfile /nonfatal "${batch}"
!appendfile "${batch}" "@echo off&setlocal ENABLEEXTENSIONS$\r$\n"
!appendfile "${batch}" `for /F "usebackq" %%A in ("%~2") do ($\r$\n`
!appendfile "${batch}" ' >> %1 echo Section "%%~nA"$\r$\n'
!appendfile "${batch}" ' >> %1 echo File "%%A"$\r$\n'
!appendfile "${batch}" ' >> %1 echo SectionEnd$\r$\n'
!appendfile "${batch}" ")$\r$\n"
!tempfile nsh
!system '"${batch}" "${nsh}" "${srcdir}\filelist.txt"' = 0
!include "${nsh}"
!delfile "${nsh}"
!undef nsh
Page Components
Page InstFiles