Commit 72d5f51a authored by Christoph Berg's avatar Christoph Berg

Start porting the postgresql-common framework to RedHat, backed by the

PGDG PostgreSQL rpm packages.
parent b1bb6bb5
......@@ -29,7 +29,7 @@ our @EXPORT = qw/error user_cluster_map get_cluster_port set_cluster_port
get_version_clusters next_free_port cluster_exists install_file
change_ugid config_bool get_db_encoding get_db_locales get_cluster_locales
get_cluster_databases read_cluster_conf_file read_pg_hba/;
our @EXPORT_OK = qw/$confroot quote_conf_value read_conf_file get_conf_value
our @EXPORT_OK = qw/$confroot $binroot quote_conf_value read_conf_file get_conf_value
set_conf_value set_conffile_value disable_conffile_value disable_conf_value
replace_conf_value cluster_data_directory get_file_device read_pidfile
check_pidfile_running/;
......@@ -50,7 +50,8 @@ if ($ENV{'PGSYSCONFDIR'}) {
($common_confdir) = $ENV{'PGSYSCONFDIR'} =~ /(.*)/; # untaint
}
my $mapfile = "$common_confdir/user_clusters";
my $binroot = "/usr/lib/postgresql";
our $binroot = "/usr/lib/postgresql/";
#redhat# $binroot = "/usr/pgsql-";
my $defaultport = 5432;
{
......@@ -379,6 +380,7 @@ sub get_cluster_socketdir {
$socketdir =~ s/\s*,.*// if ($socketdir); # ignore additional directories for now
return $socketdir if $socketdir;
#redhat# return '/tmp'; # RedHat PGDG packages default to /tmp
# try to determine whether this is a postgres owned cluster and we default
# to /var/run/postgresql
$socketdir = '/var/run/postgresql';
......@@ -414,7 +416,7 @@ sub set_cluster_socketdir {
# Arguments: <program name> <version>
sub get_program_path {
return '' unless defined($_[0]) && defined($_[1]);
my $path = "$binroot/$_[1]/bin/$_[0]";
my $path = "$binroot$_[1]/bin/$_[0]";
($path) = $path =~ /(.*)/; #untaint
return $path if -x $path;
return '';
......@@ -633,11 +635,15 @@ sub cluster_info {
# Return an array of all available PostgreSQL versions
sub get_versions {
my @versions = ();
if (opendir (D, $binroot)) {
my $dir = $binroot;
#redhat# $dir = '/usr';
if (opendir (D, $dir)) {
my $entry;
while (defined ($entry = readdir D)) {
next if $entry eq '.' || $entry eq '..';
($entry) = $entry =~ /^(\d+\.\d+)$/; # untaint
my $pfx = '';
#redhat# $pfx = "pgsql-";
($entry) = $entry =~ /^$pfx(\d+\.\d+)$/; # untaint
push @versions, $entry if get_program_path ('psql', $entry);
}
closedir D;
......
......@@ -6,6 +6,8 @@ postgresql-common (158) UNRELEASED; urgency=medium
/usr/bin anyway.
* pg_upgradecluster: Deprecate krb_srvname in 9.4.
* testsuite: Also mount /dev/shm; with -s, open shell on failure.
* Start porting the postgresql-common framework to RedHat, backed by the
PGDG PostgreSQL rpm packages.
* Debconf translation updates, thanks!
+ fr by Julien Patriarca. (Closes: #751101)
+ ja by victory. (Closes: #751131)
......
......@@ -97,13 +97,15 @@ unless ($version) {
}
}
error 'Invalid PostgreSQL cluster version' unless -d "/usr/lib/postgresql/$version";
error 'Invalid PostgreSQL cluster version' unless -d "$PgCommon::binroot$version";
my $cmdname = (split '/', $0)[-1];
my $cmd;
# for psql we always want the latest version, as this is backwards compatible
# to every major version that that we support
if ($cmdname =~ /^(psql|pg_archivecleanup|pg_isready)$/) {
if ($cmdname eq 'pg_wrapper') {
error "pg_wrapper should not be called directly, but through a symlink";
} elsif ($cmdname =~ /^(psql|pg_archivecleanup|pg_isready)$/) {
$cmd = get_program_path ($cmdname, get_newest_version);
} else {
$cmd = get_program_path ($cmdname, $version);
......@@ -139,7 +141,7 @@ if ($cmdname eq 'psql') {
}
}
error "pg_wrapper: $cmdname was not found in /usr/lib/postgresql/$version/bin" unless $cmd;
error "pg_wrapper: $cmdname was not found in $PgCommon::binroot$version/bin" unless $cmd;
unshift @ARGV, $cmd;
exec @ARGV;
......
Name: postgresql-common
Version: 158
Release: 1%{?dist}
BuildArch: noarch
Summary: PostgreSQL database-cluster manager
Packager: Debian PostgreSQL Maintainers <pkg-postgresql-public@lists.alioth.debian.org>
License: GPLv2+
URL: https://packages.debian.org/sid/%{name}
Source0: http://ftp.debian.org/debian/pool/main/p/%{name}/%{name}_%{version}.tar.xz
%description
The postgresql-common package provides a structure under which
multiple versions of PostgreSQL may be installed and/or multiple
clusters maintained at one time.
%package -n postgresql-client-common
Summary: manager for multiple PostgreSQL client versions
%description -n postgresql-client-common
The postgresql-client-common package provides a structure under which
multiple versions of PostgreSQL client programs may be installed at
the same time. It provides a wrapper which selects the right version
for the particular cluster you want to access (with a command line
option, an environment variable, /etc/postgresql-common/user_clusters,
or ~/.postgresqlrc).
%package -n postgresql-server-dev-all
Summary: extension build tool for multiple PostgreSQL versions
%description -n postgresql-server-dev-all
The postgresql-server-dev-all package provides the pg_buildext script for
simplifying packaging of a PostgreSQL extension supporting multiple major
versions of the product.
%prep
# unpack tarball, ignoring the name of the top level directory inside
%setup -c
mv */* .
%build
make
%install
rm -rf %{buildroot}
# install in subpackages using the Debian files
for inst in debian/*.install; do
pkg=$(basename $inst .install)
echo "### Reading $pkg files list from $inst ###"
while read file dir; do
mkdir -p %{buildroot}/$dir
cp -r $file %{buildroot}/$dir
echo "/$dir/${file##*/}" >> files-$pkg
done < $inst
done
for manpages in debian/*.manpages; do
pkg=$(basename $manpages .manpages)
echo "### Reading $pkg manpages list from $manpages ###"
while read file; do
section="${file##*.}"
mandir="%{buildroot}%{_mandir}/man$section"
mkdir -p $mandir
for f in $file; do # expand wildcards
cp $f $mandir
echo "%doc %{_mandir}/man$section/$f.gz" >> files-$pkg
done
done < $manpages
done
while read dest link; do
name="pgsql-$(basename $link)"
echo "update-alternatives --install /$link $name /$dest 9999" >> postgresql-client-common.post
echo "update-alternatives --remove $name /$dest" >> postgresql-client-common.preun
done < debian/postgresql-client-common.links
sed -i -e 's/^[[:space:]]*#redhat# *//' \
%{buildroot}/usr/share/postgresql-common/PgCommon.pm \
%{buildroot}/usr/share/postgresql-common/testsuite
#cp debian/postgresql-common.postinst %{buildroot}/usr/share/postgresql-common
%files -n postgresql-common -f files-postgresql-common
%attr(0755, root, root) /usr/share/postgresql-common/postgresql-common.postinst
%files -n postgresql-client-common -f files-postgresql-client-common
%files -n postgresql-server-dev-all -f files-postgresql-server-dev-all
#%post
## RedHat's adduser is different, create the user here
#if ! getent passwd postgres > /dev/null; then
# adduser --system --home /var/lib/postgresql --no-create-home \
# --shell /bin/bash --comment "PostgreSQL administrator" postgres
#fi
#sh -x /usr/share/postgresql-common/postgresql-common.postinst "configure"
%post -n postgresql-client-common -f postgresql-client-common.post
%preun -n postgresql-client-common -f postgresql-client-common.preun
%changelog
* Thu Jun 5 2014 Christoph Berg <christoph.berg@credativ.de> 158-1
- Initial specfile version
......@@ -4,7 +4,8 @@ use strict;
use lib 't';
use TestLib;
use Dpkg::Version;
#FIXME: use Dpkg::Version;
use PgCommon qw/$binroot/;
use Test::More tests => (@MAJORS) * 4 + 1;
......@@ -13,9 +14,9 @@ use Test::More tests => (@MAJORS) * 4 + 1;
my ($want_lib, $avoid_lib) = $ENV{PG_READLINE} ? qw(libreadline libedit) : qw(libedit libreadline);
foreach my $v (@MAJORS) {
like_program_out (0, "ldd /usr/lib/postgresql/$v/bin/psql", 0, qr/$want_lib\.so\./,
like_program_out (0, "ldd $binroot$v/bin/psql", 0, qr/$want_lib\.so\./,
"psql is linked against $want_lib");
unlike_program_out (0, "ldd /usr/lib/postgresql/$v/bin/psql", 0, qr/$avoid_lib\.so\./,
unlike_program_out (0, "ldd $binroot$v/bin/psql", 0, qr/$avoid_lib\.so\./,
"psql is not linked against $avoid_lib");
}
......
......@@ -68,6 +68,8 @@ if [ "${INSTALL:-}" ] && [ -z "${UNSHARED:-}" ]; then
netcat-openbsd \
hunspell-en-us
fi
# requirements on RedHat:
# perl-Time-HiRes
# re-exec ourselves through unshare
if [ -z "$UNSHARED" ]; then
......@@ -91,7 +93,7 @@ if [ -e /etc/locale.gen ]; then
ru_RU.UTF-8 UTF-8
EOF
[ "$run" ] && locale-gen
else
elif [ -x /usr/sbin/locale-gen ]; then
# Ubuntu
# locale-gen will skip existing locales, so just call it for all here
locale-gen en_US.UTF-8 ru_RU ru_RU.UTF-8
......@@ -138,6 +140,7 @@ ifconfig lo up || true
unset TMPDIR
unset LC_ALL
export LANG=en_US.utf8
#redhat# export PG_READLINE=1
# set variables which cause taint check errors
export IFS=' '
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment