summaryrefslogtreecommitdiffstats
path: root/postgresql91/postgresql.spec.diff
blob: af7ab90ec55e3e191e57d44e7bfc81bfcfa9546c (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
--- postgresql.spec.nodsc	2012-03-29 11:25:13.635351493 +0200
+++ postgresql.spec	2012-08-20 14:30:19.263974141 +0200
@@ -29,6 +29,8 @@
 # The base package, the libs package, the devel package, and the server package
 # always get built.
 
+%{?scl:%scl_package postgresql}
+
 %global beta 0
 %{?beta:%global __os_install_post /usr/lib/rpm/brp-compress}
 
@@ -46,11 +48,12 @@
 %{!?pam:%global pam 1}
 %{!?sdt:%global sdt 1}
 %{!?selinux:%global selinux 1}
-%{!?runselftest:%global runselftest 1}
+%{!?runselftest:%global runselftest 0}
+%{!?_unitdir:%global _unitdir /lib/systemd/system}
 
 
 Summary: PostgreSQL client programs
-Name: postgresql
+Name: %{?scl_prefix}postgresql
 %global majorversion 9.1
 Version: 9.1.3
 Release: 3%{?dist}
@@ -61,9 +64,6 @@ License: PostgreSQL
 Group: Applications/Databases
 Url: http://www.postgresql.org/
 
-# This number must be NVR-greater than any PG version shipped in F15:
-%global first_systemd_version 0:9.0.99
-
 # This SRPM includes a copy of the previous major release, which is needed for
 # in-place upgrade of an old database.  In most cases it will not be critical
 # that this be kept up with the latest minor release of the previous series.
@@ -95,7 +95,6 @@ Patch3: postgresql-perl-rpath.patch
 BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk
 BuildRequires: perl(ExtUtils::Embed), perl-devel
 BuildRequires: readline-devel zlib-devel
-BuildRequires: systemd-units
 
 %if %plpython
 BuildRequires: python-devel
@@ -144,6 +143,8 @@ BuildRequires: libselinux-devel
 # main package requires -libs subpackage
 Requires: %{name}-libs%{?_isa} = %{version}-%{release}
 
+%{?scl:Requires:%scl_runtime}
+
 Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
 
 %description
@@ -180,15 +181,13 @@ Requires(pre): /usr/sbin/useradd
 # for /sbin/ldconfig
 Requires(post): glibc
 Requires(postun): glibc
-# pre/post stuff needs systemd too
-Requires(post): systemd-units
-Requires(preun): systemd-units
-Requires(postun): systemd-units
 # This is actually needed for the %%triggerun script but Requires(triggerun)
 # is not valid.  We can use post because this particular %%triggerun script
 # should fire just after this package is installed.
-Requires(post): systemd-sysv
 Requires(post): chkconfig
+# This is for /sbin/service
+Requires(preun): initscripts
+Requires(postun): initscripts
 
 %description server
 PostgreSQL is an advanced Object-Relational database management system (DBMS).
@@ -298,7 +297,7 @@ benchmarks.
 %endif
 
 %prep
-%setup -q 
+%setup -q %{?scl:-n %{pkg_name}-%{version}}
 %patch1 -p1
 %patch2 -p1
 %patch3 -p1
@@ -349,7 +348,7 @@ CFLAGS="$CFLAGS -DLINUX_OOM_ADJ=0"
 %endif
 %if %pltcl
 	--with-tcl \
-	--with-tclconfig=%{_libdir} \
+	--with-tclconfig=%{?scl:%_root_libdir}%{!?scl:%_libdir} \
 %endif
 %if %plpython
 	--with-python \
@@ -383,8 +382,8 @@ CFLAGS="$CFLAGS -DLINUX_OOM_ADJ=0"
 %if %selinux
 	--with-selinux \
 %endif
-	--with-system-tzdata=/usr/share/zoneinfo \
-	--datadir=/usr/share/pgsql
+	--with-system-tzdata=%{?scl:%_root_datadir}%{!?scl:%_datadir}/zoneinfo \
+	--datadir=%{_datadir}/pgsql
 
 make %{?_smp_mflags} world
 
@@ -424,7 +423,7 @@ rm -f src/tutorial/GNUmakefile
 	./configure --build=%{_build} --host=%{_host} \
 		--prefix=%{_libdir}/pgsql/postgresql-%{prevmajorversion} \
 		--disable-rpath \
-		--with-system-tzdata=/usr/share/zoneinfo
+		--with-system-tzdata=%{?scl:%_root_datadir}%{!?scl:%_datadir}/zoneinfo
 
 	make %{?_smp_mflags} all
 
@@ -440,12 +439,12 @@ make DESTDIR=$RPM_BUILD_ROOT install-wor
 # we only apply this to known Red Hat multilib arches, per bug #177564
 case `uname -i` in
   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
-    install -m 644 %{SOURCE6} $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 %{SOURCE6} $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
-    install -m 644 %{SOURCE7} $RPM_BUILD_ROOT/usr/include/
+    mv $RPM_BUILD_ROOT%{_includedir}/pg_config.h $RPM_BUILD_ROOT%{_includedir}/pg_config_`uname -i`.h
+    install -m 644 %{SOURCE6} $RPM_BUILD_ROOT%{_includedir}/
+    mv $RPM_BUILD_ROOT%{_includedir}/pgsql/server/pg_config.h $RPM_BUILD_ROOT%{_includedir}/pgsql/server/pg_config_`uname -i`.h
+    install -m 644 %{SOURCE6} $RPM_BUILD_ROOT%{_includedir}/pgsql/server/
+    mv $RPM_BUILD_ROOT%{_includedir}/ecpg_config.h $RPM_BUILD_ROOT%{_includedir}/ecpg_config_`uname -i`.h
+    install -m 644 %{SOURCE7} $RPM_BUILD_ROOT%{_includedir}/
     ;;
   *)
     ;;
