postgresql.spec 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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_perl
  27. %define with_perl yes
  28. %endif
  29. # package information
  30. Name: postgresql
  31. Summary: PostgreSQL Database
  32. URL: http://www.postgresql.org/
  33. Vendor: PostgreSQL Group
  34. Packager: The OpenPKG Project
  35. Distribution: OpenPKG [BASE]
  36. Group: Database
  37. License: GPL
  38. Version: 7.2.1
  39. Release: 20020821
  40. # list of sources
  41. Source0: ftp://ftp.de.postgresql.org/mirror/postgresql/source/v7.2/postgresql-%{version}.tar.gz
  42. Source1: rc.postgresql
  43. # build information
  44. Prefix: %{l_prefix}
  45. BuildRoot: %{l_buildroot}
  46. BuildPreReq: OpenPKG, openpkg >= 20020416, make, gcc, readline, openssl, flex, bison
  47. PreReq: OpenPKG, openpkg >= 20020416
  48. %if "%{with_perl}" == "yes"
  49. BuildPreReq: perl
  50. PreReq: perl
  51. %endif
  52. AutoReq: no
  53. AutoReqProv: no
  54. %description
  55. PostgreSQL is a sophisticated Object-Relational DBMS, supporting
  56. almost all SQL constructs, including subselects, transactions,
  57. and user-defined types and functions. It is the most advanced
  58. open-source database available anywhere.
  59. Options:
  60. --define 'with_perl %{with_perl}'
  61. %prep
  62. %setup -q
  63. %{l_shtool} subst \
  64. -e 's;\(#define.*DEFAULT_PGSOCKET_DIR[^"]*"\)/tmp\("\);\1%{l_prefix}/var/postgresql/run\2;' \
  65. src/include/pg_config.h.in
  66. %build
  67. # configure package
  68. CC="%{l_cc}" \
  69. CFLAGS="%{l_cflags -O}" \
  70. ./configure \
  71. --prefix=%{l_prefix} \
  72. --with-openssl=%{l_prefix} \
  73. %if "%{with_perl}" == "yes"
  74. --with-perl \
  75. %endif
  76. --without-CXX \
  77. --disable-syslog
  78. # build package
  79. %{l_make} %{l_mflags -O}
  80. %install
  81. rm -rf $RPM_BUILD_ROOT
  82. # perform standard installation procedure
  83. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  84. # strip down installation
  85. rm -rf $RPM_BUILD_ROOT%{l_prefix}/doc
  86. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
  87. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgaccess.1
  88. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtclsh.1
  89. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/pgtksh.1
  90. # namespace adjustments to installation
  91. for prog in \
  92. createdb createlang createuser dropdb droplang \
  93. dropuser initdb initlocation ipcclean vacuumdb; do
  94. mv $RPM_BUILD_ROOT%{l_prefix}/bin/$prog \
  95. $RPM_BUILD_ROOT%{l_prefix}/bin/pg_$prog
  96. mv $RPM_BUILD_ROOT%{l_prefix}/man/man1/$prog.1 \
  97. $RPM_BUILD_ROOT%{l_prefix}/man/man1/pg_$prog.1
  98. done
  99. ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man7
  100. for man in *.7; do
  101. mv $man pg_$man
  102. done
  103. )
  104. # create additional directories
  105. %{l_shtool} mkdir -f -p -m 755 \
  106. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/db \
  107. $RPM_BUILD_ROOT%{l_prefix}/var/postgresql/run
  108. # install run-command script
  109. %{l_shtool} mkdir -f -p -m 755 \
  110. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  111. %{l_shtool} install -c -m 755 \
  112. -e 's;@l_prefix@;%{l_prefix};g' \
  113. -e 's;@l_rusr@;%{l_rusr};g' \
  114. -e 's;@l_rgrp@;%{l_rgrp};g' \
  115. %{SOURCE rc.postgresql} \
  116. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  117. # determine installation files
  118. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  119. %{l_files_std} \
  120. '%attr(700,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/db' \
  121. '%attr(755,%{l_rusr},%{l_rgrp}) %dir %{l_prefix}/var/postgresql/run'
  122. %files -f files
  123. %clean
  124. rm -rf $RPM_BUILD_ROOT
  125. %post
  126. if [ ".$1" = .1 ]; then
  127. # create initial database
  128. su - %{l_rusr} -c \
  129. "LC_CTYPE=C; export LC_CTYPE; umask 022; \
  130. (echo 'postgresql'; echo 'postgresql') |\
  131. $RPM_INSTALL_PREFIX/bin/pg_initdb \
  132. -U postgresql -W -D $RPM_INSTALL_PREFIX/var/postgresql/db" 2>&1 |\
  133. $RPM_INSTALL_PREFIX/lib/openpkg/shtool prop \
  134. -p "Creating initial PostgreSQL DB in $RPM_INSTALL_PREFIX/var/postgresql/db"
  135. # adjust initial authentication configuration
  136. cp $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf \
  137. $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf.old
  138. ( cat $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf.old |\
  139. sed -e 's;^\([^#]\);# \1;' -e 's;^$;#;'
  140. echo ""
  141. echo "# OpenPKG PostgreSQL default access policy"
  142. echo "local all md5"
  143. echo "host all 127.0.0.1 255.255.255.255 md5"
  144. echo ""
  145. ) >$RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf
  146. rm -f $RPM_INSTALL_PREFIX/var/postgresql/db/pg_hba.conf.old
  147. # display information about next steps
  148. ( echo "An initial PostgreSQL DB was created with the two standard"
  149. echo "databases 'template0' and 'template1'. The owner of both"
  150. echo "is the DB user 'postgresql'. Its initial password is 'postgresql'."
  151. echo "After starting PostgreSQL you should change this as quick as"
  152. echo "possible with the following command:"
  153. echo "\$ $RPM_INSTALL_PREFIX/bin/psql -U postgresql -d template1 \\"
  154. echo " -c \"ALTER USER postgresql WITH PASSWORD '<new-password>'\""
  155. ) | %{l_rpmtool} msg -b -t notice
  156. fi