summaryrefslogtreecommitdiffstats
path: root/postgresql.spec
blob: af982aba508cdfcf139fc1e75e9301bd36428a8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
# Conventions for PostgreSQL Global Development Group RPM releases:

# Official PostgreSQL Development Group RPMS have a PGDG after the release number.
# Integer releases are stable -- 0.1.x releases are Pre-releases, and x.y are
# test releases.

# Pre-releases are those that are built from CVS snapshots or pre-release
# tarballs from postgresql.org.  Official beta releases are not 
# considered pre-releases, nor are release candidates, as their beta or
# release candidate status is reflected in the version of the tarball. Pre-
# releases' versions do not change -- the pre-release tarball of 7.0.3, for
# example, has the same tarball version as the final official release of 7.0.3:
# but the tarball is different.

# Test releases are where PostgreSQL itself is not in beta, but certain parts of
# the RPM packaging (such as the spec file, the initscript, etc) are in beta.

# Pre-release RPM's should not be put up on the public ftp.postgresql.org server
# -- only test releases or full releases should be.
# This is the PostgreSQL Global Development Group Official RPMset spec file,
# or a derivative thereof.
# Copyright 2003 Lamar Owen <lowen@pari.edu> <lamar.owen@wgcr.org>
# and others listed.

# Major Contributors:
# ---------------
# Lamar Owen
# Trond Eivind Glomsrd <teg@redhat.com>
# Thomas Lockhart
# Reinhard Max
# Karl DeBisschop
# Peter Eisentraut
# Joe Conway
# Andrew Overholt
# David Jee
# Kaj J. Niemi
# Sander Steffann
# Tom Lane
# and others in the Changelog....

# This spec file and ancilliary files are licensed in accordance with 
# The PostgreSQL license.

# In this file you can find the default build package list macros.  These can be overridden by defining
# on the rpm command line:
# rpm --define 'packagename 1' .... to force the package to build.
# rpm --define 'packagename 0' .... to force the package NOT to build.
# The base package, the lib package, the devel package, and the server package always get built.

#build7x, build8, and build9 similar
%{?build7x:%define tcldevel 0}
%{?build7x:%define aconfver autoconf-2.53}
%{?build8:%define build89 1}
%{?build8:%define tcldevel 0}
%{?build9:%define build89 1}

%define beta 0
%{?beta:%define __os_install_post /usr/lib/rpm/brp-compress}

%{!?aconfver:%define aconfver autoconf}

%{!?tcldevel:%define tcldevel 1}
%{!?jdbc:%define jdbc 1}
%{!?test:%define test 1}
%{!?python:%define python 1}
%{!?pltcl:%define pltcl 1}
%{!?plperl:%define plperl 1}
%{!?tcl:%define tcl 1}
%{!?pls:%define pls 1}
%{!?ssl:%define ssl 1}
%{!?kerberos:%define kerberos 1}
%{!?nls:%define nls 1}
%{!?xml:%define xml 1}
%{!?pam:%define pam 1}
%{!?pgfts:%define pgfts 1}
%{!?runselftest:%define runselftest 1}

# Python major version.
%{expand: %%define pyver %(python -c 'import sys;print(sys.version[0:3])')}


Summary: PostgreSQL client programs and libraries.
Name: postgresql
Version: 8.1.2
Release: 1.1
License: BSD
Group: Applications/Databases
Url: http://www.postgresql.org/ 

Source0: ftp://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2
Source3: postgresql.init
Source4: Makefile.regress
Source5: pg_config.h
Source6: README.rpm-dist
Source8: http://jdbc.postgresql.org/download/postgresql-8.1-404.jdbc2.jar
Source9: http://jdbc.postgresql.org/download/postgresql-8.1-404.jdbc2ee.jar
Source10: http://jdbc.postgresql.org/download/postgresql-8.1-404.jdbc3.jar
Source14: postgresql.pam
Source15: postgresql-bashprofile
Source16: filter-requires-perl-Pg.sh
Source17: http://www.postgresql.org/docs/manuals/postgresql-8.1-US.pdf
Source18: ftp://ftp.pygresql.org/pub/distrib/PyGreSQL-3.7.tgz
Source19: ftp://gborg.postgresql.org/pub/pgtclng/stable/pgtcl1.5.2.tar.gz
Source20: ftp://gborg.postgresql.org/pub/pgtclng/stable/pgtcldocs-20041108.zip

Patch1: rpm-pgsql.patch
Patch2: postgresql-src-tutorial.patch
Patch3: postgresql-logging.patch
Patch4: postgresql-test.patch
Patch5: pgtcl-no-rpath.patch
Patch6: postgresql-perl-rpath.patch
Patch7: pgtcl-quote.patch

Buildrequires: perl glibc-devel bison flex autoconf
Prereq: /sbin/ldconfig initscripts

%if %python
BuildPrereq: python-devel
%endif

%if %tcl || %pltcl
BuildPrereq: tcl
%if %tcldevel
Buildrequires: tcl-devel
%endif
%endif

BuildPrereq: readline-devel
BuildPrereq: zlib-devel >= 1.0.4

%if %ssl
BuildPrereq: openssl-devel
%endif