@@ -459,8 +458,11 @@ sed -e 's|^PGVERSION=.*$|PGVERSION=%{ver
 	-e 's|^PGENGINE=.*$|PGENGINE=%{_bindir}|' \
 	-e 's|^PREVMAJORVERSION=.*$|PREVMAJORVERSION=%{prevmajorversion}|' \
 	-e 's|^PREVPGENGINE=.*$|PREVPGENGINE=%{_libdir}/pgsql/postgresql-%{prevmajorversion}/bin|' \
+	-e 's|SERVICE_NAME=postgresql|SERVICE_NAME=%{?scl_prefix}postgresql|' \
+	-e 's|/var/lib|%{?_scl_root}/var/lib|' \
 	<%{SOURCE9} >postgresql-setup
 touch -r %{SOURCE9} postgresql-setup
+
 install -m 755 postgresql-setup $RPM_BUILD_ROOT%{_bindir}/postgresql-setup
 
 # prep the startup check script, including insertion of some values it needs
@@ -472,24 +474,44 @@ touch -r %{SOURCE4} postgresql-check-db-
 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 -m 644 %{SOURCE10} $RPM_BUILD_ROOT%{_unitdir}/%{?scl_prefix}postgresql.service
+
+install -d $RPM_BUILD_ROOT%{_libdir}/pgsql
+cat > sclenv << EOF
+# scl-related environment variables
+# LD_LIBRARY_PATH=%_libdir:\$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=%_libdir
+EOF
+install -m 644 sclenv $RPM_BUILD_ROOT%{_libdir}/pgsql/sclenv
+
+install -d  $RPM_BUILD_ROOT%{_prefix}/var/run
+install -d  $RPM_BUILD_ROOT%{_prefix}/var/lock/subsys
 
 install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
