postgresql.spec 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. ##
  2. ## postgresql.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
  6. ##
  7. ## Permission to use, copy, modify, and distribute this software for
  8. ## any purpose with or without fee is hereby granted, provided that
  9. ## the above copyright notice and this permission notice appear in all
  10. ## copies.
  11. ##
  12. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. ## SUCH DAMAGE.
  24. ##
  25. # package options
  26. %ifndef with_openssl
  27. %define with_openssl no
  28. %endif
  29. %ifndef with_odbc
  30. %define with_odbc no
  31. %endif
  32. %ifndef with_perl
  33. %define with_perl no
  34. %endif
  35. %ifndef with_tcl
  36. %define with_tcl no
  37. %endif
  38. # package information
  39. Name: postgresql
  40. Summary: PostgreSQL Database
  41. URL: http://www.postgresql.org/
  42. Vendor: PostgreSQL Group
  43. Packager: The OpenPKG Project
  44. Distribution: OpenPKG [BASE]
  45. Group: Database
  46. License: GPL
  47. Version: 7.2.2
  48. Release: 20020914
  49. # list of sources
  50. Source0: ftp://ftp.postgresql.org/pub/source/v7.2/postgresql-%{version}.tar.gz
  51. Source1: rc.postgresql
  52. # build information
  53. Prefix: %{l_prefix}
  54. BuildRoot: %{l_buildroot}
  55. BuildPreReq: OpenPKG, openpkg >= 20020416, make, gcc, readline, flex, bison
  56. PreReq: OpenPKG, openpkg >= 20020416
  57. %if "%{with_openssl}" == "yes"
  58. BuildPreReq: openssl
  59. %endif
  60. %if "%{with_odbc}" == "yes"
  61. BuildPreReq: unixodbc
  62. PreReq: unixodbc
  63. %endif
  64. %if "%{with_perl}" == "yes"
  65. BuildPreReq: perl
  66. PreReq: perl
  67. %endif
  68. %if "%{with_tcl}" == "yes"
  69. BuildPreReq: tcl
  70. PreReq: tcl
  71. %endif
  72. AutoReq: no
  73. AutoReqProv: no
  74. %description
  75. PostgreSQL is a sophisticated Object-Relational DBMS, supporting
  76. almost all SQL constructs, including subselects, transactions,
  77. and user-defined types and functions. It is the most advanced
  78. open-source database available anywhere.
  79. Options:
  80. --define 'with_openssl %{with_openssl}'
  81. --define 'with_odbc %{with_odbc}'
  82. --define 'with_perl %{with_perl}'
  83. --define 'with_tcl %{with_tcl}'
  84. %prep
  85. %setup -q
  86. %{l_shtool} subst \
  87. -e 's;\(#define.*DEFAULT_PGSOCKET_DIR[^"]*"\)/tmp\("\);\1%{l_prefix}/var/postgresql/run\2;' \
  88. src/include/pg_config.h.in
  89. %build
  90. # configure package
  91. CC="%{l_cc}"; export CC
  92. CFLAGS="%{l_cflags -O}"; export CFLAGS
  93. CPPFLAGS="%{l_cppflags}"; export CPPFLAGS
  94. LDFLAGS="%{l_ldflags}"; export LDFLAGS
  95. %if "%{with_odbc}" == "yes"
  96. %endif
  97. %if "%{with_tcl}" == "yes"
  98. CFLAGS="$CFLAGS -I%{l_prefix}/include/tcl"
  99. LDFLAGS="$LDFLAGS -L%{l_prefix}/lib"
  100. %endif
  101. ./configure \
  102. --prefix=%{l_prefix} \
  103. %if "%{with_openssl}" == "yes"
  104. --with-openssl=%{l_prefix} \
  105. %endif
  106. %if "%{with_odbc}" == "yes"
  107. --enable-odbc \
  108. --with-unixodbc \
  109. --with-odbcinst=%{l_prefix}/etc/unixodbc \
  110. %endif
  111. %if "%{with_perl}" == "yes"
  112. --with-perl \
  113. %endif
  114. %if "%{with_tcl}" == "yes"
  115. --with-tcl \
  116. %endif
  117. --without-CXX \
  118. --disable-syslog
  119. # build package
  120. %{l_make} %{l_mflags -O}
  121. %install
  122. rm -rf $RPM_BUILD_ROOT
  123. # perform standard installation procedure
  124. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  125. # strip down installation
  126. rm -rf $RPM_BUILD_ROOT%{l_prefix}/doc
  127. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  128. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgaccess.1
  129. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtclsh.1
  130. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtksh.1
  131. # namespace adjustments to installation
  132. for prog in \
  133. createdb createlang createuser dropdb droplang \
  134. dropuser initdb initlocation ipcclean vacuumdb; do
  135. mv $RPM_BUILD_ROOT%{l_prefix}/bin/$prog \
  136. $RPM_BUILD_ROOT%{l_prefix}/bin/pg_$prog
  137. mv $RPM_BUILD_ROOT%{l_prefix}/man/man1/$prog.1 \
  138. $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_$prog.1
  139. done
  140. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man7
  141. for man in *.7; do
  142. mv $man pg_$man
  143. done
  144. )
  145. # optionally install pgAccess startup wrapper
  146. %if "%{with_tcl}" == "yes"
  147. ( LD_LIBRARY_PATH=%{l_prefix}/lib:$LD_LIBRARY_PATH
  148. %{l_prefix}/share/postgresql/pgaccess/main.tcl ${1+"$@"}
  149. ) >$RPM_BUILD_ROOT%{l_prefix}/bin/pgaccess
  150. chmod 755 $RPM_BUILD_ROOT%{l_prefix}/bin/pgaccess
  151. %endif
  152. # create additional directories
  153. %{l_shtool} mkdir -f -p -m 755 \
  154. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/db \
  155. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/run
  156. # install run-command script
  157. %{l_shtool} mkdir -f -p -m 755 \
  158. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  159. %{l_shtool} install -c -m 755 \
  160. -e 's;@l_prefix@;%{l_prefix};g' \
  161. -e 's;@l_rusr@;%{l_rusr};g' \
  162. -e 's;@l_rgrp@;%{l_rgrp};g' \
  163. %{SOURCE rc.postgresql} \
  164. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  165. # determine installation files
  166. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  167. %{l_files_std} \
  168. '%attr(700,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/db' \
  169. '%attr(755,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/run'
  170. %files -f files
  171. %clean
  172. rm -rf $RPM_BUILD_ROOT
  173. %post
  174. if [ ".$1" = .1 ]; then
  175. # create initial database
  176. su - %{l_rusr} -c \
  177. "LC_CTYPE=C; export LC_CTYPE; umask 022; \
  178. (echo 'postgresql'; echo 'postgresql') |\
  179. $RPM_INSTALL_PREFIX/bin/pg_initdb \
  180. -U postgresql -W -D $RPM_INSTALL_PREFIX/var/postgresql/db" 2>&1 |\
  181. $RPM_INSTALL_PREFIX/lib/openpkg/shtool prop \
  182. -p "Creating initial PostgreSQL DB in $RPM_INSTALL_PREFIX/var/postgresql/db"
  183. # adjust initial authentication configuration
  184. cp $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf \
  185. $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf.old
  186. ( cat $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf.old |\
  187. sed -e 's;^\([^#]\);# \1;' -e 's;^$;#;'
  188. echo ""
  189. echo "# OpenPKG PostgreSQL default access policy"
  190. echo "local all md5"
  191. echo "host all 127.0.0.1 255.255.255.255 md5"
  192. echo ""
  193. ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf
  194. rm -f $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf.old
  195. # display information about next steps
  196. ( echo "An initial PostgreSQL DB was created with the two standard"
  197. echo "databases 'template0' and 'template1'. The owner of both"
  198. echo "is the DB user 'postgresql'. Its initial password is 'postgresql'."
  199. echo "After starting PostgreSQL you should change this as quick as"
  200. echo "possible with the following command:"
  201. echo "\$ $RPM_INSTALL_PREFIX/bin/psql -U postgresql -d template1 \\"
  202. echo " -c \"ALTER USER postgresql WITH PASSWORD '<new-password>'\""
  203. ) | %{l_rpmtool} msg -b -t notice
  204. # optionally link into unixODBC
  205. %if "%{with_odbc}" == "yes"
  206. ( echo "[PostgreSQL]"
  207. echo "Description = PostgreSQL ODBC driver"
  208. echo "Driver = $RPM_INSTALL_PREFIX/lib/libodbcpsql.so"
  209. echo "Setup = $RPM_INSTALL_PREFIX/lib/libodbcpsqlS.so"
  210. echo "Threading = 2"
  211. ) $RPM_INSTALL_PREFIX/bin/odbcinst -i -d -r
  212. %endif
  213. fi