%if %kerberos
BuildPrereq: krb5-devel
BuildPrereq: e2fsprogs-devel
%endif

%if %nls
BuildPrereq: gettext >= 0.10.35
%endif

%if %xml
BuildPrereq: libxml2-devel libxslt-devel
%endif

%if %pam
BuildPrereq: pam-devel
%endif

Obsoletes: postgresql-clients
Obsoletes: postgresql-perl
Obsoletes: postgresql-tk
Obsoletes: rh-postgresql

Buildroot: %{_tmppath}/%{name}-%{version}-root

%description
PostgreSQL is an advanced Object-Relational database management system
(DBMS) that supports almost all SQL constructs (including
transactions, subselects and user-defined types and functions). The
postgresql package includes the client programs and libraries that
you'll need to access a PostgreSQL DBMS server.  These PostgreSQL
client programs are programs that directly manipulate the internal
structure of PostgreSQL databases on a PostgreSQL server. These client
programs can be located on the same machine with the PostgreSQL
server, or may be on a remote machine which accesses a PostgreSQL
server over a network connection. This package contains the docs
in HTML for the whole package, as well as command-line utilities for
managing PostgreSQL databases on a PostgreSQL server. 

If you want to manipulate a PostgreSQL database on a remote PostgreSQL
server, you need this package. You also need to install this package
if you're installing the postgresql-server package.

%package libs
Summary: The shared libraries required for any PostgreSQL clients.
Group: Applications/Databases
Provides: libpq.so
Obsoletes: rh-postgresql-libs

%description libs
The postgresql-libs package provides the essential shared libraries for any 
PostgreSQL client program or interface. You will need to install this package
to use any other PostgreSQL package or any clients that need to connect to a
PostgreSQL server.

%package server
Summary: The programs needed to create and run a PostgreSQL server.
Group: Applications/Databases
Prereq: /usr/sbin/useradd /sbin/chkconfig 
Prereq: postgresql = %{version}-%{release} libpq.so
Obsoletes: rh-postgresql-server

%description server
The postgresql-server package includes the programs needed to create
and run a PostgreSQL server, which will in turn allow you to create
and maintain PostgreSQL databases.  PostgreSQL is an advanced
Object-Relational database management system (DBMS) that supports
almost all SQL constructs (including transactions, subselects and
user-defined types and functions). You should install
postgresql-server if you want to create and maintain your own
PostgreSQL databases and/or your own PostgreSQL server. You also need
to install the postgresql package.


%package docs
Summary: Extra documentation for PostgreSQL
Group: Applications/Databases
Prereq: postgresql = %{version}-%{release}
Obsoletes: rh-postgresql-docs

%description docs
The postgresql-docs package includes some additional documentation for
PostgreSQL.  Currently, this includes the main documentation in PDF format,
the FAQ, and source files for the PostgreSQL tutorial.


%package contrib
Summary: Contributed source and binaries distributed with PostgreSQL
Group: Applications/Databases
Prereq: postgresql = %{version}-%{release}
Obsoletes: rh-postgresql-contrib

%description contrib
The postgresql-contrib package contains contributed packages that are
included in the PostgreSQL distribution.


%package devel
Summary: PostgreSQL development header files and libraries.
Group: Development/Libraries
Prereq: postgresql = %{version}-%{release}
Requires: postgresql-libs = %{version}-%{release}
Obsoletes: rh-postgresql-devel

%description devel
The postgresql-devel package contains the header files and libraries
needed to compile C or C++ applications which will directly interact
with a PostgreSQL database management server and the ecpg Embedded C
Postgres preprocessor. You need to install this package if you want to
develop applications which will interact with a PostgreSQL server.

#------------
%if %pls
%package pl
Summary: The PL procedural languages for PostgreSQL.
Group: Applications/Databases
PreReq: postgresql = %{version}-%{release}
PreReq: postgresql-server = %{version}-%{release}
Obsoletes: rh-postgresql-pl

%description pl
PostgreSQL is an advanced Object-Relational database management
system.  The postgresql-pl package contains the PL/Perl, PL/Tcl, and PL/Python
procedural languages for the backend.  PL/Pgsql is part of the core server package.
%endif

#------------
%if %tcl
%package tcl
Summary: A Tcl client library for PostgreSQL.
Group: Applications/Databases
Requires: libpq.so
Requires: tcl >= 8.3
Obsoletes: rh-postgresql-tcl

%description tcl
PostgreSQL is an advanced Object-Relational database management
system.  The postgresql-tcl package contains the Pgtcl client library
and its documentation.
%endif

#------------
%if %python
%package python
Summary: Development module for Python code to access a PostgreSQL DB.
Group: Applications/Databases
Requires: libpq.so
Requires: python mx
Obsoletes: rh-postgresql-python

%description python
PostgreSQL is an advanced Object-Relational database management
system.  The postgresql-python package includes a module for
developers to use when writing Python code for accessing a PostgreSQL
database.
%endif

#----------
%if %jdbc
%package jdbc
Summary: Files needed for Java programs to access a PostgreSQL database.
Group: Applications/Databases
Obsoletes: rh-postgresql-jdbc