-install -m 755 %{SOURCE11} $RPM_BUILD_ROOT/etc/rc.d/init.d/postgresql
+sed -e 's|/# Provides: postgresql|# Provides: %{?scl_prefix}postgresql|g' \
+	-e 's|/etc/sysconfig/pgsql|%{_sysconfdir}/sysconfig/pgsql|g' \
+	-e 's|/usr/bin|%{_bindir}|g' \
+	-e 's|^PGVERSION=.*$|PGVERSION=%{version}|' \
+	-e 's|^PGENGINE=.*$|PGENGINE=%{_bindir}|' \
+	-e 's|^PREVMAJORVERSION=.*$|PREVMAJORVERSION=%{prevmajorversion}|' \
+	-e 's|^PREVPGENGINE=.*$|PREVPGENGINE=%{_libdir}/pgsql/postgresql-%{prevmajorversion}/bin|' \
+	-e 's|SERVICE_NAME=postgresql|SERVICE_NAME=%{?scl_prefix}postgresql|' \
+	<%{SOURCE11} >postgresql.init
+install -m 755 postgresql.init $RPM_BUILD_ROOT/etc/rc.d/init.d/%{?scl_prefix}postgresql
 
 %if %pam
 install -d $RPM_BUILD_ROOT/etc/pam.d
-install -m 644 %{SOURCE14} $RPM_BUILD_ROOT/etc/pam.d/postgresql
+install -m 644 %{SOURCE14} $RPM_BUILD_ROOT/etc/pam.d/%{?scl_prefix}postgresql
 %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
+install -d -m 700 $RPM_BUILD_ROOT%{?_scl_root}/var/lib/pgsql/data
 
 # backups of data go here...
-install -d -m 700 $RPM_BUILD_ROOT/var/lib/pgsql/backups
+install -d -m 700 $RPM_BUILD_ROOT%{?_scl_root}/var/lib/pgsql/backups
 
 # postgres' .bash_profile
-install -m 644 %{SOURCE15} $RPM_BUILD_ROOT/var/lib/pgsql/.bash_profile
+install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{?_scl_root}/var/lib/pgsql/.bash_profile
 
 
 %if %upgrade
@@ -623,40 +645,57 @@ cat psql-%{majorversion}.lang >>main.lst
 
 %pre server
 /usr/sbin/groupadd -g 26 -o -r postgres >/dev/null 2>&1 || :
-/usr/sbin/useradd -M -N -g postgres -o -r -d /var/lib/pgsql -s /bin/bash \
+/usr/sbin/useradd -M -N -g postgres -o -r -d %{?_scl_root}/var/lib/pgsql -s /bin/bash \
 	-c "PostgreSQL Server" -u 26 postgres >/dev/null 2>&1 || :
 
 %post server
-/sbin/ldconfig
-if [ $1 -eq 1 ] ; then
-    # Initial installation
-    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ -e /bin/systemctl ] ; then
+    # We don't want old init script if we have systemd
+    rm -f /etc/rc.d/init.d/%{?scl_prefix}postgresql
+
+    if [ $1 -eq 1 ] ; then
+        # Initial installation
+        /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+    fi
+
+    # Run this when upgrading from SysV initscript to native systemd unit
+    %triggerun server -- postgresql-server < %{first_systemd_version}
+    # Save the current service runlevel info
+    # User must manually run systemd-sysv-convert --apply postgresql
+    # to migrate them to systemd targets
+    /usr/bin/systemd-sysv-convert --save postgresql >/dev/null 2>&1 || :
+
+    # Run these because the SysV package being removed won't do them
+    /sbin/chkconfig --del postgresql >/dev/null 2>&1 || :
+    /bin/systemctl try-restart %{?scl_prefix}postgresql.service >/dev/null 2>&1 || :
+else
+    # We don't want new systemd unit file if we don't have systemd
+    rm -f %{_unitdir}/%{?scl_prefix}postgresql.service
+    /sbin/chkconfig --add %{?scl_prefix}postgresql
+    /sbin/ldconfig
 fi
 
