postgresql-setup is now in separate tarball

.. together with other scripts and files.  This should make the
development and testing of those files easier.  Also packaging
should benefit from this change.

Version: 9.3.5-6
Resolves: #1145129
This commit is contained in:
Pavel Raiskup 2014-07-02 18:14:06 +02:00
parent 721530b8e4
commit c88f76d540
7 changed files with 55 additions and 799 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/postgresql-9.2.9.tar.bz2 /postgresql-9.2.9.tar.bz2
/postgresql-9.2.9.tar.bz2.sha256 /postgresql-9.2.9.tar.bz2.sha256
/postgresql-9.3.5-US.pdf /postgresql-9.3.5-US.pdf
/postgresql-setup-1.0.0.tar.gz

View File

@ -1,357 +0,0 @@
README.rpm-dist
-----------------------------------------------------------------------------
Version 9.3, for the PostgreSQL 9.3 RPM set.
Devrim Gündüz <devrim@gunduz.org>
-----------------------------------------------------------------------------
Contents:
1.) Introduction and QuickStart
2.) Upgrading an installation
3.) PostgreSQL RPM packages and rationale
4.) Starting multiple postmasters
5.) Regression Testing
6.) Starting postmaster automatically on startup
7.) Grand Unified Configuration(GUC) File
8.) Logging set up
9.) Rebuilding from the source RPM
10.) Contrib files
11.) Further Information Resource
INTRODUCTION
-----------------------------------------------------------------------------
This document exists to explain the layout of the RPMs for PostgreSQL, to
describe various RPM specifics, and to document special features found
in the RPMset.
This document is written to be applicable to version 9.3 of PostgreSQL,
which is the current version of the RPMs as of this writing. More to the
point, versions prior to 9.3 are not documented here.
This document is intended for use only with the RPMs supplied in Red Hat
Enterprise Linux, CentOS and Fedora. Note that there are also "PGDG"
RPMs available directly from the upstream PostgreSQL project. Those are
slightly different.
QUICKSTART (note that this requires postgresql-server installed)
-----------------------------------------------------------------------------
For a fresh installation, you will need to initialize the cluster first. Run:
postgresql-setup initdb
as root, and it will prepare a new database cluster for you. Then you will
need to start PostgreSQL. Again as root, run:
systemctl start postgresql.service
This command will start a postmaster that willl listen on localhost and Unix
socket 5432 only. Edit /var/lib/pgsql/data/postgresql.conf and pg_hba.conf
if you want to allow remote access -- see the section on Grand Unified
Configuration.
You will probably also want to do
systemctl enable postgresql.service
so that the postmaster is automatically started during future reboots.
The file /var/lib/pgsql/.bash_profile is packaged to help with the
setting of environment variables. You may edit this file, and it won't be
overwritten during an upgrade. However, enhancements and bugfixes may
be added to this file, so be sure to check .bash_profile.rpmnew after
upgrading.
The user 'postgres' is created during installation of the server subpackage.
This user by default is UID and GID 26. The user has the default shell set to
bash, and the home directory set to /var/lib/pgsql. This user also has no
default password, so the only way to become this user is to su to it from root.
If you want to be able to su to it from a non-root account or log in directly
as 'postgres' you will need to set a password using passwd.
UPGRADING AN INSTALLATION
-----------------------------------------------------------------------------
For a minor-version upgrade (such as 9.3.1 to 9.3.2), just install the
new RPMs; there's usually nothing more to it than that. Upgrading
across a major release of PostgreSQL (for example, from 9.2.x to 9.3.x)
requires more effort.
If you are upgrading across more than one major release of PostgreSQL
(for example, from 8.3.x to 9.0.x), you will need to follow the "traditional"
dump and reload process to bring your data into the new version. That is:
*before* upgrading, run pg_dumpall to extract all your data into a SQL file.
Shut down the old postmaster, upgrade to the new version RPMs, initdb,
and run the dump file through psql to restore your data.
In some major releases, the RPMs also support in-place upgrade from the
immediately previous major release. Currently, you can upgrade in-place
from 9.2.x to 9.3.x. This is much faster than a dump and reload.
To do an in-place upgrade:
* shut down the old postmaster ("systemctl stop postgresql.service")
* optionally make a backup of /var/lib/pgsql/data/ (recommended!)
* install the new version's RPMs (install all the ones you had before,
plus postgresql-upgrade)
* as root, run "postgresql-setup upgrade"
* update the configuration files /var/lib/pgsql/data/*.conf with any
customizations you had before (your old configuration files are in
/var/lib/pgsql/data-old/)
* as root, run "systemctl start postgresql.service"
* the postgresql-upgrade RPM can be removed after the update is complete,
as can /var/lib/pgsql/data-old/
NOTE: The in-place upgrade process is new and relatively poorly tested,
so if your data is critical it's a really good idea to make a tarball
backup of /var/lib/pgsql/data/ before running the upgrade. This will
let you get back to where you were in case of disaster.
POSTGRESQL RPM PACKAGES AND RATIONALE.
-----------------------------------------------------------------------------
PostgreSQL is split up into multiple packages so that users can 'pick and
choose' what pieces are needed, and what dependencies are required.
The RPMset is packaged in the following subpackages:
postgresql: Key client programs and basic documentation
postgresql-libs: Client shared libraries
postgresql-server: Server executables and data files
postgresql-devel: Development libraries and include files
postgresql-test: The regression tests and associated files
postgresql-upgrade: Support files for upgrading from previous major version
postgresql-docs: Full documentation in HTML and PDF, the tutorial files
postgresql-contrib: Add-on loadable modules and programs
postgresql-plperl: PL/Perl procedural language
postgresql-plpython: PL/Python procedural language (for Python 2)
postgresql-plpython3: PL/Python procedural language (for Python 3)
postgresql-pltcl: PL/Tcl procedural language
You have to install postgresql and postgresql-libs to do anything.
postgresql-server is needed unless you only plan to use the clients to work
with a remote PostgreSQL server. The others are optional.
Note that there are no postgresql-perl, postgresql-jdbc, postgresql-odbc,
postgresql-python, postgresql-tcl, or postgresql-tk subpackages any longer.
Those programs have been split off into separate source distributions.
They are still available, but in some cases not under those RPM names.
RPM FILE LOCATIONS.
-----------------------------------------------------------------------------
To be in compliance with the Linux FHS, the PostgreSQL RPMs install files in
a manner not consistent with most of the PostgreSQL documentation. According
to the standard PostgreSQL documentation, PostgreSQL is installed under the
directory /usr/local/pgsql, with executables, source, and data existing in
various subdirectories.
Different distributions have different ideas of some of these file locations.
In particular, the documentation directory can be /usr/doc, /usr/doc/packages,
/usr/share/doc, /usr/share/doc/packages, or some other similar path.
However, the Red Hat / CentOS / Fedora RPM's install the files like
this:
Executables: /usr/bin
Libraries: /usr/lib (or /usr/lib64 on 64-bit machines)
Documentation: /usr/share/doc/postgresql/html
PDF documentation: /usr/share/doc/postgresql-docs
Contrib documentation: /usr/share/doc/postgresql-contrib
Source: not installed
Data: /var/lib/pgsql/data
Backup area: /var/lib/pgsql/backups
Templates: /usr/share/pgsql
Procedural Languages: /usr/lib/pgsql or /usr/lib64/pgsql
Development Headers: /usr/include/pgsql
Other shared data: /usr/share/pgsql
Regression tests: /usr/lib/pgsql/test/regress (in the -test package)
or /usr/lib64/pgsql/test/regress
While it may seem gratuitous to place these files in different locations, the
FHS requires it -- distributions should not ever touch /usr/local. It may
also seem like more work to keep track of where everything is -- but, that's
the beauty of RPM -- you don't have to keep track of the files, RPM does it
for you.
These RPMs are designed to be LSB-compliant -- if you find this not to be the
case, please let us know by way of the pgsql-pkg-yum@postgresql.org
mailing list.
MULTIPLE POSTMASTERS
-------------------------------------------------------------------------------
The postgresql-server RPM contains a systemd "unit" file, postgresql.service,
that is used to start the PostgreSQL postmaster. If you need to run multiple
postmasters on one machine, you can create additional unit files derived
from this one.
As an example, let us create a secondary postmaster called, creatively enough,
'secondary'. Here are the steps:
1.) Create a file named /etc/systemd/system/secondary.service.
(Note that user-created unit files must go into /etc not /lib!)
Put these lines in it:
.include /lib/systemd/system/postgresql.service
[Service]
Environment=PGPORT=nnnn
Environment=PGDATA=/path/to/data/directory
Replace "nnnn" and "/path/to/data/directory" with appropriate
settings that don't conflict with any other postmaster.
2.) As root, do "/bin/systemctl daemon-reload" to ensure systemd has
noticed your updates to the service file.
3.) Create the target PGDATA directory, making sure that its parent
directories have appropriate ownership and permissions.
4.) Initdb the target PGDATA with 'postgresql-setup initdb secondary'.
5.) Edit postgresql.conf in the target PGDATA to change settings as needed.
6.) Start the new postmaster with 'systemctl start secondary.service'.
You will probably also want to do 'systemctl enable secondary.service'
so that the new postmaster is automatically started in future reboots.
When doing a major-version upgrade of a secondary postmaster, add the
service name to the postgresql-setup command, for example 'postgresql-setup
upgrade secondary'. This will let postgresql-setup find the correct data
directory from the service file.
If you are running SELinux in enforcing mode (which is highly recommended,
particularly for network-exposed services like PostgreSQL) you will need to
adjust SELinux policy to allow the postmaster to use non-default PGPORT or
PGDATA settings. To allow use of a non-default port, say 5433, do this
as root:
semanage port -a -t postgresql_port_t -p tcp 5433
To allow use of a non-default data directory, say /special/pgdata, do:
semanage fcontext -a -t postgresql_db_t "/special/pgdata(/.*)?"
If you already created the directory, follow that with:
restorecon -R /special/pgdata
These settings are persistent across reboots. For more information
see "man semanage".
REGRESSION TESTING
-------------------------------------------------------------------------------
If you install the postgresql-test RPM then you can run the PostgreSQL
regression tests. These tests stress your database installation and produce
results that give you assurances that the installation is complete, and that
your database machine is up to the task.
To run the regression tests under the RPM installation, make sure that the
postmaster has been started (if not, su to root and do "systemctl start
postgresql.service"), su to postgres, cd to /usr/lib/pgsql/test/regress
(or /usr/lib64/pgsql/test/regress on a 64-bit machine),
and execute "make check".
This command will start the regression tests and will both show the
results to the screen and store the results in the file regress.out.
If any tests fail, see the file regression.diffs in that directory for details,
and read the "Regression Tests" section of the PostgreSQL documentation to
find out whether the differences are actually significant. If you need help
interpreting the results, contact the pgsql-general list at
postgresql.org.
After testing, run "make clean" to remove the files generated by the test
script. Then you can remove the postgresql-test RPM, if you wish.
STARTING POSTMASTER AUTOMATICALLY AT SYSTEM STARTUP
-------------------------------------------------------------------------------
Fedora / Red Hat / CentOS use the systemd package to manage server startup.
A systemd unit file for PostgreSQL is provided in the server package, as
/lib/systemd/system/postgresql.service. To start the postmaster manually,
as root run
systemctl start postgresql.service
To shut the postmaster down,
systemctl stop postgresql.service
These two commands only change the postmaster's current status. If you
want the postmaster to be started automatically during future system startups,
run
systemctl enable postgresql.service
To undo that again,
systemctl disable postgresql.service
See "man systemctl" for other possible subcommands.
GRAND UNIFIED CONFIGURATION (GUC) FILE
-------------------------------------------------------------------------------
The PostgreSQL server has many tunable parameters -- the file
/var/lib/pgsql/data/postgresql.conf is the master configuration file for the
whole system.
The RPM ships with a mostly-default file -- you will need to tune the
parameters for your installation. In particular, you might want to allow
nonlocal TCP/IP socket connections -- in order to allow these, you will need
to edit the postgresql.conf file. The line in question contains the string
'listen_addresses' -- you need to both uncomment the line and set the value
to '*' to get the postmaster to accept nonlocal connections. You'll also need
to adjust pg_hba.conf appropriately.
LOGGING SET UP
-------------------------------------------------------------------------------
By default, the postmaster's stderr log is directed into files placed in a
pg_log subdirectory of the data directory (ie, /var/lib/pgsql/data/pg_log).
The out-of-the-box configuration rotates among seven files, one for each
day of the week. You can adjust this by changing postgresql.conf settings.
REBUILDING FROM SOURCE RPM
-------------------------------------------------------------------------------
If your distribution is not supported by the binary RPMs from PostgreSQL.org,
you will need to rebuild from the source RPM.
If you have not previously rebuilt any RPMs, set up the required environment:
make a work directory, say ~/rpmwork, then cd into it and do
mkdir BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
Then make a file ~/.rpmmacros containing
%_topdir <full path to work directory here>
Download the postgresql .src.rpm for the release you want and place it in
the SRPMS subdirectory, then cd there and execute
rpmbuild --rebuild postgresql-nnn.src.rpm
The results will appear under the RPMS subdirectory.
You will have to have a full development environment to rebuild the RPM set.
If rpmbuild complains of lack of certain packages, install them and try
again. In some cases, you can disable features to avoid needing some
development packages, as detailed next.
This release of the RPMset includes the ability to conditionally build
sets of packages. The parameters, their defaults, and the meanings are:
beta 0 #build with cassert and do not strip the binaries
runselftest 1 #do "make check" during the build
test 1 #build the postgresql-test package
upgrade 1 #build the postgresql-upgrade package
plpython 1 #build the PL/Python procedural language package
plpython3 1 #build the PL/Python3 procedural language package
pltcl 1 #build the PL/Tcl procedural language package
plperl 1 #build the PL/Perl procedural language package
ssl 1 #build with OpenSSL support
kerberos 1 #build with Kerberos 5 support
ldap 1 #build with LDAP support
nls 1 #build with national language support
pam 1 #build with PAM support
sdt 1 #build with SystemTap support
xml 1 #build with XML support
pgfts 1 #build with --enable-thread-safety
selinux 1 #build contrib/selinux
uuid 1 #build contrib/uuid-ossp
To use these defines, invoke a rebuild like this:
rpmbuild --rebuild --define 'plpython 0' --define 'pltcl 0' \
--define 'test 0' --define 'runselftest 0' --define 'kerberos 0' \
postgresql-9.2.0-1.src.rpm
This line would disable the plpython, pltcl, and test subpackages, disable
the regression test run during build, and disable kerberos support.
You might need to disable runselftest if there is an installed version of
PostgreSQL that is a different major version from what you are trying to
build. The self test tends to pick up the installed libpq.so shared library
in place of the one being built :-(, so if that isn't compatible the test will
fail. Also, you can't use runselftest when doing the build as root.
More of these conditionals will be added in the future.
CONTRIB FILES
-------------------------------------------------------------------------------
The contents of the contrib tree are packaged into the -contrib subpackage
and are processed with make and make install. There is documentation in
/usr/share/doc/postgresql-contrib for these modules. Most of the
modules are in /usr/lib/pgsql (or /usr/lib64/pgsql) for loadable
modules, and binaries are in /usr/bin. In the future these files may be
split out, depending upon function and dependencies.
MORE INFORMATION
-------------------------------------------------------------------------------
You can get more information at http://www.postgresql.org and
http://yum.postgresql.org
Please help make this packaging better -- let us know if you find problems, or
better ways of doing things. You can reach us by e-mail at
pgsql-pkg-yum@postgresql.org
-------------------------------------------------------------------------------

View File

@ -1,57 +0,0 @@
#!/bin/sh
# This script verifies that the postgresql data directory has been correctly
# initialized. We do not want to automatically initdb it, because that has
# a risk of catastrophic failure (ie, overwriting a valuable database) in
# corner cases, such as a remotely mounted database on a volume that's a
# bit slow to mount. But we can at least emit a message advising newbies
# what to do.
PGDATA="$1"
if [ -z "$PGDATA" ]
then
echo "Usage: $0 database-path"
exit 1
fi
# PGVERSION is the full package version, e.g., 9.1.2
# Note: the specfile inserts the correct value during package build
PGVERSION=xxxx
# PGMAJORVERSION is major version, e.g., 9.1 (this should match PG_VERSION)
PGMAJORVERSION=`echo "$PGVERSION" | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/'`
# PREVMAJORVERSION is the previous major version, e.g., 8.4, for upgrades
# Note: the specfile inserts the correct value during package build
PREVMAJORVERSION=xxxx
# PGDOCDIR is the directory containing the package's documentation
# Note: the specfile inserts the correct value during package build
PGDOCDIR=xxxx
# Check for the PGDATA structure
if [ -f "$PGDATA/PG_VERSION" ] && [ -d "$PGDATA/base" ]
then
# Check version of existing PGDATA
if [ x`cat "$PGDATA/PG_VERSION"` = x"$PGMAJORVERSION" ]
then
: A-OK
elif [ x`cat "$PGDATA/PG_VERSION"` = x"$PREVMAJORVERSION" ]
then
echo $"An old version of the database format was found."
echo $"Use \"postgresql-setup upgrade\" to upgrade to version $PGMAJORVERSION."
echo $"See $PGDOCDIR/README.rpm-dist for more information."
exit 1
else
echo $"An old version of the database format was found."
echo $"You need to dump and reload before using PostgreSQL $PGMAJORVERSION."
echo $"See $PGDOCDIR/README.rpm-dist for more information."
exit 1
fi
else
# No existing PGDATA! Warn the user to initdb it.
echo $"\"$PGDATA\" is missing or empty."
echo $"Use \"postgresql-setup initdb\" to initialize the database cluster."
echo $"See $PGDOCDIR/README.rpm-dist for more information."
exit 1
fi
exit 0

View File

@ -1,268 +0,0 @@
#!/bin/bash
#
# postgresql-setup - Initialization and upgrade operations for PostgreSQL
test -z "$PATH" && export PATH="/sbin:/usr/sbin:/bin:/usr/bin"
test x"$PGSETUP_DEBUG" != x && set -x
# PGVERSION is the full package version, e.g., 9.0.2
# Note: the specfile inserts the correct value during package build
PGVERSION=xxxx
# PGMAJORVERSION is the major version, e.g. 9.0
PGMAJORVERSION=xxxx
# PGENGINE is the directory containing the postmaster executable
PGENGINE=xxxx
# PREVMAJORVERSION is the previous major version, e.g., 8.4, for upgrades
PREVMAJORVERSION=xxxx
# PREVPGENGINE is the directory containing the previous postmaster executable
PREVPGENGINE=xxxx
# Absorb configuration settings from the specified systemd service file,
# or the default "postgresql" service if not specified
SERVICE_NAME="$2"
if [ x"$SERVICE_NAME" = x ]; then
SERVICE_NAME=postgresql
fi
# Pathname of the RPM distribution README
README_RPM_DIST=xxxx
USAGE_STRING=$"
Usage: $0 {initdb|upgrade} [SERVICE_NAME]
Script is aimed to help sysadmin with basic database cluster administration.
The SERVICE_NAME is used for selection of proper unit configuration file; For
more info and howto/when use this script please look at the docu file
$README_RPM_DIST. The 'postgresql'
string is used when no SERVICE_NAME is explicitly passed.
Available operation mode:
initdb Create a new PostgreSQL database cluster. This is usually the
first action you perform after PostgreSQL server installation.
upgrade Upgrade PostgreSQL database cluster to be usable with new
server. Use this if you upgraded your PostgreSQL server to
newer major version (currently from $PREVMAJORVERSION \
to $PGMAJORVERSION).
Environment:
PGSETUP_INITDB_OPTIONS Options carried by this variable are passed to
subsequent call of \`initdb\` binary (see man
initdb(1)). This variable is used also during
'upgrade' mode because the new cluster is actually
re-initialized from the old one.
PGSETUP_PGUPGRADE_OPTIONS Options in this variable are passed next to the
subsequent call of \`pg_upgrade\`. For more info
about possible options please look at man
pg_upgrade(1).
PGSETUP_DEBUG Set to '1' if you want to see debugging output."
# note that these options are useful at least for help2man processing
case "$1" in
--version)
echo "postgresql-setup $PGVERSION"
exit 0
;;
--help|--usage)
echo "$USAGE_STRING"
exit 0
;;
esac
# this parsing technique fails for PGDATA pathnames containing spaces,
# but there's not much I can do about it given systemctl's output format...
PGDATA=`systemctl show -p Environment "${SERVICE_NAME}.service" |
sed 's/^Environment=//' | tr ' ' '\n' |
sed -n 's/^PGDATA=//p' | tail -n 1`
if [ x"$PGDATA" = x ]; then
echo "failed to find PGDATA setting in ${SERVICE_NAME}.service"
exit 1
fi
PGPORT=`systemctl show -p Environment "${SERVICE_NAME}.service" |
sed 's/^Environment=//' | tr ' ' '\n' |
sed -n 's/^PGPORT=//p' | tail -n 1`
if [ x"$PGPORT" = x ]; then
echo "failed to find PGPORT setting in ${SERVICE_NAME}.service"
exit 1
fi
# Log file for initdb
PGLOG=/var/lib/pgsql/initdb.log
# Log file for pg_upgrade
PGUPLOG=/var/lib/pgsql/pgupgrade.log
export PGDATA
export PGPORT
# For SELinux we need to use 'runuser' not 'su'
if command -v runuser &>/dev/null; then
SU=runuser
else
SU=su
fi
script_result=0
# code shared between initdb and upgrade actions
perform_initdb(){
if [ ! -e "$PGDATA" ]; then
mkdir "$PGDATA" || return 1
chown postgres:postgres "$PGDATA"
chmod go-rwx "$PGDATA"
fi
# Clean up SELinux tagging for PGDATA
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA"
# Create the initdb log file if needed
if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]; then
touch "$PGLOG" || return 1
chown postgres:postgres "$PGLOG"
chmod go-rwx "$PGLOG"
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
fi
# Initialize the database
initdbcmd="$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'"
initdbcmd+=" $PGSETUP_INITDB_OPTIONS"
$SU -l postgres -c "$initdbcmd" >> "$PGLOG" 2>&1 < /dev/null
# Create directory for postmaster log files
mkdir "$PGDATA/pg_log"
chown postgres:postgres "$PGDATA/pg_log"
chmod go-rwx "$PGDATA/pg_log"
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA/pg_log"
if [ -f "$PGDATA/PG_VERSION" ]; then
return 0
fi
return 1
}
initdb(){
if [ -f "$PGDATA/PG_VERSION" ]; then
echo $"Data directory is not empty!"
echo
script_result=1
else
echo -n $"Initializing database ... "
if perform_initdb; then
echo $"OK"
else
echo $"failed, see $PGLOG"
script_result=1
fi
echo
fi
}
upgrade(){
# must see previous version in PG_VERSION
if [ ! -f "$PGDATA/PG_VERSION" -o \
x`cat "$PGDATA/PG_VERSION"` != x"$PREVMAJORVERSION" ]
then
echo
echo $"Cannot upgrade because the database in $PGDATA is not of"
echo $"compatible previous version $PREVMAJORVERSION."
echo
exit 1
fi
if [ ! -x "$PGENGINE/pg_upgrade" ]; then
echo
echo $"Please install the postgresql-upgrade RPM."
echo
exit 5
fi
# Set up log file for pg_upgrade
rm -f "$PGUPLOG"
touch "$PGUPLOG" || exit 1
chown postgres:postgres "$PGUPLOG"
chmod go-rwx "$PGUPLOG"
[ -x /sbin/restorecon ] && /sbin/restorecon "$PGUPLOG"
# Move old DB to PGDATAOLD
PGDATAOLD="${PGDATA}-old"
rm -rf "$PGDATAOLD"
mv "$PGDATA" "$PGDATAOLD" || exit 1
# Create configuration file for upgrade process
HBA_CONF_BACKUP="$PGDATAOLD/pg_hba.conf.postgresql-setup.`date +%s`"
HBA_CONF_BACKUP_EXISTS=0
if [ ! -f $HBA_CONF_BACKUP ]; then
mv "$PGDATAOLD/pg_hba.conf" "$HBA_CONF_BACKUP"
HBA_CONF_BACKUP_EXISTS=1
# For fluent upgrade 'postgres' user should be able to connect
# to any database without password. Temporarily, no other type
# of connection is needed.
echo "local all postgres ident" > "$PGDATAOLD/pg_hba.conf"
fi
echo -n $"Upgrading database: "
# Create empty new-format database
if perform_initdb; then
# Do the upgrade
$SU -l postgres -c "$PGENGINE/pg_upgrade \
'--old-bindir=$PREVPGENGINE' \
'--new-bindir=$PGENGINE' \
'--old-datadir=$PGDATAOLD' \
'--new-datadir=$PGDATA' \
--link \
'--old-port=$PGPORT' '--new-port=$PGPORT' \
--user=postgres \
$PGSETUP_PGUPGRADE_OPTIONS" \
>> "$PGUPLOG" 2>&1 < /dev/null
if [ $? -ne 0 ]; then
# pg_upgrade failed
script_result=1
fi
else
# initdb failed
script_result=1
fi
# Move back the backed-up pg_hba.conf regardless of the script_result.
if [ x$HBA_CONF_BACKUP_EXISTS = x1 ]; then
mv -f "$HBA_CONF_BACKUP" "$PGDATAOLD/pg_hba.conf"
fi
if [ $script_result -eq 0 ]; then
echo $"OK"
echo
echo $"The configuration files were replaced by default configuration."
echo $"The previous configuration and data are stored in folder"
echo $PGDATAOLD.
else
# Clean up after failure
rm -rf "$PGDATA"
mv "$PGDATAOLD" "$PGDATA"
echo $"failed"
fi
echo
echo $"See $PGUPLOG for details."
}
# See how we were called.
case "$1" in
initdb)
initdb
;;
upgrade)
upgrade
;;
*)
echo >&2 "$USAGE_STRING"
exit 2
esac
exit $script_result

View File

@ -1,63 +0,0 @@
# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades. If you want to customize, the
# best way is to create a file "/etc/systemd/system/postgresql.service",
# containing
# .include /lib/systemd/system/postgresql.service
# ...make your changes here...
# For more info about custom unit files, see
# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
# For example, if you want to change the server's port number to 5433,
# create a file named "/etc/systemd/system/postgresql.service" containing:
# .include /lib/systemd/system/postgresql.service
# [Service]
# Environment=PGPORT=5433
# This will override the setting appearing below.
# Note: changing PGPORT or PGDATA will typically require adjusting SELinux
# configuration as well; see /usr/share/doc/postgresql/README.rpm-dist.
# Note: do not use a PGDATA pathname containing spaces, or you will
# break postgresql-setup.
# Note: in F-17 and beyond, /usr/lib/... is recommended in the .include line
# though /lib/... will still work.
[Unit]
Description=PostgreSQL database server
After=network.target
[Service]
Type=forking
User=postgres
Group=postgres
# Port number for server to listen on
Environment=PGPORT=5432
# Location of database directory
Environment=PGDATA=/var/lib/pgsql/data
# Where to send early-startup messages from the server (before the logging
# options of postgresql.conf take effect)
# This is normally controlled by the global default set by systemd
# StandardOutput=syslog
# Disable OOM kill on the postmaster
OOMScoreAdjust=-1000
# ... but allow it still to be effective for child processes
# (note that these settings are ignored by Postgres releases before 9.5)
Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
Environment=PG_OOM_ADJUST_VALUE=0
ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA}
ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300
ExecStop=/usr/bin/pg_ctl stop -D ${PGDATA} -s -m fast
ExecReload=/usr/bin/pg_ctl reload -D ${PGDATA} -s
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300
[Install]
WantedBy=multi-user.target

View File

@ -67,7 +67,7 @@ Summary: PostgreSQL client programs
Name: postgresql Name: postgresql
%global majorversion 9.3 %global majorversion 9.3
Version: 9.3.5 Version: 9.3.5
Release: 5%{?dist} Release: 6%{?dist}
# The PostgreSQL license is very similar to other MIT licenses, but the OSI # The PostgreSQL license is very similar to other MIT licenses, but the OSI
# recognizes it as an independent license, so we do as well. # recognizes it as an independent license, so we do as well.
@ -85,24 +85,26 @@ Url: http://www.postgresql.org/
%global prevversion 9.2.9 %global prevversion 9.2.9
%global prevmajorversion 9.2 %global prevmajorversion 9.2
%global setup_version 1.0.0
Source0: ftp://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2 Source0: ftp://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2
# The PDF file is generated by generate-pdf.sh, which see for comments # The PDF file is generated by generate-pdf.sh, which see for comments
Source1: postgresql-%{version}-US.pdf Source1: postgresql-%{version}-US.pdf
# generate-pdf.sh is not used during RPM build, but include for documentation # generate-pdf.sh is not used during RPM build, but include for documentation
Source2: generate-pdf.sh Source2: generate-pdf.sh
Source3: ftp://ftp.postgresql.org/pub/source/v%{prevversion}/postgresql-%{prevversion}.tar.bz2 Source3: ftp://ftp.postgresql.org/pub/source/v%{prevversion}/postgresql-%{prevversion}.tar.bz2
Source4: postgresql-check-db-dir Source4: Makefile.regress
Source5: Makefile.regress Source5: pg_config.h
Source6: pg_config.h Source6: ecpg_config.h
Source7: ecpg_config.h Source7: initdb.sh
Source8: README.rpm-dist Source8: upgrade.sh
Source9: postgresql-setup Source9: postgresql.tmpfiles.d
Source10: postgresql.service Source10: postgresql.pam
Source11: initdb.sh Source11: postgresql-bashprofile
Source12: upgrade.sh
Source13: postgresql.tmpfiles.d # Temporary location of postgresql-setup. Development git:
Source14: postgresql.pam # http://fedorapeople.org/cgit/praiskup/public_git/postgresql-setup.git/
Source15: postgresql-bashprofile Source12: http://praiskup.fedorapeople.org/proj/postgresql-setup/postgresql-setup-%{setup_version}.tar.gz
# Those here are just to enforce packagers check that the tarball was downloaded # Those here are just to enforce packagers check that the tarball was downloaded
# correctly. Also, this allows us check that packagers-only tarballs do not # correctly. Also, this allows us check that packagers-only tarballs do not
@ -346,7 +348,7 @@ benchmarks.
%prep %prep
( cd %_sourcedir; sha256sum -c %{SOURCE16}; sha256sum -c %{SOURCE17} ) ( cd %_sourcedir; sha256sum -c %{SOURCE16}; sha256sum -c %{SOURCE17} )
%setup -q %setup -q -a 12
%patch1 -p1 %patch1 -p1
%patch2 -p1 %patch2 -p1
%patch3 -p1 %patch3 -p1
@ -377,25 +379,6 @@ cp -p config/config.sub postgresql-%{prevversion}/config/config.sub
# remove .gitignore files to ensure none get into the RPMs (bug #642210) # remove .gitignore files to ensure none get into the RPMs (bug #642210)
find . -type f -name .gitignore | xargs rm find . -type f -name .gitignore | xargs rm
# prep the setup script, including insertion of some values it needs
sed -e 's|^PGVERSION=.*$|PGVERSION=%{version}|' \
-e 's|^PGMAJORVERSION=.*$|PGMAJORVERSION=%{majorversion}|' \
-e 's|^PGENGINE=.*$|PGENGINE=%{_bindir}|' \
-e 's|^PREVMAJORVERSION=.*$|PREVMAJORVERSION=%{prevmajorversion}|' \
-e 's|^PREVPGENGINE=.*$|PREVPGENGINE=%{_libdir}/pgsql/postgresql-%{prevmajorversion}/bin|' \
-e 's|^README_RPM_DIST=.*$|README_RPM_DIST=%{_pkgdocdir}/%(basename %{SOURCE8})|' \
<%{SOURCE9} >postgresql-setup
touch -r %{SOURCE9} postgresql-setup
chmod +x postgresql-setup
help2man -N -m "Postgresql RPM-dist manual" ./postgresql-setup -o postgresql-setup.1
# prep the startup check script, including insertion of some values it needs
sed -e 's|^PGVERSION=.*$|PGVERSION=%{version}|' \
-e 's|^PREVMAJORVERSION=.*$|PREVMAJORVERSION=%{prevmajorversion}|' \
-e 's|^PGDOCDIR=.*$|PGDOCDIR=%{_pkgdocdir}|' \
<%{SOURCE4} >postgresql-check-db-dir
touch -r %{SOURCE4} postgresql-check-db-dir
%build %build
# fail quickly and obviously if user tries to build as root # fail quickly and obviously if user tries to build as root
@ -408,6 +391,24 @@ touch -r %{SOURCE4} postgresql-check-db-dir
fi fi
%endif %endif
# Building postgresql-setup
cd postgresql-setup-%{setup_version}
export POSTGRES_BIN=%{_bindir}/postgres \
PG_CTL_BIN=%{_bindir}/pg_ctl \
PGVERSION=%{version} \
PGMAJORVERSION=%{majorversion} \
PGENGINE=%{_bindir} \
PREVMAJORVERSION=%{prevmajorversion} \
PREVPGENGINE=%{_libdir}/pgsql/postgresql-%{prevmajorversion}/bin \
README_DIST=%{_pkgdocdir}/README.rpm-dist \
PKGCONFIG_DIR=%{_sysconfdir}/postgresql
%configure
make %{?_smp_mflags}
cd ..
# Fiddling with CFLAGS. # Fiddling with CFLAGS.
CFLAGS="${CFLAGS:-%optflags}" CFLAGS="${CFLAGS:-%optflags}"
@ -621,6 +622,10 @@ rm -f src/tutorial/GNUmakefile
%install %install
cd postgresql-setup-%{setup_version}
make install DESTDIR=$RPM_BUILD_ROOT
cd ..
make DESTDIR=$RPM_BUILD_ROOT install-world make DESTDIR=$RPM_BUILD_ROOT install-world
%if %plpython3 %if %plpython3
@ -646,11 +651,11 @@ install -D -m 644 macros.%{name} \
case `uname -i` in case `uname -i` in
i386 | x86_64 | ppc | ppc64 | s390 | s390x | sparc | sparc64 ) i386 | x86_64 | ppc | ppc64 | s390 | s390x | sparc | sparc64 )
mv $RPM_BUILD_ROOT/usr/include/pg_config.h $RPM_BUILD_ROOT/usr/include/pg_config_`uname -i`.h mv $RPM_BUILD_ROOT/usr/include/pg_config.h $RPM_BUILD_ROOT/usr/include/pg_config_`uname -i`.h
install -m 644 %{SOURCE6} $RPM_BUILD_ROOT/usr/include/ install -m 644 %{SOURCE5} $RPM_BUILD_ROOT/usr/include/
mv $RPM_BUILD_ROOT/usr/include/pgsql/server/pg_config.h $RPM_BUILD_ROOT/usr/include/pgsql/server/pg_config_`uname -i`.h mv $RPM_BUILD_ROOT/usr/include/pgsql/server/pg_config.h $RPM_BUILD_ROOT/usr/include/pgsql/server/pg_config_`uname -i`.h
install -m 644 %{SOURCE6} $RPM_BUILD_ROOT/usr/include/pgsql/server/ install -m 644 %{SOURCE5} $RPM_BUILD_ROOT/usr/include/pgsql/server/
mv $RPM_BUILD_ROOT/usr/include/ecpg_config.h $RPM_BUILD_ROOT/usr/include/ecpg_config_`uname -i`.h mv $RPM_BUILD_ROOT/usr/include/ecpg_config.h $RPM_BUILD_ROOT/usr/include/ecpg_config_`uname -i`.h
install -m 644 %{SOURCE7} $RPM_BUILD_ROOT/usr/include/ install -m 644 %{SOURCE6} $RPM_BUILD_ROOT/usr/include/
;; ;;
*) *)
;; ;;
@ -659,21 +664,13 @@ esac
install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial
cp -p src/tutorial/* $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial cp -p src/tutorial/* $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial
install -m 755 postgresql-setup $RPM_BUILD_ROOT%{_bindir}/postgresql-setup
install -p -m 644 postgresql-setup.1 $RPM_BUILD_ROOT%{_mandir}/man1
install -m 755 postgresql-check-db-dir $RPM_BUILD_ROOT%{_bindir}/postgresql-check-db-dir
install -d $RPM_BUILD_ROOT%{_unitdir}
install -m 644 %{SOURCE10} $RPM_BUILD_ROOT%{_unitdir}/postgresql.service
install -d $RPM_BUILD_ROOT/usr/libexec/initscripts/legacy-actions/postgresql install -d $RPM_BUILD_ROOT/usr/libexec/initscripts/legacy-actions/postgresql
install -m 755 %{SOURCE11} $RPM_BUILD_ROOT/usr/libexec/initscripts/legacy-actions/postgresql/initdb install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/libexec/initscripts/legacy-actions/postgresql/initdb
install -m 755 %{SOURCE12} $RPM_BUILD_ROOT/usr/libexec/initscripts/legacy-actions/postgresql/upgrade install -m 755 %{SOURCE8} $RPM_BUILD_ROOT/usr/libexec/initscripts/legacy-actions/postgresql/upgrade
%if %pam %if %pam
install -d $RPM_BUILD_ROOT/etc/pam.d install -d $RPM_BUILD_ROOT/etc/pam.d
install -m 644 %{SOURCE14} $RPM_BUILD_ROOT/etc/pam.d/postgresql install -m 644 %{SOURCE10} $RPM_BUILD_ROOT/etc/pam.d/postgresql
%endif %endif
# Create the directory for sockets. # Create the directory for sockets.
@ -681,7 +678,7 @@ install -d -m 755 $RPM_BUILD_ROOT/var/run/postgresql
# ... and make a tmpfiles script to recreate it at reboot. # ... and make a tmpfiles script to recreate it at reboot.
mkdir -p $RPM_BUILD_ROOT%{_tmpfilesdir} mkdir -p $RPM_BUILD_ROOT%{_tmpfilesdir}
install -m 0644 %{SOURCE13} $RPM_BUILD_ROOT%{_tmpfilesdir}/postgresql.conf install -m 0644 %{SOURCE9} $RPM_BUILD_ROOT%{_tmpfilesdir}/postgresql.conf
# PGDATA needs removal of group and world permissions due to pg_pwd hole. # PGDATA needs removal of group and world permissions due to pg_pwd hole.
install -d -m 700 $RPM_BUILD_ROOT/var/lib/pgsql/data install -d -m 700 $RPM_BUILD_ROOT/var/lib/pgsql/data
@ -690,7 +687,7 @@ install -d -m 700 $RPM_BUILD_ROOT/var/lib/pgsql/data
install -d -m 700 $RPM_BUILD_ROOT/var/lib/pgsql/backups install -d -m 700 $RPM_BUILD_ROOT/var/lib/pgsql/backups
# postgres' .bash_profile # postgres' .bash_profile
install -m 644 %{SOURCE15} $RPM_BUILD_ROOT/var/lib/pgsql/.bash_profile install -m 644 %{SOURCE11} $RPM_BUILD_ROOT/var/lib/pgsql/.bash_profile
%if %upgrade %if %upgrade
@ -750,12 +747,10 @@ install -m 644 %{SOURCE15} $RPM_BUILD_ROOT/var/lib/pgsql/.bash_profile
rm -f GNUmakefile Makefile *.o rm -f GNUmakefile Makefile *.o
chmod 0755 pg_regress regress.so chmod 0755 pg_regress regress.so
popd popd
cp %{SOURCE5} $RPM_BUILD_ROOT%{_libdir}/pgsql/test/regress/Makefile cp %{SOURCE4} $RPM_BUILD_ROOT%{_libdir}/pgsql/test/regress/Makefile
chmod 0644 $RPM_BUILD_ROOT%{_libdir}/pgsql/test/regress/Makefile chmod 0644 $RPM_BUILD_ROOT%{_libdir}/pgsql/test/regress/Makefile
%endif %endif
# Fix some more documentation
cp %{SOURCE8} README.rpm-dist
rm -rf doc/html # HACK! allow 'rpmbuild -bi --short-circuit' rm -rf doc/html # HACK! allow 'rpmbuild -bi --short-circuit'
mv $RPM_BUILD_ROOT%{_docdir}/pgsql/html doc mv $RPM_BUILD_ROOT%{_docdir}/pgsql/html doc
rm -rf $RPM_BUILD_ROOT%{_docdir}/pgsql rm -rf $RPM_BUILD_ROOT%{_docdir}/pgsql
@ -882,7 +877,6 @@ fi
%files -f main.lst %files -f main.lst
%doc doc/KNOWN_BUGS doc/MISSING_FEATURES doc/TODO %doc doc/KNOWN_BUGS doc/MISSING_FEATURES doc/TODO
%doc COPYRIGHT README HISTORY doc/bug.template %doc COPYRIGHT README HISTORY doc/bug.template
%doc README.rpm-dist
%{_bindir}/clusterdb %{_bindir}/clusterdb
%{_bindir}/createdb %{_bindir}/createdb
%{_bindir}/createlang %{_bindir}/createlang
@ -1046,6 +1040,7 @@ fi
%files server -f server.lst %files server -f server.lst
%{_unitdir}/postgresql.service %{_unitdir}/postgresql.service
%{_unitdir}/postgresql@.service
%dir /usr/libexec/initscripts/legacy-actions/postgresql %dir /usr/libexec/initscripts/legacy-actions/postgresql
/usr/libexec/initscripts/legacy-actions/postgresql/* /usr/libexec/initscripts/legacy-actions/postgresql/*
%if %pam %if %pam
@ -1060,7 +1055,6 @@ fi
%{_bindir}/postgres %{_bindir}/postgres
%{_bindir}/postmaster %{_bindir}/postmaster
%{_bindir}/postgresql-setup %{_bindir}/postgresql-setup
%{_bindir}/postgresql-check-db-dir
%{_mandir}/man1/initdb.* %{_mandir}/man1/initdb.*
%{_mandir}/man1/pg_basebackup.* %{_mandir}/man1/pg_basebackup.*
%{_mandir}/man1/pg_controldata.* %{_mandir}/man1/pg_controldata.*
@ -1096,6 +1090,8 @@ fi
%{_datadir}/pgsql/information_schema.sql %{_datadir}/pgsql/information_schema.sql
%{_datadir}/pgsql/snowball_create.sql %{_datadir}/pgsql/snowball_create.sql
%{_datadir}/pgsql/sql_features.txt %{_datadir}/pgsql/sql_features.txt
%{_libexecdir}/postgresql-ctl
%{_libexecdir}/postgresql-check-db-dir
%files devel -f devel.lst %files devel -f devel.lst
/usr/include/* /usr/include/*
@ -1155,6 +1151,9 @@ fi
%endif %endif
%changelog %changelog
* Sun Sep 21 2014 Pavel Raiskup <praiskup@redhat.com> - 9.3.5-6
- postgresql-setup & relatives are now in separate tarball
* Wed Aug 27 2014 Jitka Plesnikova <jplesnik@redhat.com> - 9.3.5-5 * Wed Aug 27 2014 Jitka Plesnikova <jplesnik@redhat.com> - 9.3.5-5
- Perl 5.20 rebuild - Perl 5.20 rebuild

View File

@ -3,3 +3,4 @@
38b0937c86d537d5044c599273066cfc postgresql-9.2.9.tar.bz2 38b0937c86d537d5044c599273066cfc postgresql-9.2.9.tar.bz2
08b4a99710e25d7004d058997cdb1ebc postgresql-9.2.9.tar.bz2.sha256 08b4a99710e25d7004d058997cdb1ebc postgresql-9.2.9.tar.bz2.sha256
5d8361190dd064a655b21f112daa91ec postgresql-9.3.5-US.pdf 5d8361190dd064a655b21f112daa91ec postgresql-9.3.5-US.pdf
2e601b008c98b991c38a8d7443b13e76 postgresql-setup-1.0.0.tar.gz