Re: Creating custom Win32 installer - Mailing list pgsql-hackers

From Dave Page
Subject Re: Creating custom Win32 installer
Date
Msg-id E7F85A1B5FF8D44C8A1AF6885BC9A0E401388DCF@ratbert.vale-housing.co.uk
Whole thread Raw
In response to Creating custom Win32 installer  ("Victor B. Wagner" <vitus@cryptocom.ru>)
List pgsql-hackers

> -----Original Message-----
> From: pgsql-hackers-owner@postgresql.org
> [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of
> Victor B. Wagner
> Sent: 05 July 2006 12:28
> To: pgsql-hackers@postgresql.org
> Subject: [HACKERS] Creating custom Win32 installer
>
> I need to build custom win32 binary package for PostgreSQL.
>
> I've downloaded source for PGinstaller but found them hard to
> understand - WiX toolkit and MSI is totally alien territory for me.
>
> Things I need to modify:
>
> 1. Exclude all unneccessary extensions such as PostGIS

In wxs/pginst.wxs, remove the appropriate Component and Feature
sections. E.g. To remove JDBC, you would take out:

<!-- *** JDBC *** -->
<Directory Id="JDBCDIR" Name="jdbc"> <Component Id="jdbc" Guid="412ED45F-047B-4A63-8C09-590DE16B4C5E">   <File
Id="jdbc2"LongName="postgresql-8.1-405.jdbc2.jar" 
Name="jdbc2.jar" DiskId="1"
src="$(var.PKGDIR)/jdbc/postgresql-8.1-405.jdbc2.jar" />   <File Id="jdbc2ee" LongName="postgresql-8.1-405.jdbc2ee.jar"
Name="jdbc2ee.jar" DiskId="1"
src="$(var.PKGDIR)/jdbc/postgresql-8.1-405.jdbc2ee.jar" />   <File Id="jdbc3" LongName="postgresql-8.1-405.jdbc3.jar"
Name="jdbc3.jar" DiskId="1"
src="$(var.PKGDIR)/jdbc/postgresql-8.1-405.jdbc3.jar" /> </Component> <Component Id="postgisjdbc"
Guid="2A1DA975-176C-486E-BC27-D67EB98D2B4F">   <File Id="postgisjdbc" LongName="postgis_1_0_0.jar"
Name="postgis.jar" DiskId="1"
src="$(var.PKGDIR)/postgis/jdbc/postgis_1_0_0.jar" /> </Component>
</Directory>

... And ...

<Feature Id="jdbc" Title="JDBC Driver" Level="1" Description="The
PostgreSQL JDBC driver." AllowAdvertise="no">  <ComponentRef Id="jdbc" />
</Feature>

(as well as the postgisjdbc feature).

Some parts (those that require additional processing to install) are
harder to remove, e.g. PostGIS. In these cases, remove the sections as
above, but also look out for:

<Custom Action="PrepInstallPostgis" After="InstallFiles">&postgis=3
AND DOSERVICE=1 AND DOINITDB=1 AND MaintenanceType="Modify"</Custom>
<Custom Action="InstallPostgis" After="InstallContrib">&postgis=3
AND DOSERVICE=1 AND DOINITDB=1 AND MaintenanceType="Modify"</Custom>

... And ...

<Property Id="POSTGIS" Value=" " Secure="yes" />

... And ...

<ProgressText Action="InstallPostgis">Activating
PostGIS...</ProgressText>

... And ...

<CustomAction Id="PrepInstallPostgis" Property="InstallPostgis"
Value="[UILANG];[SUPERUSER];[SUPERPASSWORD];[LISTENPORT];[SHARECONTRIBDI
R];[POSTGIS]" Execute="immediate" />
<CustomAction Id="InstallPostgis" Return="check" BinaryKey="pginstca"
DllEntry="InstallPostgis@4" Execute="deferred" />

As well as the UI in wxs/uidata.wxs, and the custom action code that
installs PostGIS in ca/pginstca.c

It sounds a lot, but once you get used to it it's pretty
straightforward.

> 2. Add some other extension

To simply install a new feature, just add the required components and a
feature section. If you need post-processing of any kind, you'll need to
add an appropriate CustomAction, and the required C function.

> 3. Add some environment variables to server process (as needed by
> modified version of OpenSSL)

You'll need to write a CustomAction to modify the service user account's
environment.

> 4. Enable openssl by default and create certificate signing request
> during installation.

CustomAction again.

> By quick examination of pginstaller sources I haven't found
> how it does
> register postgresql as service. When I compile postgres from
> sources and
> start it using pg_ctl, it starts as console process, and closing of
> command line window where it have been started, kill it.
>
> I know about separate tools to run arbitrary program as
> service, such as
> one in Cygwin suite, but it seems that PGinstaller doesn't
> include such
> tool.

No, pg_ctl.exe is a service as well as a standalone app. Look at the
"service" component in wxs/pginst.wxs. It calls ServiceInstall to
install the service.

For more info, look at the WiX schema docs, and in particular, the docs
on MSDN
(http://windowssdk.msdn.microsoft.com/en-us/library/ms710796.aspx). They
tend to speak of 'Tables', just remember that the WiX is what builds
those tables so you can see that tags in the wxs file relate to rows
being added to tables.

Regards, Dave.


pgsql-hackers by date:

Previous
From: "Victor B. Wagner"
Date:
Subject: Creating custom Win32 installer
Next
From: "Robert Max Kramer"
Date:
Subject: Re: The problem of an inline definition by construction in