This document describes some of the tricks used in the ]po[ V4.0 installer in order to include PostgreSQL 8.4 as part of the installation.
The ]po[ installer consists of the following three main software packages:
The ]po[ installer contains the following directory structure:
During installation, the installer copies the directory tree into the target machine and performs a number of changes in the target Windows system:
The installer uses NSIS (Nullsoft Scriptable Install System) for creating an installer.
NSIS is working perfectly for us and includes a large number of user written plugins for a wide range of needs.
In ]po[ V4.0 we have decided to include the PostgreSQL database as part of the ]po[ installer, instead of calling the PosgreSQL installer as a kind of sub-installer. The reason for this extra step is that the PostgreSQL installer didn't completely uninstall the PosgreSQL files and didn't remove the "postgres" user account that it creates. These leftovers used to create a lot of user complaints in ]po[ V3.5 and earlier.
Instead of using the PostgreSQL 8.4 ".exe" installer, we now use the ".zip" binary Windows distribution as part of the ]po[ installer. We copied the content of the ZIP file into C:\project-open\pgsql\ and created the following NSIS installer file that creates a "postgres" user account and sets up PostgreSQL as a Windows service:
# -------------------------------------------------------------- # Install PostgreSQL # -------------------------------------------------------------- # set the name of the installer outfile "C:\project-open\installer\install_postgres.exe" Name "Install PostgreSQL" !include Registry.nsh !include LogicLib.nsh !include MultiUser.nsh !include Sections.nsh !include MUI2.nsh !define TARGET c:\project-open Function .onInit StrCpy $INSTDIR "c:\project-open" FunctionEnd section UserMgr::CreateAccountEx "postgres" "AcpfP0st" "PostgreSQL" "PostgreSQL Database User" "Database user created by ]po[ installer" "UF_PASSWD_NOTREQD|UF_DONT_EXPIRE_PASSWD" pop $R0 DetailPrint "After creating account: result=$R0" UserMgr::AddPrivilege "postgres" "SeBatchLogonRight" pop $R0 DetailPrint "SeBatchLogonRight: result=$R0" UserMgr::AddPrivilege "postgres" "SeServiceLogonRight" pop $R0 DetailPrint "SeServiceLogonRight: result=$R0" nsExec::ExecToLog '"$INSTDIR\pgsql\bin\initdb.exe" --username=postgres --locale=C --encoding=UTF8 -D "$INSTDIR\pgsql\data"' pop $R0 DetailPrint "After initializing database: result=$R0" nsExec::ExecToLog 'sc create postgresql-8.4 binpath= "c:\project-open\pgsql\bin\pg_ctl.exe runservice -N postgresql-8.4 -D c:/project-open/pgsql/data -w" DisplayName= "PostgreSQL 8.4" start= "demand" type= own obj= ".\postgres" password= "AcpfP0st" ' pop $R0 DetailPrint "After registering the service: result=$R0" sectionEnd
For more details please see the file "project_open_installer.nsi" in the "/installer/" folder of ]po[ Windows installer. The "/installer/" contains the complete source code for building the installer.
Calle Aprestadora 19, 12o-2a
08902 Hospitalet de Llobregat (Barcelona)
Spain
Tel Europe: +34 609 953 751
Tel US: +1 415 200 2465
Mail: info@project-open.com