Discussion:
Installing postgis from an NSIS installer
Yves Moisan
2009-02-16 17:48:50 UTC
Permalink
Hi All,

I'm using an NSIS script to bundle our application. The script calls a
bunch of other installers, namely the PostGIS installer. Here are the
sections about postgres and postgis :

...
MessageBox MB_YESNO "Install PostgreSQL 8.3.5?" /SD IDYES IDNO endPG835
File "..\postgresql\postgresql-8.3-int.msi"
ExecWait '"msiexec" /i "postgresql-8.3-int.msi" /qr INTERNALLAUNCH=1
SERVICEACCOUNT="postgres" \
SERVICEPASSWORD="xyz" CREATESERVICEUSER=1 SUPERUSER="postgres"
SUPERPASSWORD="xyz" LISTENPORT=5433 \
PERMITREMOTE=1 ENCODING=latin1 BASEDIR="$INSTDIR\postgresql"
TRANSFORMS=:lang_fr'
endPG835:

MessageBox MB_YESNO "Install PostGIS 1.3.5 for 8.3.5?" /SD IDYES IDNO
endPostGIS
File "..\postgis\postgis-pg83-setup-1.3.5-1.exe"
ExecWait "$INSTDIR\postgis-pg83-setup-1.3.5-1.exe /D=$INSTDIR
\postgresql"
endPostGIS:

PostgreSQL installs fine, but then when I'm launching the PostGIS
installer I get a message saying template_postgis already exists and if
I continue it will override it, but then it fails because the template
is not there. I can check in pgAdmin that the template isn't there.
Why would the postGIS installer find a template_postgis object that is
not there ? I tried to find whether the registry keeps some info, but
it seems not to.

Any hints ?

TIA,

Yves Moisan
Mark Cave-Ayland
2009-02-16 20:53:18 UTC
Permalink
Post by Yves Moisan
Hi All,
I'm using an NSIS script to bundle our application. The script calls a
bunch of other installers, namely the PostGIS installer. Here are the
...
MessageBox MB_YESNO "Install PostgreSQL 8.3.5?" /SD IDYES IDNO endPG835
File "..\postgresql\postgresql-8.3-int.msi"
ExecWait '"msiexec" /i "postgresql-8.3-int.msi" /qr INTERNALLAUNCH=1
SERVICEACCOUNT="postgres" \
SERVICEPASSWORD="xyz" CREATESERVICEUSER=1 SUPERUSER="postgres"
SUPERPASSWORD="xyz" LISTENPORT=5433 \
PERMITREMOTE=1 ENCODING=latin1 BASEDIR="$INSTDIR\postgresql"
TRANSFORMS=:lang_fr'
MessageBox MB_YESNO "Install PostGIS 1.3.5 for 8.3.5?" /SD IDYES IDNO
endPostGIS
File "..\postgis\postgis-pg83-setup-1.3.5-1.exe"
ExecWait "$INSTDIR\postgis-pg83-setup-1.3.5-1.exe /D=$INSTDIR
\postgresql"
PostgreSQL installs fine, but then when I'm launching the PostGIS
installer I get a message saying template_postgis already exists and if
I continue it will override it, but then it fails because the template
is not there. I can check in pgAdmin that the template isn't there.
Why would the postGIS installer find a template_postgis object that is
not there ? I tried to find whether the registry keeps some info, but
it seems not to.
Any hints ?
TIA,
Yves Moisan
Hi Yves,

You can download a zip-file containing the GPL'd source for the Win32
installer from here:
http://pgfoundry.org/frs/?group_id=1000256&release_id=1274. This should
then answer all your questions :)


HTH,

Mark.
--
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063
Yves Moisan
2009-02-17 14:55:06 UTC
Permalink
Post by Mark Cave-Ayland
Post by Yves Moisan
MessageBox MB_YESNO "Install PostgreSQL 8.3.5?" /SD IDYES IDNO endPG835
File "..\postgresql\postgresql-8.3-int.msi"
ExecWait '"msiexec" /i "postgresql-8.3-int.msi" /qr INTERNALLAUNCH=1
SERVICEACCOUNT="postgres" \
SERVICEPASSWORD="xyz" CREATESERVICEUSER=1 SUPERUSER="postgres"
SUPERPASSWORD="xyz" LISTENPORT=5433 \
PERMITREMOTE=1 ENCODING=latin1 BASEDIR="$INSTDIR\postgresql"
TRANSFORMS=:lang_fr'
MessageBox MB_YESNO "Install PostGIS 1.3.5 for 8.3.5?" /SD IDYES IDNO
endPostGIS
File "..\postgis\postgis-pg83-setup-1.3.5-1.exe"
ExecWait "$INSTDIR\postgis-pg83-setup-1.3.5-1.exe /D=$INSTDIR
\postgresql"
Hi Yves,
You can download a zip-file containing the GPL'd source for the Win32
http://pgfoundry.org/frs/?group_id=1000256&release_id=1274. This should
then answer all your questions :)
Hi Mark,