-# Run this when upgrading from SysV initscript to native systemd unit
-%triggerun server -- postgresql-server < %{first_systemd_version}
-# Save the current service runlevel info
-# User must manually run systemd-sysv-convert --apply postgresql
-# to migrate them to systemd targets
-/usr/bin/systemd-sysv-convert --save postgresql >/dev/null 2>&1 || :
-
-# Run these because the SysV package being removed won't do them
-/sbin/chkconfig --del postgresql >/dev/null 2>&1 || :
-/bin/systemctl try-restart postgresql.service >/dev/null 2>&1 || :
-
 %preun server
 if [ $1 -eq 0 ] ; then
     # Package removal, not upgrade
-    /bin/systemctl --no-reload disable postgresql.service >/dev/null 2>&1 || :
-    /bin/systemctl stop postgresql.service >/dev/null 2>&1 || :
+    if [ -e /bin/systemctl ] ; then
+        /bin/systemctl --no-reload disable %{?scl_prefix}postgresql.service >/dev/null 2>&1 || :
+        /bin/systemctl stop %{?scl_prefix}postgresql.service >/dev/null 2>&1 || :
+    else
+        /sbin/service %{?scl_prefix}postgresql stop >/dev/null 2>&1
+        /sbin/chkconfig --del %{?scl_prefix}postgresql
+    fi
 fi
 
 %postun server
 /sbin/ldconfig 
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :
 if [ $1 -ge 1 ] ; then
     # Package upgrade, not uninstall
-    /bin/systemctl try-restart postgresql.service >/dev/null 2>&1 || :
+    if [ -e /bin/systemctl ] ; then
+        /bin/systemctl try-restart %{?scl_prefix}postgresql.service >/dev/null 2>&1 || :
+    else
+        /sbin/service %{?scl_prefix}postgresql condrestart >/dev/null 2>&1 || :
+    fi
 fi
 
 %if %plperl
@@ -833,10 +872,11 @@ rm -rf $RPM_BUILD_ROOT
 
 %files server -f server.lst
 %defattr(-,root,root)
-%{_unitdir}/postgresql.service
-/etc/rc.d/init.d/postgresql
+%{_libdir}/pgsql/sclenv
+%{_unitdir}/%{?scl_prefix}postgresql.service
+/etc/rc.d/init.d/%{?scl_prefix}postgresql
 %if %pam
-%config(noreplace) /etc/pam.d/postgresql
+%config(noreplace) /etc/pam.d/%{?scl_prefix}postgresql
 %endif
 %{_bindir}/initdb
 %{_bindir}/pg_basebackup
@@ -867,10 +907,10 @@ rm -rf $RPM_BUILD_ROOT
 %dir %{_datadir}/pgsql/contrib
 %dir %{_datadir}/pgsql/extension
 %{_datadir}/pgsql/extension/plpgsql*
-%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
+%attr(700,postgres,postgres) %dir %{?_scl_root}/var/lib/pgsql
+%attr(700,postgres,postgres) %dir %{?_scl_root}/var/lib/pgsql/data
+%attr(700,postgres,postgres) %dir %{?_scl_root}/var/lib/pgsql/backups
+%attr(644,postgres,postgres) %config(noreplace) %{?_scl_root}/var/lib/pgsql/.bash_profile
 %{_libdir}/pgsql/libpqwalreceiver.so
 %{_libdir}/pgsql/*_and_*.so
 %{_libdir}/pgsql/euc2004_sjis2004.so
@@ -878,10 +918,12 @@ rm -rf $RPM_BUILD_ROOT
 %{_datadir}/pgsql/information_schema.sql
 %{_datadir}/pgsql/snowball_create.sql
 %{_datadir}/pgsql/sql_features.txt
+%dir %{_prefix}/var/run
+%dir %{_prefix}/var/lock/subsys
 
 %files devel -f devel.lst
 %defattr(-,root,root)
-/usr/include/*
+%{_includedir}/*
 %{_bindir}/ecpg
 %{_libdir}/libpq.so
 %{_libdir}/libecpg.so