Relocatable installs

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Relocatable installs
Date: 2004-05-08 18:48:37
Message-ID: 200405081848.i48Imbn26138@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Win32 is going to need relocatable installs, and Unix packagers have
asked for this too.

A relocatable install is one where you can do 'gmake install', tar up
the directory where you installed it, then untar it on to another
machine with the same operating system, but into a different directory
location.

For example, if you use the defaults for directory locations, PostgreSQL
will install into /usr/local/pgsql, and everything will be under that
directory --- bin, lib, include, share. (Not sure about etc, doc, and
man.)

However, right now, if you try to move /usr/local/pgsql to /var/pgsql,
the database will not work because there are hard-coded directory
dependencies in the binaries:

initdb has to find its *.bki files in /share
initdb has to find the postgres binary in /bin
pg_dumpall has to find pg_dump
postgres has to find shared objects the /lib
Win32 postgres has to find /share/timezone

Maybe there are more.

Anyway, one idea for relocatable installs is to drive everything off of
the bin directory. We know the full path of the binary we are running
by looking at argv[0] or looking in $PATH. From there, we can find the
needed directories by looking relative to the /bin directory. So, by
default, installs in /usr/local/pgsql have binaries in
/usr/local/pgsql/bin, and the lib directory is ../lib relative to /bin.

This seems like a logical way to allow relocatable installs. The only
problem is with more complex configurations. Suppose you add configure
flags to install binaries in /usr/local/bin, and libs in /usr/local/lib.
Now, if you move your binaries to /usr/bin, it will be looking for libs
in /usr/lib, while they might still be in /usr/local/lib. Even more
complex installs are possible, with binaries in /usr/bin and libraries
in /usr/share/pgsql/lib.

My idea is to write a /port function that uses various methods to find
the needed files. We could look in the relative location first, and if
the needed file is not found, look in the hardcoded directory.

Comments?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2004-05-08 19:02:48 mingw configure failure detection
Previous Message Bernd Helmle 2004-05-08 18:48:33 Re: email built in type