summaryrefslogtreecommitdiffstats
path: root/postgresql.spec
blob: e1c2e5c04a7020dcf16e252dae665f0bb81c66d4 (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
%{!?perl:%define perl 1}
%{!?tcl:%define tcl 1}
%{!?tkpkg:%define tkpkg 1}
%{!?odbc:%define odbc 1}
%{!?jdbc:%define jdbc 1}
%{!?test:%define test 0}
%{!?python:%define python 1}
%{!?pltcl:%define pltcl 1}
%{?forceplperl:%define plperl %{expand:forceplperl}}
%{!?forceplperl:%define forceplperl 0}
%{!?plperl:%define plperl 1}
%{!?ssl:%define ssl 1}
%{!?kerberos:%define kerberos 1}

# Utility feature defines.
%{!?enable_mb:%define enable_mb 1}
%{!?pgaccess:%define pgaccess 1}

# Python major version.
%define pyver 2.2
%define pymainver 2
%define pynextver 2.3

Summary: PostgreSQL client programs and libraries.
Name: postgresql
Version: 7.2

# 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.

Release: 0.7.1
License: BSD
Group: Applications/Databases
Source0: ftp://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.gz
Source3: postgresql.init
Source4: file-lists.tar.gz
Source5: ftp://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.gz.md5
Source6: README.rpm-dist
Source7: migration-scripts.tar.gz
Source10: http://www.retep.org.uk/postgres/jdbc7.0-1.1.jar
Source11: jdbc7.1-1.2.jar
Source12: postgresql-dump.1.gz
Source14: rh-pgdump.sh
Source15: postgresql-bashprofile
Patch1: rpm-pgsql-7.2.patch
Patch2: postgresql-7.2rc2-betterquote.patch
Buildrequires: perl glibc-devel autoconf
Prereq: /sbin/ldconfig initscripts
BuildPrereq: python%{?pymainver}-devel perl tcl
BuildPrereq: readline-devel >= 4.0
BuildPrereq: zlib-devel >= 1.0.4
%if %ssl
BuildPrereq: openssl-devel
%endif
%if %kerberos
BuildPrereq: krb5-devel
%endif
Url: http://www.postgresql.org/ 
Obsoletes: postgresql-clients
Buildroot: %{_tmppath}/%{name}-%{version}-root
# Obsolete the packages we are not building...
%if ! %{plperl}
Obsoletes: postgresql-plperl
%endif
%if ! %{tcl}
Obsoletes: postgresql-tcl
%endif
%if ! %{tkpkg}
Obsoletes: postgresql-tk
%endif
%if ! %{odbc}
Obsoletes: postgresql-odbc
%endif
%if ! %{perl}
Obsoletes: postgresql-perl
%endif
%if ! %{python}
Obsoletes: postgresql-python
%endif
%if ! %{jdbc}
Obsoletes: postgresql-jdbc
%endif
%if ! %{test}
Obsoletes: postgresql-test
%endif



# This is the PostgreSQL Global Development Group Official RPMset spec file,
# or a derivative thereof.
# Copyright 2001 Lamar Owen <lamar@postgresql.org> <lamar.owen@wgcr.org>
# and others listed.

# Major Contributors:
# ---------------
# Lamar Owen
# Trond Eivind Glomsrød <teg@redhat.com>
# Thomas Lockhart
# Reinhard Max
# Karl DeBisschop
# Peter Eisentraut
# and others in the Changelog....

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

# On top of 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.


%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.2 libpq.so.2.0 libpq.so

%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 
Requires: postgresql = %{version} libpq.so

%package docs
Summary: Extra documentation for PostgreSQL
Group: Applications/Databases
%description docs
The postgresql-docs package includes the SGML source for the documentation
as well as the documentation in other formats, and some extra documentation.
Install this package if you want to help with the PostgreSQL documentation
project, or if you want to generate printed documentation.

%package contrib
Summary: Contributed source and binaries distributed with PostgreSQL
Group: Applications/Databases
Requires: libpq.so postgresql = %{version}
%description contrib
The postgresql-contrib package includes the contrib tree distributed with
the PostgreSQL tarball.  Selected contrib modules are prebuilt.

%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 devel
Summary: PostgreSQL development header files and libraries.
Group: Development/Libraries
Requires: postgresql-libs = %{version}

%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
you're installing postgresql-server, you need to install this
package.

#------------
%if %plperl
%package plperl
Summary: The PL/Perl procedural language for PostgreSQL.
Group: Applications/Databases
Requires: perl, postgresql = %{version}

%description plperl
PostgreSQL is an advanced Object-Relational database management
system.  The postgresql-plperl package contains the the PL/Perl
procedural language for the backend.
%endif

#------------
%if %tcl
%package tcl
Summary: A Tcl client library, and the PL/Tcl procedural language for PostgreSQL.
Group: Applications/Databases
Requires: tcl >= 8.0

%description tcl
PostgreSQL is an advanced Object-Relational database management
system.  The postgresql-tcl package contains the libpgtcl client library,
the pg-enhanced pgtclsh, and the PL/Tcl procedural language for the backend.
%endif

#------------
%if %tkpkg
%package tk
Summary: Tk shell and tk-based GUI for PostgreSQL.
Group: Applications/Databases
Requires: tcl >= 8.0, tk >= 8.0

%description tk
PostgreSQL is an advanced Object-Relational database management
system.  The postgresql-tk package contains the pgaccess
program. Pgaccess is a graphical front end, written in Tcl/Tk, for the
psql and related PostgreSQL client programs.
%endif

#------------
%if %odbc
%package odbc
Summary: The ODBC driver needed for accessing a PostgreSQL DB using ODBC.
Group: Applications/Databases

%description odbc
PostgreSQL is an advanced Object-Relational database management
system. The postgresql-odbc package includes the ODBC (Open DataBase
Connectivity) driver and sample configuration files needed for
applications to access a PostgreSQL database using ODBC.
%endif

#------------
%if %perl
%package perl
Summary: Development module needed for Perl code to access a PostgreSQL DB.
Group: Applications/Databases
Requires: perl >= 5.004-4

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

#------------
%if %python
%package python
Summary: Development module for Python code to access a PostgreSQL DB.
Group: Applications/Databases
Requires: mx%{?pymainver}
Requires: python%{?pymainver} >= %pyver, python < %pynextver

%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

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

#------------
%if %test
%package test
Summary: The test suite distributed with PostgreSQL.
Group: Applications/Databases
Requires: postgresql = %{version}

%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

%prep
%setup -q 

%patch1 -p1
%patch2 -p1

%build

# Get file lists....
tar xzf %{SOURCE4}

#Commented out for testing on other platforms for now.
# If libtool installed, copy some files....
#if [ -d /usr/share/libtool ]
#then
#	cp /usr/share/libtool/config.* .
#fi

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`
export PYTHON="/usr/bin/python%{pyver}"

./configure --enable-locale  --with-CXX --prefix=/usr --disable-rpath\
%if %perl
	--with-perl \
%endif
%if %enable_mb
	--enable-multibyte \
%endif
%if %tcl
	--with-tcl \
%endif
%if %tkpkg
%else
	--without-tk \
%endif
%if %odbc
	--with-odbc \
%endif
	--enable-syslog\
%if %python
	--with-python \
%endif
%if %ssl
	--with-openssl \
%endif
%if %kerberos
	--with-krb5=/usr/kerberos \
%endif
	--sysconfdir=/etc/pgsql \
	--mandir=%{_mandir} \
	--docdir=%{_docdir} \
	--includedir=%{_includedir} \
	--datadir=/usr/share/pgsql

make %{?_smp_mflags} all

%if %test
	pushd src/test
	make all
	popd
%endif

%install
rm -rf $RPM_BUILD_ROOT

make DESTDIR=$RPM_BUILD_ROOT install

%if %perl
	make PREFIX=$RPM_BUILD_ROOT/usr -C src/interfaces/perl5 -f Makefile install

	# Get rid of the packing list generated by the perl Makefile, and build my own...
	find $RPM_BUILD_ROOT/usr/lib/perl5 -name .packlist -exec rm -f {} \;
	find $RPM_BUILD_ROOT/usr/lib/perl5 -type f -print | \
		sed -e "s|$RPM_BUILD_ROOT/|/|g"  | \
		sed -e "s|.*/man/.*|&\*|" > perlfiles.list
	find $RPM_BUILD_ROOT/usr/lib/perl5 -type d -name Pg -print | \
		sed -e "s|$RPM_BUILD_ROOT/|%dir /|g" >> perlfiles.list
	
	# check and fixup Pg manpage location....
	if [ ! -e $RPM_BUILD_ROOT%{_mandir}/man3/Pg.* ]
	then
		mkdir -p $RPM_BUILD_ROOT%{_mandir}/man3
		cp `find $RPM_BUILD_ROOT -name 'Pg.3*' -print` $RPM_BUILD_ROOT%{_mandir}/man3
	fi
	
	pushd src/interfaces
	mkdir -p $RPM_BUILD_ROOT/usr/share/pgsql/perl5
	cp -a perl5/test.pl $RPM_BUILD_ROOT/usr/share/pgsql/perl5
	popd
	# remove perllocal.pod and Pg.bs from the file list - only occurs with 5.6

	perl -pi -e "s/^.*perllocal.pod$//" perlfiles.list
	perl -pi -e "s/^.*Pg.bs$//" perlfiles.list
	mkdir -p $RPM_BUILD_ROOT/usr/lib/perl5/site_perl/%{_arch}-linux/auto/Pg

%endif


# man pages....
# the postgresql-dump manpage.....
pushd $RPM_BUILD_ROOT%{_mandir}
cp %{SOURCE12} man1
popd

# install the dump script

install -m755 %SOURCE14 $RPM_BUILD_ROOT/usr/bin/

# install dev headers.

make DESTDIR=$RPM_BUILD_ROOT install-all-headers

# copy over Makefile.global to the include dir....
install -m755 src/Makefile.global $RPM_BUILD_ROOT/usr/include/pgsql

%if %pgaccess
	# pgaccess installation
	pushd src/bin
	install -m 755 pgaccess/pgaccess $RPM_BUILD_ROOT/usr/bin
	mkdir -p $RPM_BUILD_ROOT/usr/share/pgsql/pgaccess
	install -m 644 pgaccess/main.tcl $RPM_BUILD_ROOT/usr/share/pgsql/pgaccess
	tar cf - pgaccess/lib pgaccess/images | tar xf - -C $RPM_BUILD_ROOT/usr/share/pgsql
	cp -a pgaccess/doc/html   ../../doc/pgaccess
	cp    pgaccess/demo/*.sql ../../doc/pgaccess
	popd
%endif

%if %jdbc
	# Java/JDBC
	# The user will have to set a CLASSPATH to find it here, but not sure where else to put it...

	# Install 7.0 JDBC jars 
	install -m 755 %{SOURCE10} $RPM_BUILD_ROOT/usr/share/pgsql
	install -m 755 %{SOURCE11} $RPM_BUILD_ROOT/usr/share/pgsql

%endif

# The initscripts....
# Redhat-style....
if [ -d /etc/rc.d/init.d ]
then
	install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
	install -m 755 %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/postgresql
	mv redhat-style-files.lst files.lst
fi

# SuSE-style....
# NOTE: SuSE stuff not yet fully implemented -- this is likely to not work yet.
# Putting SuSE-style stuff here
if [ -d /sbin/init.d ]
then
	# install the SuSE stuff...
	mv suse-style-files.lst files.lst
fi


# 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

%if %test
	# tests. There are many files included here that are unnecessary, but include
	# them anyway for completeness.
	mkdir -p $RPM_BUILD_ROOT/usr/lib/pgsql/test
	cp -a src/test/regress $RPM_BUILD_ROOT/usr/lib/pgsql/test
	install -m 0755 contrib/spi/refint.so $RPM_BUILD_ROOT/usr/lib/pgsql/test/regress
	install -m 0755 contrib/spi/autoinc.so $RPM_BUILD_ROOT/usr/lib/pgsql/test/regress
	pushd  $RPM_BUILD_ROOT/usr/lib/pgsql/test/regress/
	strip *.so
	popd
%endif

# Upgrade scripts.
pushd $RPM_BUILD_ROOT
tar xzf %{SOURCE7}
popd

# logrotate script removed until future release
#logrotate script source (which needs WORK)
#mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
#cp %{SOURCE8} $RPM_BUILD_ROOT/etc/logrotate.d/postgres
#chmod 0644 $RPM_BUILD_ROOT/etc/logrotate.d/postgres

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

# Build contrib stuff....
pushd contrib
make clean
make all
popd 
# move the contrib tree to the right place after building....
cp -r contrib $RPM_BUILD_ROOT/usr/lib/pgsql
# We'll do more prep work in a later release.....

#more massaging

pushd $RPM_BUILD_ROOT/usr/lib/pgsql/contrib

# Get rid of useless makefiles
rm -f Makefile */Makefile
# earthdistance
pushd earthdistance
perl -pi -e "s|/usr/share/pgsql/contrib|/usr/lib/pgsql/contrib/earthdistance|" *
popd

# array
pushd array
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/array|" *
popd

# cube
pushd cube
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/cube|" cube.sql
popd

# fulltext
pushd fulltextindex
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/fulltextindex|" *.sql
popd

# intarray
pushd intarray
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/intarray|" *.sql
popd

# isbn_issn
pushd isbn_issn
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/isbn_issn|" *.sql
popd

# lo
pushd lo
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/lo|" *.sql
popd

# miscutil
pushd miscutil
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/miscutil|" *.sql
popd

# noup
pushd noupdate
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/noupdate|" *.sql
popd

# pgcrypto
pushd pgcrypto
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/pgcrypto|" *.sql
popd


# rserv
pushd rserv
perl -pi -e "s|/usr/share/|/usr/lib/|" *
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/rserv|" *
perl -pi -e "s|/usr/bin|/usr/lib/pgsql/contrib/rserv|" *
perl -pi -e "s|/usr/lib/pgsql/contrib\"|/usr/lib/pgsql/contrib/rserv\"|" *
perl -pi -e "s|/usr/lib/pgsql/contrib$|/usr/lib/pgsql/contrib/rserv|" *
popd

# seg 
pushd seg
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/seg|" *.sql
popd

# spi
pushd spi
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/spi|" *.sql
popd

# string
pushd string
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/string|" *.sql
popd

# userlock
pushd userlock
perl -pi -e "s|/usr/lib/contrib|/usr/lib/pgsql/contrib/userlock|" *.sql
popd

popd

#more broken symlinks
rm -f $RPM_BUILD_ROOT/usr/lib/pgsql/contrib/pg_resetxlog/pg_crc.c $RPM_BUILD_ROOT/usr/lib/pgsql/contrib/pg_controldata/pg_crc.c
cp src/backend/utils/hash/pg_crc.c $RPM_BUILD_ROOT/usr/lib/pgsql/contrib/pg_resetxlog/pg_crc.c
ln $RPM_BUILD_ROOT/usr/lib/pgsql/contrib/pg_resetxlog/pg_crc.c $RPM_BUILD_ROOT/usr/lib/pgsql/contrib/pg_controldata/pg_crc.c

# Symlink libpq.so.2.0 to libpq.so.2 for backwards compatibility, until 
# -soname patches are the norm.
pushd $RPM_BUILD_ROOT/usr/lib
ln -s libpq.so.2 libpq.so.2.0
popd


%pre
# Need to make backups of some executables if an upgrade
# They will be needed to do a dump of the old version's database.
# All output redirected to /dev/null.

if [ $1 -gt 1 ]
then
   mkdir -p /usr/lib/pgsql/backup > /dev/null
   pushd /usr/bin > /dev/null
   cp -fp postmaster postgres pg_dump pg_dumpall psql /usr/share/pgsql/backup > /dev/null 2>&1  || :
   popd > /dev/null
   pushd /usr/lib > /dev/null
   cp -fp libpq.* /usr/share/pgsql/backup > /dev/null 2>&1 || :
   popd > /dev/null
fi

%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 || :
touch /var/log/pgsql
chown postgres.postgres /var/log/pgsql
chmod 0700 /var/log/pgsql


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

%preun server
if [ $1 = 0 ] ; then
	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 %odbc
%post -p /sbin/ldconfig  odbc
%postun -p /sbin/ldconfig  odbc
%endif

%if %tcl
%post -p /sbin/ldconfig   tcl
%postun -p /sbin/ldconfig   tcl
%endif

%if %plperl
%post -p /sbin/ldconfig   plperl
%postun -p /sbin/ldconfig   plperl
%endif

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

%clean
rm -rf $RPM_BUILD_ROOT
rm -f perlfiles.list

# Ok, we are dynamically generating some filelists.  These are by default
# under the BUILD/postgresql-x.y.z tree.

# Note that macros such as config are available in those lists.
# The lists differentiate between RedHat, SuSE, and others.

%files
%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
/usr/bin/createdb
/usr/bin/createlang
/usr/bin/createuser
/usr/bin/dropdb
/usr/bin/droplang
/usr/bin/dropuser
/usr/bin/pg_dump
/usr/bin/pg_dumpall
/usr/bin/pg_encoding
/usr/bin/pg_id
/usr/bin/pg_restore
/usr/bin/psql
/usr/bin/vacuumdb
%{_mandir}/man1/createdb.1*
%{_mandir}/man1/createlang.1*
%{_mandir}/man1/createuser.1*
%{_mandir}/man1/dropdb.1*
%{_mandir}/man1/droplang.1*
%{_mandir}/man1/dropuser.1*
%{_mandir}/man1/pg_dump.1*
%{_mandir}/man1/pg_dumpall.1*
%{_mandir}/man1/psql.1*
%{_mandir}/man1/vacuumdb.1*
%{_mandir}/man7/*

%files docs
%defattr(-,root,root)
%doc doc/src/*

%files contrib
%defattr(-,root,root)
%dir /usr/lib/pgsql/contrib/
/usr/lib/pgsql/contrib/*

%files libs
%defattr(-,root,root)
/usr/lib/libpq.so.*
/usr/lib/libecpg.so.*
/usr/lib/libpq++.so.*
/usr/lib/libpgeasy.so.*

%files server -f files.lst
%defattr(-,root,root)
/usr/bin/initdb
/usr/bin/initlocation
/usr/bin/ipcclean
/usr/bin/pg_ctl
/usr/bin/pg_passwd
/usr/bin/postgres
/usr/bin/postgresql-dump
/usr/bin/postmaster
/usr/bin/rh-pgdump.sh
%{_mandir}/man1/initdb.1*
%{_mandir}/man1/initlocation.1*
%{_mandir}/man1/ipcclean.1*
%{_mandir}/man1/pg_ctl.1*
%{_mandir}/man1/pg_passwd.1*
%{_mandir}/man1/postgres.1*
%{_mandir}/man1/postmaster.1*
%{_mandir}/man1/postgresql-dump.1*
/usr/share/pgsql/postgres.bki
/usr/share/pgsql/postgres.description
/usr/share/pgsql/*.sample
/usr/lib/pgsql/plpgsql.so
%dir /usr/lib/pgsql
%dir /usr/share/pgsql
%attr(700,postgres,postgres) %dir /usr/share/pgsql/backup
/usr/share/pgsql/backup/pg_dumpall_new
%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

%files devel
%defattr(-,root,root)
/usr/include/*
/usr/bin/ecpg
/usr/bin/pg_config
/usr/lib/libpq.so
/usr/lib/libecpg.so
/usr/lib/libpq++.so
/usr/lib/libpgeasy.so
/usr/lib/libpgtcl.so
/usr/lib/libpq.a
/usr/lib/libecpg.a
/usr/lib/libpq++.a
/usr/lib/libpgeasy.a
/usr/lib/libpgtcl.a
%{_mandir}/man1/ecpg.1*
%{_mandir}/man1/pg_config.1*

%if %tcl
%files tcl
%defattr(-,root,root)
%attr(755,root,root) /usr/lib/libpgtcl.so.*
/usr/bin/pgtclsh
%{_mandir}/man1/pgtclsh.1*
/usr/lib/pgsql/pltcl.so
%endif

%if %tkpkg
%files tk
%defattr(-,root,root)
/usr/bin/pgtksh
%{_mandir}/man1/pgtksh.1*
%endif

%if %pgaccess
%doc doc/pgaccess/*
/usr/share/pgsql/pgaccess
/usr/bin/pgaccess
%{_mandir}/man1/pgaccess.1*
%endif

%if %odbc
%files odbc
%defattr(-,root,root)
%attr(755,root,root) /usr/lib/libpsqlodbc.so
/usr/share/pgsql/odbc.sql
%endif

%if %perl
%files -f perlfiles.list perl
%defattr (-,root,root)
%dir /usr/lib/perl5/site_perl/%{_arch}-linux/auto
/usr/share/pgsql/perl5
%{_mandir}/man3/Pg.*
%endif

%if %plperl
%files plperl
%defattr(-,root,root)
/usr/lib/pgsql/plperl.so
%endif

%if %python
%files python
%defattr(-,root,root)
%doc src/interfaces/python/README src/interfaces/python/tutorial
/usr/lib/python%{pyver}/site-packages/_pgmodule.so
/usr/lib/python%{pyver}/site-packages/*.py
%endif

%if %jdbc
%files jdbc
%defattr(-,root,root)
/usr/share/pgsql/jdbc7.0-1.1.jar
/usr/share/pgsql/jdbc7.1-1.2.jar
%endif

%if %test
%files test
%defattr(-,postgres,postgres)
%attr(-,postgres,postgres) /usr/lib/pgsql/test/*
%attr(-,postgres,postgres) %dir /usr/lib/pgsql/test
%endif

%changelog
* Mon Feb  4 2002 Trond Eivind Glomsrød <teg@redhat.com> 7.2-0.7
- 7.2

* Thu Jan 31 2002 Elliot Lee <sopwith@redhat.com> 7.2rc2-0.3
- Fix python dependencies

* Mon Jan 28 2002 Trond Eivind Glomsrød <teg@redhat.com> 7.2rc2-0.2
- Added Elliot Lee's python quote enhancement patch

* Fri Jan 25 2002 Trond Eivind Glomsrød <teg@redhat.com> 7.2rc2-0.1
- 7.2rc2
- Patches now included mainstream

* Wed Jan 23 2002 Trond Eivind Glomsrød <teg@redhat.com> 7.2rc1-0.2
- fix perl

* Wed Jan 23 2002 Trond Eivind Glomsrød <teg@redhat.com> 7.2rc1-0.1
- 7.2rc1
- Disable perl for now, it doesn't build...
- autoconf fixes 

* Thu Jan 17 2002 Trond Eivind Glomsrød <teg@redhat.com> 7.2b5-0.3
- Work around buggy autoconf test (AC_PROG_CC_WORKS)

* Tue Jan 15 2002 Trond Eivind Glomsrød <teg@redhat.com> 7.2b5-0.2
- 7.2b5

* Tue Nov 27 2001 Trond Eivind Glomsrød <teg@redhat.com>
- Improve python version handling

* Fri Nov 23 2001 Lamar Owen <lamar.owen@wgcr.org>
- 7.2b3-0.2PGDG
- second beta3 tarball.

* Thu Nov 22 2001 Lamar Owen <lamar.owen@wgcr.org>
- 7.2b3-0.1PGDG
- Beta3
- Docs changes --man pages back, internals.ps gone.
- manl (letter 'ell') is now 'man7'.

* Mon Nov 19 2001 Lamar Owen <lamar.owen@wgcr.org>
- 7.2b2-0.1PGDG
- --disable-rpath configure option.

* Fri Oct 26 2001 Lamar Owen <lamar.owen@wgcr.org>
- Actual PGDG 7.2b1.

* Mon Oct 01 2001 Lamar Owen <lamar.owen@wgcr.org>
- 7.2alpha-0.1PGDG
- Merged some changes from Peter Eisentraut for7.2.
- Cleaned up some legacy junk.
- Prepare for 7.2 beta cycle.