Debian Codegraph @

debhelper/Debian/Debhelper/pgxs.pm

raw
1 # A debhelper build system class for building PostgreSQL extension modules using PGXS
2 #
3 # Copyright: © 2020 Christoph Berg
4 # License: GPL-2+
5
6 package Debian::Debhelper::pgxs;
7
8 use strict;
9 use warnings;
10 use Exporter 'import';
11 our @EXPORT = qw(package_pattern);
12
13 =head1 package_pattern()
14
15 From C<debian/control.in>, look for the package name containing the
16 B<PGVERSION> placeholder, and return it in the format suitable for passing to
17 B<pg_buildext>, i.e. with B<PGVERSION> replaced by B<%v>.
18
19 For B<Package: postgresql-PGVERSION-unit> it will return B<postgresql-%v-unit>.
20
21 Errors out if more than one package with the B<PGVERSION> placeholder is found.
22
23 =cut
24
25 sub package_pattern () {
26 open F, "debian/control.in" or die "debian/control.in: $!";
27 my $pattern;
28 while (<F>) {
29 if (/^Package: (.*)PGVERSION(.*)/) {
30 die "More than one Package with PGVERSION placeholder found in debian/control.in, cannot build with dh --buildsystem=pgxs. Use pg_buildext manually." if ($pattern);
31 $pattern = "$1%v$2";
32 }
33 }
34 close F;
35 return $pattern;
36 }
37
38 1;