postgresql.spec 6.2 KB

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