Re: Extension Packaging - Mailing list pgsql-hackers

From Daniele Varrazzo
Subject Re: Extension Packaging
Date
Msg-id BANLkTikh8KNEk28gYOpDB7wrMtLPYnPbvw@mail.gmail.com
Whole thread Raw
In response to Extension Packaging  ("David E. Wheeler" <david@kineticode.com>)
Responses Re: Extension Packaging  ("David E. Wheeler" <david@kineticode.com>)
Re: Extension Packaging  (Dimitri Fontaine <dimitri@2ndQuadrant.fr>)
List pgsql-hackers
On Thu, Apr 21, 2011 at 1:14 AM, David E. Wheeler <david@kineticode.com> wrote:

> I finally got round to updating a couple of my extensions to support 9.1 extensions. Unlike the contrib extensions,
theseneeded to target older versions of PostgreSQL, as well. Case in point, the semver data type; you might find the
Makefileof 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


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Typed table DDL loose ends
Next
From: Robert Haas
Date:
Subject: Re: pg_dump --binary-upgrade vs. ALTER TYPE ... DROP ATTRIBUTE