openssh.spec 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. ##
  2. ## openssh.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_pam
  27. %define with_pam no
  28. %endif
  29. %ifndef with_pcre
  30. %define with_pcre no
  31. %endif
  32. %ifndef with_skey
  33. %define with_skey no
  34. %endif
  35. # package information
  36. Name: openssh
  37. Summary: Secure Shell (SSH)
  38. URL: http://www.openssh.com/
  39. Vendor: The OpenBSD Project
  40. Packager: The OpenPKG Project
  41. Distribution: OpenPKG [REL]
  42. Group: Cryptography
  43. License: BSD
  44. Version: 3.1p1
  45. Release: 20020312
  46. # list of sources
  47. Source0: ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz
  48. Source1: fakesyslog.tar.gz
  49. Source2: rc.openssh
  50. Source3: sshd_config
  51. Source4: ssh_config
  52. Source5: ssh-askpass
  53. # build information
  54. Prefix: %{l_prefix}
  55. BuildRoot: %{l_buildroot}
  56. BuildPreReq: OpenPKG, openpkg >= 20020206, perl, openssl, zlib
  57. %if "%{with_pam}" == "yes"
  58. BuildPreReq: PAM
  59. PreReq: PAM
  60. %endif
  61. %if "%{with_pcre}" == "yes"
  62. BuildPreReq: pcre
  63. %endif
  64. %if "%{with_skey}" == "yes"
  65. BuildPreReq: skey
  66. %endif
  67. PreReq: OpenPKG, openpkg >= 20020206
  68. AutoReq: no
  69. AutoReqProv: no
  70. %description
  71. Secure Shell (SSH) is a facility for logging into a remote machine
  72. and for remotely executing commands on a remote machine. It is
  73. intended to replace rlogin(1) and rsh(1), and provide secure
  74. encrypted communications between two untrusted hosts over an
  75. insecure network. X11 connections and arbitrary TCP/IP ports can
  76. also be forwarded over the secure channel. OpenSSH is OpenBSD's
  77. rework of the last free version of SSH, bringing it up to date in
  78. terms of security and features, as well as removing all patented
  79. algorithms to separate libraries (OpenSSL).
  80. Options: with_pam=%{with_pam} with_pcre=%{with_pcre} with_skey=%{with_skey}
  81. %prep
  82. %setup0 -q -c -a 0
  83. %setup1 -q -T -D -a 1
  84. %build
  85. # build faked syslog(3) library
  86. fakesyslogdir="`pwd`/fakesyslog"
  87. ( cd fakesyslog
  88. CC="%{l_cc}" \
  89. CFLAGS="%{l_cflags -O}" \
  90. ./configure \
  91. --with-logfile=%{l_prefix}/var/openssh/sshd.log
  92. %{l_make} %{l_mflags}
  93. )
  94. # build OpenSSH
  95. ( cd openssh-%{version}
  96. inc="-I%{l_prefix}/include"
  97. lib="-L%{l_prefix}/lib -L$fakesyslogdir"
  98. %if "%{with_pam}" == "yes"
  99. inc="$inc -I`%{l_prefix}/etc/rc --query pam_incdir`"
  100. lib="$lib -L`%{l_prefix}/etc/rc --query pam_libdir`"
  101. %endif
  102. CC="%{l_cc}" \
  103. CFLAGS="%{l_cflags -O} $inc" \
  104. CPPFLAGS="$inc" \
  105. LDFLAGS="$lib" \
  106. LIBS="-lcrypt -lfakesyslog" \
  107. ./configure \
  108. --prefix=%{l_prefix} \
  109. --sbindir=%{l_prefix}/bin \
  110. --mandir=%{l_prefix}/man \
  111. --infodir=%{l_prefix}/info \
  112. --sysconfdir=%{l_prefix}/etc/openssh \
  113. --libexecdir=%{l_prefix}/libexec/openssh \
  114. --localstatedir=%{l_prefix}/var/openssh \
  115. --with-pid-dir=%{l_prefix}/var/openssh \
  116. --with-ssl-dir=%{l_prefix} \
  117. %if "%{with_pcre}" == "yes"
  118. --with-pcre=%{l_prefix} \
  119. %endif
  120. %if "%{with_skey}" == "yes"
  121. --with-skey=%{l_prefix} \
  122. %endif
  123. %if "%{with_pam}" == "yes"
  124. --with-pam \
  125. %else
  126. --without-pam \
  127. %endif
  128. --with-md5-passwords \
  129. --with-zlib=%{l_prefix} \
  130. --with-ipv4-default \
  131. --without-smartcard \
  132. --without-kerberos4 \
  133. --disable-suid-ssh \
  134. --without-rsh \
  135. --with-mantype=man \
  136. --with-default-path=%{l_prefix}/bin:/bin:/usr/bin:/usr/local/bin
  137. # build package
  138. %{l_make} %{l_mflags -O}
  139. )
  140. %install
  141. rm -rf $RPM_BUILD_ROOT
  142. # perform standard installation procedure of OpenSSH
  143. ( cd openssh-%{version}
  144. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  145. )
  146. # strip down installation tree
  147. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share
  148. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/slogin
  149. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/slogin.1
  150. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2> /dev/null || true
  151. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/* 2> /dev/null || true
  152. # install ssh-askpass wrapper
  153. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  154. %{SOURCE ssh-askpass} $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  155. # make sure the state directory exists
  156. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/openssh
  157. # install run-command script
  158. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  159. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  160. -e 's;@l_musr@;%{l_musr};g' -e 's;@l_mgrp@;%{l_mgrp};g' \
  161. %{SOURCE rc.openssh} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  162. # install reasonable ssh server and client configuration files
  163. case "%{l_target}" in
  164. *-freebsd* ) uselogin=yes; printmotd=no ;;
  165. *-linux* ) uselogin=yes; printmotd=no ;;
  166. *-solaris* ) uselogin=no; printmotd=yes ;; # "uselogin" does not work on Solaris!
  167. esac
  168. %{l_shtool} install -c -m 644 \
  169. -e 's;@l_prefix@;%{l_prefix};g' \
  170. -e "s;@uselogin@;$uselogin;" \
  171. -e "s;@printmotd@;$printmotd;" \
  172. %{SOURCE sshd_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  173. %{l_shtool} install -c -m 644 -e 's;@l_prefix@;%{l_prefix};g' \
  174. %{SOURCE ssh_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  175. # determine installation files
  176. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  177. %{l_files_std} \
  178. '%config %{l_prefix}/etc/openssh/*'
  179. %files -f files
  180. %clean
  181. rm -rf $RPM_BUILD_ROOT
  182. %post
  183. # generate server RSA key
  184. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" -o \
  185. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" ] ; then
  186. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa1 -b 1024 \
  187. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key \
  188. -N '' -C `hostname` 1>&2
  189. fi
  190. # generate server DSA key
  191. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" -o \
  192. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" ] ; then
  193. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t dsa -d \
  194. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key \
  195. -N '' -C `hostname` 1>&2
  196. fi
  197. # add PAM configuration entry
  198. %if "%{with_pam}" == "yes"
  199. $RPM_INSTALL_PREFIX/sbin/pamtool -a -s -n "openssh"
  200. %endif
  201. %preun
  202. # remove PAM configuration entry
  203. %if "%{with_pam}" == "yes"
  204. $RPM_INSTALL_PREFIX/sbin/pamtool -r -s -n "openssh"
  205. %endif