%description jdbc
PostgreSQL is an advanced Object-Relational database management
system. The postgresql-jdbc package includes the .jar files needed for
Java programs to access a PostgreSQL database.
%endif

#------------
%if %test
%package test
Summary: The test suite distributed with PostgreSQL.
Group: Applications/Databases
PreReq: postgresql = %{version}-%{release}
PreReq: postgresql-server = %{version}-%{release}
Obsoletes: rh-postgresql-test

%description test
PostgreSQL is an advanced Object-Relational database management
system. The postgresql-test package includes the sources and pre-built
binaries of various tests for the PostgreSQL database management
system, including regression tests and benchmarks.
%endif

%define __perl_requires %{SOURCE16}

%prep
%setup -q 
pushd doc
tar zxf postgres.tar.gz
popd
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
# patch5 is applied later
%patch6 -p1
# patch7 is applied later

#call autoconf 2.53 or greater
%aconfver

pushd doc
tar -zcf postgres.tar.gz *.html stylesheet.css
rm -f *.html stylesheet.css
popd

cp -p %{SOURCE17} .

%if %python
   tar xzf %{SOURCE18}
   PYGRESQLDIR=`basename %{SOURCE18} .tgz`
   mv $PYGRESQLDIR PyGreSQL
   # Some versions of PyGreSQL.tgz contain wrong file permissions
   chmod 644 PyGreSQL/Announce PyGreSQL/ChangeLog PyGreSQL/README
   chmod 755 PyGreSQL/tutorial
   chmod 644 PyGreSQL/tutorial/*.py
   chmod 755 PyGreSQL/tutorial/advanced.py PyGreSQL/tutorial/basics.py
%endif

%if %tcl
   tar xzf %{SOURCE19}
   PGTCLDIR=`basename %{SOURCE19} .tar.gz`
   mv $PGTCLDIR Pgtcl
   unzip %{SOURCE20}
   PGTCLDOCDIR=`basename %{SOURCE20} .zip`
   mv $PGTCLDOCDIR Pgtcl-docs

%patch5 -p0
%patch7 -p0
   pushd Pgtcl
%aconfver
   popd
%endif

%build

CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS

# Strip out -ffast-math from CFLAGS....
CFLAGS=`echo $CFLAGS|xargs -n 1|grep -v ffast-math|xargs -n 100`

%configure --disable-rpath \
%if %beta
	--enable-debug \
	--enable-cassert \
%endif
%if %plperl
	--with-perl \
%endif
%if %pltcl
	--with-tcl \
	--with-tclconfig=%{_libdir} \
%endif
%if %python
	--with-python \
%endif
%if %ssl
	--with-openssl \
%endif
%if %pam
	--with-pam \
%endif
%if %kerberos
	--with-krb5 \
%endif
%if %nls
	--enable-nls \
%endif
%if %pgfts
	--enable-thread-safety \
%endif
	--sysconfdir=/etc/sysconfig/pgsql \
	--datadir=/usr/share/pgsql \
	--with-docdir=%{_docdir}

make %{?_smp_mflags} all
make %{?_smp_mflags} -C contrib all
%if %xml
make %{?_smp_mflags} -C contrib/xml2 all
%endif

# Have to hack makefile to put correct path into tutorial scripts
sed "s|C=\`pwd\`;|C=%{_libdir}/pgsql/tutorial;|" < src/tutorial/Makefile > src/tutorial/GNUmakefile
make %{?_smp_mflags} -C src/tutorial NO_PGXS=1 all
rm -f src/tutorial/GNUmakefile

%if %runselftest
	pushd src/test/regress
	make all
	make MAX_CONNECTIONS=5 check
	make clean
	popd
%endif

%if %test
	pushd src/test/regress
	make RPMTESTING=1 all
	popd
%endif

%if %python
   PYTHON=/usr/bin/python
   python_version=`${PYTHON} -c "import sys; print sys.version[:3]"`
   python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
   python_includespec="-I${python_prefix}/include/python${python_version}"

   pushd PyGreSQL

   gcc $CFLAGS -fpic -shared -o _pgmodule.so ${python_includespec} -I../src/interfaces/libpq -I../src/include -L../src/interfaces/libpq -lpq pgmodule.c

   popd
%endif

%if %tcl
   pushd Pgtcl
   # pgtcl's configure only handles one include directory :-(
   ./configure --prefix=/usr \
     --libdir=%{_libdir} \
     --with-tcl=%{_libdir} \
     --with-postgres-include="../src/interfaces/libpq -I../src/include" \
     --with-postgres-lib=../src/interfaces/libpq
   # note: as of pgtcl 1.5.2, its makefile is not parallel-safe
   make all
   popd
%endif

%install
rm -rf $RPM_BUILD_ROOT

make DESTDIR=$RPM_BUILD_ROOT install
make -C contrib DESTDIR=$RPM_BUILD_ROOT install
%if %xml
make -C contrib/xml2 DESTDIR=$RPM_BUILD_ROOT install
%endif

# multilib header hack; note pg_config.h is installed in two places!
mv $RPM_BUILD_ROOT/usr/include/pg_config.h $RPM_BUILD_ROOT/usr/include/pg_config_`uname -i`.h
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
install -m 644 %{SOURCE5} $RPM_BUILD_ROOT/usr/include/pgsql/server/

install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial
cp src/tutorial/* $RPM_BUILD_ROOT%{_libdir}/pgsql/tutorial

%if %jdbc
	# Java/JDBC
	# Red Hat's standard place to put jarfiles is /usr/share/java

	# JDBC jars 
	install -d $RPM_BUILD_ROOT/usr/share/java
	install -m 644 %{SOURCE8} $RPM_BUILD_ROOT/usr/share/java
	install -m 644 %{SOURCE9} $RPM_BUILD_ROOT/usr/share/java
	install -m 644 %{SOURCE10} $RPM_BUILD_ROOT/usr/share/java
	# Versionless symlinks to the versioned jars
	pushd $RPM_BUILD_ROOT/usr/share/java
	ln -s `basename %{SOURCE8}` postgresql-jdbc2.jar
	ln -s `basename %{SOURCE9}` postgresql-jdbc2ee.jar
	ln -s `basename %{SOURCE10}` postgresql-jdbc3.jar
	popd
%endif

%if %tcl
	install -d -m 755 $RPM_BUILD_ROOT%{_libdir}/Pgtcl
	cp Pgtcl/pkgIndex.tcl $RPM_BUILD_ROOT%{_libdir}/Pgtcl
	cp Pgtcl/libpgtcl*.so $RPM_BUILD_ROOT%{_libdir}/Pgtcl
%endif

if [ -d /etc/rc.d/init.d ]
then
	install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
	sed 's/^PGVERSION=.*$/PGVERSION=%{version}/' <%{SOURCE3} >postgresql.init
	install -m 755 postgresql.init $RPM_BUILD_ROOT/etc/rc.d/init.d/postgresql
fi

%if %pam
if [ -d /etc/pam.d ]
then
	install -d $RPM_BUILD_ROOT/etc/pam.d
	install -m 644 %{SOURCE14} $RPM_BUILD_ROOT/etc/pam.d/postgresql
fi
%endif

# PGDATA needs removal of group and world permissions due to pg_pwd hole.
install -d -m 700 $RPM_BUILD_ROOT/var/lib/pgsql/data

# backups of data go here...
install -d -m 700 $RPM_BUILD_ROOT/var/lib/pgsql/backups

# postgres' .bash_profile
install -m 644 %{SOURCE15} $RPM_BUILD_ROOT/var/lib/pgsql/.bash_profile

# Create the multiple postmaster startup directory
install -d -m 700 $RPM_BUILD_ROOT/etc/sysconfig/pgsql


%if %test
	# tests. There are many files included here that are unnecessary,
	# but include them anyway for completeness.  We replace the original
	# Makefiles, however.
	mkdir -p $RPM_BUILD_ROOT%{_libdir}/pgsql/test
	cp -a src/test/regress $RPM_BUILD_ROOT%{_libdir}/pgsql/test
	install -m 0755 contrib/spi/refint.so $RPM_BUILD_ROOT%{_libdir}/pgsql/test/regress
	install -m 0755 contrib/spi/autoinc.so $RPM_BUILD_ROOT%{_libdir}/pgsql/test/regress
	pushd  $RPM_BUILD_ROOT%{_libdir}/pgsql/test/regress
	strip *.so
	rm -f GNUmakefile Makefile
	popd
	cp %{SOURCE4} $RPM_BUILD_ROOT%{_libdir}/pgsql/test/regress/Makefile
	chmod 0644 $RPM_BUILD_ROOT%{_libdir}/pgsql/test/regress/Makefile
%endif

# Fix some more documentation
# gzip doc/internals.ps
cp %{SOURCE6} README.rpm-dist
mv $RPM_BUILD_ROOT%{_docdir}/pgsql/html doc
rm -rf $RPM_BUILD_ROOT%{_docdir}/pgsql

%if %python
   pushd PyGreSQL
   install -m 0755 -d $RPM_BUILD_ROOT%{_libdir}/python%{pyver}/site-packages
   install -m 0755 _pgmodule.so $RPM_BUILD_ROOT%{_libdir}/python%{pyver}/site-packages
   install -m 0644 pg.py $RPM_BUILD_ROOT%{_libdir}/python%{pyver}/site-packages
   install -m 0644 pgdb.py $RPM_BUILD_ROOT%{_libdir}/python%{pyver}/site-packages
   popd
%endif

%find_lang libpq
%find_lang initdb
%find_lang pg_config
%find_lang pg_ctl
%find_lang pg_dump
%find_lang postgres
%find_lang psql
%find_lang pg_resetxlog
%find_lang pg_controldata
%find_lang pgscripts

cat libpq.lang > libpq.lst
cat pg_config.lang > pg_config.lst
cat initdb.lang pg_ctl.lang psql.lang pg_dump.lang pgscripts.lang > main.lst
cat postgres.lang pg_resetxlog.lang pg_controldata.lang > server.lst

%post libs -p /sbin/ldconfig 
%postun libs -p /sbin/ldconfig 

%pre server
groupadd -g 26 -o -r postgres >/dev/null 2>&1 || :
useradd -M -n -g postgres -o -r -d /var/lib/pgsql -s /bin/bash \
	-c "PostgreSQL Server" -u 26 postgres >/dev/null 2>&1 || :

# If we're upgrading from rh-postgresql, we have to repeat the above actions
# after rh-postgresql-server is uninstalled, because its postun script runs
# after our pre script ...
%triggerpostun -n postgresql-server -- rh-postgresql-server
groupadd -g 26 -o -r postgres >/dev/null 2>&1 || :
useradd -M -n -g postgres -o -r -d /var/lib/pgsql -s /bin/bash \
	-c "PostgreSQL Server" -u 26 postgres >/dev/null 2>&1 || :

%post server
chkconfig --add postgresql
/sbin/ldconfig

%preun server
if [ $1 = 0 ] ; then
	/sbin/service postgresql condstop >/dev/null 2>&1
	chkconfig --del postgresql
fi

%postun server
/sbin/ldconfig 
if [ $1 -ge 1 ] ; then
	/sbin/service postgresql condrestart >/dev/null 2>&1 || :
fi
if [ $1 = 0 ] ; then
	userdel postgres >/dev/null 2>&1 || :
	groupdel postgres >/dev/null 2>&1 || : 
fi

%if %pls
%post -p /sbin/ldconfig   pl
%postun -p /sbin/ldconfig   pl
%endif

%if %test
%post test
chown -R postgres:postgres /usr/share/pgsql/test >/dev/null 2>&1 || :
%endif

%clean
rm -rf $RPM_BUILD_ROOT

# FILES section.

%files -f main.lst
%defattr(-,root,root)
%doc doc/FAQ doc/KNOWN_BUGS doc/MISSING_FEATURES doc/README* 
%doc COPYRIGHT README HISTORY doc/bug.template
%doc README.rpm-dist
%doc doc/html
%{_bindir}/clusterdb
%{_bindir}/createdb
%{_bindir}/createlang
%{_bindir}/createuser
%{_bindir}/dropdb
%{_bindir}/droplang
%{_bindir}/dropuser
%{_bindir}/pg_dump
%{_bindir}/pg_dumpall
%{_bindir}/pg_restore
%{_bindir}/psql
%{_bindir}/reindexdb
%{_bindir}/vacuumdb
%{_mandir}/man1/clusterdb.*
%{_mandir}/man1/createdb.*
%{_mandir}/man1/createlang.*
%{_mandir}/man1/createuser.*
%{_mandir}/man1/dropdb.*
%{_mandir}/man1/droplang.*
%{_mandir}/man1/dropuser.*
%{_mandir}/man1/pg_dump.*
%{_mandir}/man1/pg_dumpall.*
%{_mandir}/man1/pg_restore.*
%{_mandir}/man1/psql.*
%{_mandir}/man1/reindexdb.*
%{_mandir}/man1/vacuumdb.*
%{_mandir}/man7/*
%dir %{_libdir}/pgsql

%files docs
%defattr(-,root,root)
%doc doc/src/FAQ
%doc *-US.pdf
%{_libdir}/pgsql/tutorial/

%files contrib
%defattr(-,root,root)
%{_libdir}/pgsql/_int.so
%{_libdir}/pgsql/autoinc.so
%{_libdir}/pgsql/btree_gist.so
%{_libdir}/pgsql/chkpass.so
%{_libdir}/pgsql/cube.so
%{_libdir}/pgsql/dblink.so
%{_libdir}/pgsql/earthdistance.so
%{_libdir}/pgsql/fti.so
%{_libdir}/pgsql/fuzzystrmatch.so
%{_libdir}/pgsql/insert_username.so
%{_libdir}/pgsql/int_aggregate.so
%{_libdir}/pgsql/isbn_issn.so
%{_libdir}/pgsql/lo.so
%{_libdir}/pgsql/ltree.so
%{_libdir}/pgsql/moddatetime.so
%{_libdir}/pgsql/pending.so
%{_libdir}/pgsql/pgcrypto.so
%{_libdir}/pgsql/pgstattuple.so
%{_libdir}/pgsql/pg_buffercache.so
%{_libdir}/pgsql/pg_trgm.so
%{_libdir}/pgsql/refint.so
%{_libdir}/pgsql/seg.so
%{_libdir}/pgsql/tablefunc.so
%{_libdir}/pgsql/timetravel.so
%{_libdir}/pgsql/tsearch2.so
%{_libdir}/pgsql/user_locks.so
%if %xml
%{_libdir}/pgsql/pgxml.so
%endif
%{_datadir}/pgsql/contrib/
%{_bindir}/DBMirror.pl
%{_bindir}/clean_pending.pl
%{_bindir}/dbf2pg
%{_bindir}/fti.pl
%{_bindir}/oid2name
%{_bindir}/pgbench
%{_bindir}/vacuumlo
%doc contrib/*/README.* contrib/spi/*.example

%files libs -f libpq.lang
%defattr(-,root,root)
%{_libdir}/libpq.so.*
%{_libdir}/libecpg.so.*
%{_libdir}/libpgtypes.so.*
%{_libdir}/libecpg_compat.so.*

%files server -f server.lst
%defattr(-,root,root)
/etc/rc.d/init.d/postgresql
%if %pam
%config(noreplace) /etc/pam.d/postgresql
%endif
%attr (755,root,root) %dir /etc/sysconfig/pgsql
%{_bindir}/initdb
%{_bindir}/ipcclean
%{_bindir}/pg_controldata
%{_bindir}/pg_ctl
%{_bindir}/pg_resetxlog
%{_bindir}/postgres
%{_bindir}/postmaster
%{_mandir}/man1/initdb.*
%{_mandir}/man1/ipcclean.*
%{_mandir}/man1/pg_controldata.*
%{_mandir}/man1/pg_ctl.*
%{_mandir}/man1/pg_resetxlog.*
%{_mandir}/man1/postgres.*
%{_mandir}/man1/postmaster.*
%{_datadir}/pgsql/postgres.bki
%{_datadir}/pgsql/postgres.description
%{_datadir}/pgsql/system_views.sql
%{_datadir}/pgsql/*.sample
%{_datadir}/pgsql/timezone/
%{_libdir}/pgsql/plpgsql.so
%dir %{_datadir}/pgsql
%attr(700,postgres,postgres) %dir /var/lib/pgsql
%attr(700,postgres,postgres) %dir /var/lib/pgsql/data
%attr(700,postgres,postgres) %dir /var/lib/pgsql/backups
%attr(644,postgres,postgres) %config(noreplace) /var/lib/pgsql/.bash_profile
%{_libdir}/pgsql/*_and_*.so
%{_datadir}/pgsql/conversion_create.sql
%{_datadir}/pgsql/information_schema.sql
%{_datadir}/pgsql/sql_features.txt

%files devel -f pg_config.lst
%defattr(-,root,root)
/usr/include/*
%{_bindir}/ecpg
%{_bindir}/pg_config
%{_libdir}/libpq.so
%{_libdir}/libecpg.so
%{_libdir}/libpq.a
%{_libdir}/libecpg.a
%{_libdir}/libecpg_compat.so
%{_libdir}/libecpg_compat.a
%{_libdir}/libpgport.a
%{_libdir}/libpgtypes.so
%{_libdir}/libpgtypes.a
%{_libdir}/pgsql/pgxs/
%{_mandir}/man1/ecpg.*
%{_mandir}/man1/pg_config.*

%if %tcl
%files tcl
%defattr(-,root,root)
%{_libdir}/Pgtcl/
%doc Pgtcl-docs/*
%endif

%if %pls
%files pl
%defattr(-,root,root)
%if %plperl
%{_libdir}/pgsql/plperl.so
%endif
%if %pltcl
%{_libdir}/pgsql/pltcl.so
%{_bindir}/pltcl_delmod
%{_bindir}/pltcl_listmod
%{_bindir}/pltcl_loadmod
%{_datadir}/pgsql/unknown.pltcl
%endif
%if %python
%{_libdir}/pgsql/plpython.so
%endif
%endif

%if %python
%files python
%defattr(-,root,root)
%doc PyGreSQL/tutorial PyGreSQL/Announce PyGreSQL/ChangeLog PyGreSQL/README
%{_libdir}/python%{pyver}/site-packages/_pgmodule.so
%{_libdir}/python%{pyver}/site-packages/*.py
%endif

%if %jdbc
%files jdbc
%defattr(-,root,root)
%{_datadir}/java/*
%endif

%if %test
%files test
%defattr(-,postgres,postgres)
%attr(-,postgres,postgres) %{_libdir}/pgsql/test/*
%attr(-,postgres,postgres) %dir %{_libdir}/pgsql/test
%endif

%changelog
* Tue Feb 07 2006 Jesse Keating <jkeating@redhat.com> - 8.1.2-1.1
- rebuilt for new gcc4.1 snapshot and glibc changes

* Mon Jan  9 2006 Tom Lane <tgl@redhat.com> 8.1.2-1
- Update to PostgreSQL 8.1.2
- Repair extraneous quote in pgtcl configure script ... odd that bash
  didn't use to spit up on this.

* Thu Dec 15 2005 Tom Lane <tgl@redhat.com> 8.1.1-3
- fix pg_config.h for 64-bit and ppc platforms
- update Makefile.regress (needs to --load-language=plpgsql)

* Wed Dec 14 2005 Tom Lane <tgl@redhat.com> 8.1.1-2
- oops, looks like we want uname -i not uname -m

* Wed Dec 14 2005 Tom Lane <tgl@redhat.com> 8.1.1-1
- Update to PostgreSQL 8.1.1
- Make pg_config.h architecture-independent for multilib installs;
  put the original pg_config.h into pg_config_$ARCH.h

* Fri Dec 09 2005 Jesse Keating <jkeating@redhat.com>
- rebuilt

* Sat Nov 12 2005 Tom Lane <tgl@redhat.com> 8.1.0-4
- Update included PDF-format manual to 8.1.

* Wed Nov  9 2005 Tom Lane <tgl@redhat.com> 8.1.0-3
- Rebuild due to openssl library update.

* Wed Nov  9 2005 Tom Lane <tgl@redhat.com> 8.1.0-2
- Rebuild due to openssl library update.

* Mon Nov  7 2005 Tom Lane <tgl@redhat.com> 8.1.0-1
- Update to PostgreSQL 8.1.0, PyGreSQL 3.7, and jdbc driver build 404
- Fix PAM config file (must have account not only auth) (bug #167040)
- Add BuildPrereq: libxslt-devel (bug #170141)
- Sync with PGDG SRPM as much as feasible

* Fri Oct 14 2005 Tomas Mraz <tmraz@redhat.com>
- use include instead of pam_stack in pam config

* Tue Oct  4 2005 Tom Lane <tgl@redhat.com> 8.0.4-2
- Add rpath to plperl.so (bug #162198)

* Tue Oct  4 2005 Tom Lane <tgl@redhat.com> 8.0.4-1
- Update to PostgreSQL 8.0.4, PyGreSQL 3.6.2, and jdbc driver build 312
- Adjust pgtcl link command to ensure it binds to correct libpq (bug #166665)
- Remove obsolete Conflicts: against other python versions (bug #166754)
- Add /etc/pam.d/postgresql (bug #167040)
- Include contrib/xml2 in build (bug #167492)

* Tue May 10 2005 Tom Lane <tgl@redhat.com> 8.0.3-1
- Update to PostgreSQL 8.0.3 (includes security and data-loss fixes; see
  bz#156727, CAN-2005-1409, CAN-2005-1410)
- Update to jdbc driver build 311
- Recreate postgres user after superseding an rh-postgresql install (bug #151911)
- Ensure postgresql server is restarted if running during an upgrade

* Thu Apr 14 2005 Florian La Roche <laroche@redhat.com> 8.0.2-2
- rebuild for postgresql-tcl

* Tue Apr 12 2005 Tom Lane <tgl@redhat.com> 8.0.2-1
- Update to PostgreSQL 8.0.2.

* Fri Mar 11 2005 Tom Lane <tgl@redhat.com> 8.0.1-5
- Remove unwanted rpath specification from pgtcl (bz#150649)

* Wed Mar  2 2005 Tom Lane <tgl@redhat.com> 8.0.1-4
- Attach Obsoletes: declarations for rh-postgresql to subpackages (bz#144435)
- Make Requires: and Prereq: package linkages specify release not only
  version, as per recent mailing list discussion.

* Tue Mar  1 2005 Tomas Mraz <tmraz@redhat.com> 8.0.1-3
- rebuild with openssl-0.9.7e

* Mon Feb 21 2005 Tom Lane <tgl@redhat.com> 8.0.1-2
- Repair improper error message in init script when PGVERSION doesn't match.
- Arrange for auto update of version embedded in init script.

* Sun Jan 30 2005 Tom Lane <tgl@redhat.com> 8.0.1-1
- Update to PostgreSQL 8.0.1.
- Add versionless symlinks to jar files (bz#145744)

* Wed Jan 19 2005 Tom Lane <tgl@redhat.com> 8.0.0-1
- Update to PostgreSQL 8.0.0, PyGreSQL 3.6.1, pgtcl 1.5.2,
  and jdbc driver build 309.
- Extensive cleanout of obsolete cruft in patch set.
- Regression tests are run during RPM build (NOTE: cannot build as root when
  this is enabled).
- Postmaster stderr goes someplace useful, not /dev/null (bz#76503, #103767)
- Make init script return a useful exit status (bz#80782)
- Move docs' tutorial directory to %%{_libdir}/pgsql/tutorial, since it
  includes .so files that surely do not belong under /usr/share.
- Remove useless .sgml files from docs RPM (bz#134450)
- Put regression tests under /usr/lib64 on 64-bit archs, since .so files
  are not architecture-independent.

* Wed Jan 12 2005 Tim Waugh <twaugh@redhat.com> 7.4.6-5
- Rebuilt for new readline.

* Tue Jan 11 2005 Dan Walsh <dwalsh@redhat.com> 7.4.6-4
- Add restorecon to postgresql.init in order to restore database to correct
- SELinux context.

* Thu Dec 16 2004 Tom Lane <tgl@redhat.com> 7.4.6-3
- Update to PyGreSQL 3.6 (to fix bug #142711)
- Adjust a few file permissions (bug #142431)
- Assign %%{_libdir}/pgsql to base package instead of -server (bug #74003)

* Mon Nov 15 2004 Tom Lane <tgl@redhat.com> 7.4.6-2
- Rebuild so python components play with python 2.4 (bug 139160)

* Sat Oct 23 2004 Tom Lane <tgl@redhat.com> 7.4.6-1
- Update to PostgreSQL 7.4.6 (bugs 136947, 136949)
- Make init script more paranoid about mkdir step of initializing a new
  database (bugs 136947, 136949)

* Wed Oct 20 2004 Tom Lane <tgl@redhat.com> 7.4.5-4
- Remove contrib/oidjoins stuff from installed fileset; it's of no use
  to ordinary users and has a security issue (bugs 136300, 136301)
- adjust chkconfig priority (bug 128852)

* Tue Oct 05 2004 Tom Lane <tgl@redhat.com> 7.4.5-3
- Solve the stale lockfile problem (bugs 71295, 96981, 134090)
- Use runuser instead of su for SELinux (bug 134588)

* Mon Aug 30 2004 Tom Lane <tgl@redhat.com> 7.4.5-2
- Update to PyGreSQL 3.5.

* Wed Aug 24 2004 Tom Lane <tgl@redhat.com> 7.4.5-1
- Update to PostgreSQL 7.4.5.
- Update JDBC jars to driver build 215.
- Add Obsoletes: entries for rh-postgresql packages, per bug 129278.

* Sat Jul 10 2004 Tom Lane <tgl@redhat.com> 7.4.3-3
- Undo ill-considered chkconfig change that causes server to start
  immediately upon install.  Mea culpa (bug 127552).

* Sat Jul 03 2004 Tom Lane <tgl@redhat.com> 7.4.3-2
- Update JDBC jars to driver build 214.

* Wed Jun 23 2004 Tom Lane <tgl@redhat.com> 7.4.3-1
- Update to PostgreSQL 7.4.3.
- Uninstalling server RPM stops postmaster first, per bug 114846.
- Fix su commands to not assume PG user's shell is sh-like, per bug 124024.
- Fix permissions on postgresql-python doc files, per bug 124822.
- Minor postgresql.init improvements.

* Tue Jun 15 2004 Elliot Lee <sopwith@redhat.com>
- rebuilt

* Wed Mar 10 2004 Tom Lane <tgl@redhat.com> 7.4.2-1
- Update to PostgreSQL 7.4.2; sync with community SRPM as much as possible.
- Support PGOPTS from /etc/sysconfig/pgsql, per bug 111504.
- Fix permissions on /etc/sysconfig/pgsql, per bug 115278.
- SELinux patch in init file: always su </dev/null, per bug 117901.
- Rebuilt

* Tue Mar 02 2004 Elliot Lee <sopwith@redhat.com>
- rebuilt

* Wed Feb 25 2004 Tom Lane <tgl@redhat.com>
- Update to PostgreSQL 7.4.1.
- Rebuilt

* Tue Feb 24 2004 Tom Lane <tgl@redhat.com>
- Fix chown syntax in postgresql.init also.
- Rebuilt

* Mon Feb 23 2004 Tim Waugh <twaugh@redhat.com>
- Use ':' instead of '.' as separator for chown.

* Fri Feb 13 2004 Elliot Lee <sopwith@redhat.com>
- rebuilt

* Fri Jan 9 2004 Lamar Owen <lowen@pari.edu>
- 7.4.1-1PGDG
- Merge Sander Steffann's changes up to 7.4-0.5PGDG
- Proper 7.4.1 JDBC jars this time.
- Patch for no pl/python from Alvaro

* Fri Dec 05 2003 David Jee <djee@redhat.com> 7.4-5
- Rebuild for Perl 5.8.2.

* Mon Dec 01 2003 David Jee <djee@redhat.com> 7.4-4
- Add PyGreSQL patch for deprecated column pg_type.typprtlen [Bug #111263]
- Add headers patch which moves ecpg headers to /usr/include/ecpg
  [Bug #111195]

* Fri Nov 28 2003 David Jee <djee@redhat.com> 7.4-3
- uncomment buildrequires tcl-devel

* Fri Nov 28 2003 David Jee <djee@redhat.com> 7.4-2
- rebuild

* Mon Nov 24 2003 David Jee <djee@redhat.com> 7.4-1
- initial Red Hat build
- move jars to /usr/share/java
- fix rpm-multilib patch to use sysconfig

* Fri Nov 21 2003 Lamar Owen <lowen@pari.edu> <lamar.owen@wgcr.org>
- 7.4-0.1PGDG
- Development JDBC jars in addition to the 7.3 jars; will replace the
- 7.3 jars once 7.4 official jars are released.
- Changed to use the bzip2 source to save a little size.
- Removed some commented out portions of the specfile.
- Removed the 7.3.4 PDF docs.  Will replace with 7.4 PDF's once they
- are ready.

* Tue Nov 18 2003 Kaj J. Niemi <kajtzu@fi.basen.net> 7.4-0.1
- 7.4
- Fixed Patch #1 (now rpm-pgsql-7.4.patch)
- Fixed Patch #2 (now rpm-multilib-7.4.patch):
- Patch #4 is unnecessary (upstream)
- Fixed Patch #6 (now postgresql-7.4-src-tutorial.patch)
- Added Patch #8 (postgresql-7.4-com_err.patch) as com_err()
  is provided by e2fsprogs and CPPFLAGS gets lost somewhere
  inside configure (bad macro?)
- No 7.4 PDF docs available yet (Source #17)
- PyGreSQL is separated from the upstream distribution but
  we include it as usual (Source #18)
- Default to compiling libpq and ECPG as fully thread-safe

- 7.4 Origin.  See previous spec files for previous history. Adapted
- from Red Hat and PGDG's 7.3.4 RPM, directly descended from 
- postgresql-7.3.4-2 as shipped in Fedora Core 1.