Detecting Postgres version during build

Richard W.M. Jones rjones at
Tue Mar 6 15:00:59 UTC 2012

On Tue, Mar 06, 2012 at 01:13:24AM +0100, Gianluca Sforna wrote:
> I am trying to build a package that provides a Postegres cartridge
> compatible with 8.x and 9.x. Unfortunately the cartridge related files
> are not installed in the same path for both version so I am looking
> for a way to query the version against I'm building and pick the
> correct path.
> Is there any standard mean for doing what I need?

If you BuildRequire the database itself (likely you don't) then
postgres --version + some scripting seems to do what you want:

$ postgres --version | awk '{print $3}'

I suspect this isn't going to do what your users need.  What happens
if they connect to a remote PostgreSQL database?  I'm guessing they
could use either cartridge depending on the remote version, so you
probably want to build and install both of them, if that is possible.

More context could help, including knowing which package you are
trying to build and what this "cartridge" actually does.


Richard Jones, Virtualization Group, Red Hat
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.

More information about the devel mailing list