as I promised in the last post, this time I'm on the subject of intense NSIS Installer one. The NSIS (Nullsoft Scriptable Install System) is very highly configurable and therefore can script are great. I occupied myself with this issue now and wrote a first script, with input from existing install scripts aimed at facilitating the creation of Setup.exe.
That's what I tried to reach where I work at the beginning of this script with a lot of variables. But enough of introduction, here is the script with the appropriate explanations.
The installer is back for the address book example of Qt.
!Define PRODUCT_NAME "AddressBook sample"
Name "$ {PRODUCT_NAME}"
!Define EXE_NAME "part2.exe"
!Define PRODUCT_VERSION "0.2"
!Define VER_MAJOR 0
!Define VER_MINOR 2
!Define VER_REVISION 2
!Define VER_BUILD 10
!Define PRODUCT_PUBLISHER "Jürgen Mülbert"
!Define PRODUCT_WEBSITE
"http://www.juergen-muelbert.de"
!Define PRODUCT_SUPPORT_SITE
"http://www.juergen-muelbert.de/support.html"
!Define PRODUCT_DIR_REGKEY
"Software\Microsoft\Windows\CurrentVersion\
App Paths\${EXE_NAME}"
!Define PRODUCT_UNINST_KEY
"Software\Microsoft\Windows\CurrentVersion\
Uninstall\${PRODUCT_NAME}"
! Define REG_KEY "SOFTWARE\$(^Name)"
! Define HKLM INSTALL_ROOT_KEY
Most of the definitions shown above are self-explanatory HKLM is the RegistryKey for the "local machine". Otherwise your request ...
;--------------------------------
; Configuration
Caption "$ {PRODUCT_NAME} $ {PRODUCT_VERSION} Setup"
branding text "© Jürgen Mülbert"
!Ifdef OUTFILE
OutFile "$ {OUTFILE}"
!Else
OutFile
..\${PRODUCT_NAME}-${PRODUCT_VERSION}-setup.exe
!Endif
; Installer attributes
InstallDir $PROGRAMFILES\${PRODUCT_NAME}
InstallDirRegKey
${INSTALL_ROOT_KEY} "${PRODUCT_DIR_REGKEY}" ""
As seen here, in the above text is already used extensively to access the configuration defined constants. That runs through the entire file, as we shall see at the next example.
;--------------------------------
; Installer Sections
Section! $(Secmain) secmain
SetDetailsPrint TextOnly
detailed print "Installing $ {PRODUCT_NAME} core files ..."
SetDetailsPrint listonly
SectionIn 1 2 3 RO
SetShellVarContext all
SetOutPath $ INSTDIR
SetOverwrite on
$ {File} EXE_NAME
Changelog.txt file
File libgcc_s_dw2-1.dll
File mingwm10.dll
File QtCore4.dll
File QtGui4.dll
File addressbook_de.qm
WriteRegStr
${INSTALL_ROOT_KEY} "${REG_KEY}\Components" sec_main 1
SectionEnd
Here is an example of the last main section is listed. In this section, all necessary components installed so the program can run at all. How beautiful is seen here appears as a variable of PRODUCT_NAME . Although that is only used for the detail log, but still. The INSTALLDIR is finally initialized with the PRODUCT_NAME and the much earlier. Incidentally, the command SetShellVarContext with the all option sets, the set this installation for all users of this computer implemented. SetOverwrite on causes all existing files are overwritten by the files in the installation archive. The next variable is used EXE_NAME , which simply contains the name of the executable program. The contents of the file changelog.txt will be displayed after the installation:!define MUI_FINISHPAGE_SHOWREADME $INSTDIR\changelog.txt !define MUI_FINISHPAGE_SHOWREADME_TEXT changelog.txt The DLL's are required. These are the two DLL's was compiled with the QT. Without the use Qt libraries, it would not work of course. At the end of the file list still stands, the translation file for the German text of the address book example. At the end of this section is not written in the Windows registry that the main components were installed.
As I said the moves so through the entire script, which is seen to be fully compatible with link . On my website there are now projects JMNSISHelper NSIS4Java about this topic.