Re: Extension Packaging

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Extension Packaging
Date: 2011-04-21 03:04:39
Message-ID: BANLkTikh8KNEk28gYOpDB7wrMtLPYnPbvw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Apr 21, 2011 at 1:14 AM, David E. Wheeler <david(at)kineticode(dot)com> wrote:

> I finally got round to updating a couple of my extensions to support 9.1 extensions. Unlike the contrib extensions, these needed to target older versions of PostgreSQL, as well. Case in point, the semver data type; you might find the Makefile of particular interest:
>
>  https://github.com/theory/pg-semver/blob/master/Makefile

Hi David, thanks for sharing.

I've recently packaged an extension for PG 8.4-9.1 and had to wrestle
the Makefile too. You may take a look at it and check if there is any
solution useful for your extension too:
<https://github.com/dvarrazzo/pgmp/blob/master/Makefile>.

Specifically, I parse the version from the control file using:

PGMP_VERSION=$(shell grep default_version pgmp.control | sed -e
"s/default_version = '\(.*\)'/\1/")

so the Makefile doesn't have to be maintained for it. To tell apart <
9.1 and >= 9.1 I've used instead:

PG91 = $(shell $(PG_CONFIG) --version | grep -qE " 8\.| 9\.0" &&
echo pre91 || echo 91)
ifeq ($(PG91),91)
...
else
...

For my extension I'm less concerned by having the install sql named in
different ways or by the upgrade sql as all these files are generated
by scripts. You may find useful this one
<https://github.com/dvarrazzo/pgmp/blob/master/tools/sql2extension.py>
to generate the upgrade sql from the install sql. For my extension I
require Python and have all the sql files generated by the Makefile at
install time; if you don't want this dependency you may generate the
sql before packaging and ship the result instead.

Cheers,

-- Daniele

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-04-21 03:05:25 Re: pg_dump --binary-upgrade vs. ALTER TYPE ... DROP ATTRIBUTE
Previous Message Robert Haas 2011-04-21 03:02:25 Re: Typed table DDL loose ends