I can see the postgis.nsi file and all it depends upon, but what I'm
most interested in is just calling the generated installer file (.exe)
from within my own installer. An Exec command on the postgis...exe
should work.

In fact, I'm guessing the way I install postgresql (access of the
postgres account, file persmissions ??) to begin with has problems
because the postgis installer chokes even if I do it directly (out of my
NSIS script). I've installed postgis many times but it is the first
time I get a message warning me of the existence of a database object
that does not exist.

I read that the postgres user should have an "edit database object"
permission (saw that on a Django list) but I can't find that in pgAdmin.
I'll keep looking at the code to see if I can find the answers I'm
looking for.

Thanx,

Yves
Yves Moisan
2009-02-17 20:50:43 UTC
Permalink
Post by Mark Cave-Ayland
You can download a zip-file containing the GPL'd source for the Win32
http://pgfoundry.org/frs/?group_id=1000256&release_id=1274. This should
then answer all your questions :)
Some results. First, I tried commenting out the sections on checking
the existence of template_postgis but I need a couple more pieces to be
able to build the NSI file on my system. Is there a location where I
can find all files or do I have to set up mingw and execute the bash
files ?

Anyhow, I manually created template_postgis in pgAdmin just to test the
postGIS installer :

CREATE DATABASE template_postgis
WITH OWNER = postgres ENCODING = 'WIN1252'

Then when I run the postGIS installer I have the message saying
template_postgis exists (which this time is true) and if I proceed it
will overwrite it, so I go "yes" and it does the delete of the existing
template_postgis object and creates the new one fine. From then on, the
rest of the postGIS installation runs fine. Only glitch is that my
newly created template_postgis object now reads :

CREATE DATABASE template_postgis
WITH OWNER = postgres ENCODING = 'UTF-8'

So there's an encoding problem. The NSI file mentions Unicode as
encoding ??

To summarize :

- I have found the installer to think template_postgis exists whereas it
does not exist (which causes the installer to crash when it tries to
delete a non-existing object)

- It is not possible to specify an encoding other that UTF-8

If I could easily build the NSI file I could try and play with the
condition that checks the existence of the template_postgis object.

Cheers,

Yves
Mark Cave-Ayland
2009-02-18 18:26:18 UTC
Permalink
Post by Yves Moisan
Some results. First, I tried commenting out the sections on checking
the existence of template_postgis but I need a couple more pieces to be
able to build the NSI file on my system. Is there a location where I
can find all files or do I have to set up mingw and execute the bash
files ?
Anyhow, I manually created template_postgis in pgAdmin just to test the
CREATE DATABASE template_postgis
WITH OWNER = postgres ENCODING = 'WIN1252'
Then when I run the postGIS installer I have the message saying
template_postgis exists (which this time is true) and if I proceed it
will overwrite it, so I go "yes" and it does the delete of the existing
template_postgis object and creates the new one fine. From then on, the
rest of the postGIS installation runs fine. Only glitch is that my
CREATE DATABASE template_postgis
WITH OWNER = postgres ENCODING = 'UTF-8'
So there's an encoding problem. The NSI file mentions Unicode as
encoding ??
- I have found the installer to think template_postgis exists whereas it
does not exist (which causes the installer to crash when it tries to
delete a non-existing object)
- It is not possible to specify an encoding other that UTF-8
If I could easily build the NSI file I could try and play with the
condition that checks the existence of the template_postgis object.
Cheers,
Yves
Hi Yves,

If you check the source you can see that all the installer does is
create some batch files to launch psql and run them in the background.
Hence if you look in the %TEMP%\postgis_installer directory you should
be able to see these batch files, along with any error output produced
by each one. Normally it is fairly easy to find out what is going wrong
by running these files manually.


HTH,

Mark.
--
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063
Yves Moisan
2009-02-18 20:58:25 UTC
Permalink
Post by Mark Cave-Ayland
Hi Yves,
If you check the source you can see that all the installer does is
create some batch files to launch psql and run them in the background.
Hence if you look in the %TEMP%\postgis_installer directory you should
be able to see these batch files, along with any error output produced
by each one. Normally it is fairly easy to find out what is going wrong
by running these files manually.
Hi Mark,

What I ended up doing is to create the template_postgis object manually
through a batch file exactly like you do in postgis.nsi. I fought with
different ways of launching creadb.exe or psql.exe without having to
specify a password but the only way to do that is through encapsulating
the whole thing in a batch file like you do (forget redirecting the
input of psql or setting some .pgpass file).

There still is an issue with the condition that makes the postgis
installer think there already is a template_postgis when there is none,
but at least now I can create one manually before calling the postgis
installer executable and things are ok.

I don't have the time or power to do much more in terms of making the
installer script behave in a better manner, but if I may express a
wishlist, here goes (besides fixing the condition mentioned above) :

- have the encoding of the template_postgis database the same as the
default of the postgresql installation (e.g. in my case WIN1252)

- have a silent mode

Thanx for your time. I learned a couple more NSIS tricks by looking at
your code :-).

Yves
Post by Mark Cave-Ayland
HTH,
Mark.
Loading...