openssh.spec 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. ##
  2. ## openssh.spec -- OpenPKG RPM Specification
  3. ## Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
  4. ## Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2003 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 versions
  26. %define V_base 3.6.1
  27. %define V_portable p2
  28. %define V_chroot 3.6.1
  29. # package information
  30. Name: openssh
  31. Summary: Secure Shell (SSH)
  32. URL: http://www.openssh.com/
  33. Vendor: The OpenBSD Project
  34. Packager: The OpenPKG Project
  35. Distribution: OpenPKG [CORE]
  36. Group: Security
  37. License: BSD
  38. Version: %{V_base}%{V_portable}
  39. Release: 20030624
  40. # package options
  41. %option with_fsl yes
  42. %option with_pam no
  43. %option with_pcre no
  44. %option with_skey no
  45. %option with_x11 no
  46. %option with_chroot no
  47. # list of sources
  48. Source0: ftp://ftp.openssh.com/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz
  49. Source1: rc.openssh
  50. Source2: fsl.openssh
  51. Source3: sshd_config
  52. Source4: ssh_config
  53. Source5: ssh-askpass
  54. Source6: ssh-keyman
  55. Source7: ssh-keyman.1
  56. Source8: ssh-keyman.pod
  57. Source9: http://chrootssh.sourceforge.net/download/osshChroot-%{V_chroot}.diff
  58. # build information
  59. Prefix: %{l_prefix}
  60. BuildRoot: %{l_buildroot}
  61. BuildPreReq: OpenPKG, openpkg >= 20030415, perl, openssl, zlib
  62. PreReq: OpenPKG, openpkg >= 20030415
  63. %if "%{with_pam}" == "yes"
  64. BuildPreReq: PAM
  65. PreReq: PAM
  66. %endif
  67. %if "%{with_fsl}" == "yes"
  68. BuildPreReq: fsl
  69. PreReq: fsl
  70. %endif
  71. %if "%{with_pcre}" == "yes"
  72. BuildPreReq: pcre
  73. %endif
  74. %if "%{with_skey}" == "yes"
  75. BuildPreReq: skey
  76. %endif
  77. %if "%{with_x11}" == "yes"
  78. BuildPreReq: X11
  79. PreReq: X11
  80. %endif
  81. AutoReq: no
  82. AutoReqProv: no
  83. %description
  84. Secure Shell (SSH) is a facility for logging into a remote machine
  85. and for remotely executing commands on a remote machine. It is
  86. intended to replace rlogin(1) and rsh(1), and provide secure
  87. encrypted communications between two untrusted hosts over an
  88. insecure network. X11 connections and arbitrary TCP/IP ports can
  89. also be forwarded over the secure channel. OpenSSH is OpenBSD's
  90. rework of the last free version of SSH, bringing it up to date in
  91. terms of security and features, as well as removing all patented
  92. algorithms to separate libraries (OpenSSL).
  93. %prep
  94. # unpack distribution
  95. %setup -q
  96. # optionally apply chroot(2) patch
  97. %if "%{with_chroot}" == "yes"
  98. %{l_patch} -p1 <%{SOURCE osshChroot-%{V_chroot}.diff}
  99. %endif
  100. # prevent in advance "make install" from running sshd
  101. %{l_shtool} subst \
  102. -e 's;^\(install:.*\)check-config\(.*\)$;\1 \2;' \
  103. Makefile.in
  104. %build
  105. # configure package
  106. inc="%{l_cppflags}"
  107. lib="%{l_ldflags}"
  108. %if "%{with_pam}" == "yes"
  109. inc="$inc -I`%{l_prefix}/etc/rc --query pam_incdir`"
  110. lib="$lib -L`%{l_prefix}/etc/rc --query pam_libdir`"
  111. %endif
  112. CC="%{l_cc}" \
  113. CFLAGS="%{l_cflags -O} $inc" \
  114. LDFLAGS="%{l_ldflags} %{l_fsl_ldflags} $lib" \
  115. LIBS="%{l_fsl_libs}" \
  116. ./configure \
  117. --prefix=%{l_prefix} \
  118. --sbindir=%{l_prefix}/bin \
  119. --mandir=%{l_prefix}/man \
  120. --infodir=%{l_prefix}/info \
  121. --sysconfdir=%{l_prefix}/etc/openssh \
  122. --libexecdir=%{l_prefix}/libexec/openssh \
  123. --localstatedir=%{l_prefix}/var/openssh \
  124. --with-pid-dir=%{l_prefix}/var/openssh \
  125. --with-ssl-dir=%{l_prefix} \
  126. %if "%{with_pcre}" == "yes"
  127. --with-pcre=%{l_prefix} \
  128. %endif
  129. %if "%{with_skey}" == "yes"
  130. --with-skey=%{l_prefix} \
  131. %endif
  132. %if "%{with_pam}" == "yes"
  133. --with-pam \
  134. %else
  135. --without-pam \
  136. %endif
  137. %if "%{with_x11}" == "yes"
  138. --with-xauth="`%{l_prefix}/etc/rc --query x11_bindir`/xauth" \
  139. %endif
  140. --with-md5-passwords \
  141. --with-zlib=%{l_prefix} \
  142. --with-ipv4-default \
  143. --without-smartcard \
  144. --without-kerberos4 \
  145. --disable-suid-ssh \
  146. --without-rsh \
  147. --with-mantype=man \
  148. --with-default-path=%{l_prefix}/bin:/bin:/usr/bin:/usr/local/bin \
  149. --with-privsep-user=%{l_nusr} \
  150. --with-privsep-path=%{l_prefix}/var/openssh/empty
  151. # build package
  152. %{l_make} %{l_mflags -O}
  153. %install
  154. rm -rf $RPM_BUILD_ROOT
  155. # perform standard installation procedure of OpenSSH
  156. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  157. # strip down installation tree
  158. rm -rf $RPM_BUILD_ROOT%{l_prefix}/share
  159. rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/slogin
  160. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/slogin.1
  161. strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
  162. strip $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/* 2>/dev/null || true
  163. # install ssh-askpass wrapper
  164. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh
  165. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  166. %{SOURCE ssh-askpass} $RPM_BUILD_ROOT%{l_prefix}/libexec/openssh/
  167. # make sure the state directory exists
  168. %{l_shtool} mkdir -f -p -m 755 \
  169. $RPM_BUILD_ROOT%{l_prefix}/var/openssh \
  170. $RPM_BUILD_ROOT%{l_prefix}/var/openssh/empty
  171. # install addons
  172. %{l_shtool} mkdir -f -p -m 755 \
  173. $RPM_BUILD_ROOT%{l_prefix}/bin \
  174. $RPM_BUILD_ROOT%{l_prefix}/man/man1
  175. %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
  176. %{SOURCE ssh-keyman} $RPM_BUILD_ROOT%{l_prefix}/bin/
  177. %{l_shtool} install -c -m 644 -e 's;@l_prefix@;%{l_prefix};g' \
  178. %{SOURCE ssh-keyman.1} $RPM_BUILD_ROOT%{l_prefix}/man/man1/
  179. # install run-command script
  180. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  181. %{l_shtool} install -c -m 755 \
  182. -e 's;@l_prefix@;%{l_prefix};g' \
  183. -e 's;@l_susr@;%{l_susr};g' \
  184. -e 's;@l_sgrp@;%{l_sgrp};g' \
  185. %{SOURCE rc.openssh} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  186. # install reasonable ssh server and client configuration files
  187. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/openssh
  188. %{l_shtool} install -c -m 644 \
  189. -e 's;@l_prefix@;%{l_prefix};g' \
  190. -e 's;@l_x11forwarding@;%{with_x11};' \
  191. %{SOURCE sshd_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  192. %{l_shtool} install -c -m 644 -e 's;@l_prefix@;%{l_prefix};g' \
  193. %{SOURCE ssh_config} $RPM_BUILD_ROOT%{l_prefix}/etc/openssh/
  194. # OSSP fake syslog library
  195. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  196. %{l_shtool} install -c -m 644 \
  197. -e 's;@l_prefix@;%{l_prefix};g' \
  198. %{SOURCE fsl.%{name}} \
  199. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  200. # determine installation files
  201. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  202. %{l_files_std} \
  203. '%not %dir %{l_prefix}/etc/fsl' \
  204. '%config %{l_prefix}/etc/fsl/fsl.%{name}' \
  205. '%config %{l_prefix}/etc/openssh/*' \
  206. '%attr(4711,%{l_susr},%{l_mgrp}) %{l_prefix}/libexec/openssh/ssh-keysign' \
  207. '%dir %attr(700,%{l_susr},%{l_sgrp}) %{l_prefix}/var/openssh/empty'
  208. %files -f files
  209. %clean
  210. rm -rf $RPM_BUILD_ROOT
  211. %post
  212. # generate server RSA1 (SSHv1) key
  213. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" -o \
  214. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key" ] ; then
  215. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa1 -b 2048 \
  216. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_key \
  217. -N '' -C `hostname` 1>&2
  218. fi
  219. # generate server RSA (SSHv2) key
  220. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" -o \
  221. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key" ] ; then
  222. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t rsa -b 2048 \
  223. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_rsa_key \
  224. -N '' -C `hostname` 1>&2
  225. fi
  226. # generate server DSA (SSHv2) key
  227. if [ ! -f "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" -o \
  228. ! -s "$RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key" ] ; then
  229. $RPM_INSTALL_PREFIX/bin/ssh-keygen -t dsa -b 2048 \
  230. -f $RPM_INSTALL_PREFIX/etc/openssh/ssh_host_dsa_key \
  231. -N '' -C `hostname` 1>&2
  232. fi
  233. # add PAM configuration entry
  234. %if "%{with_pam}" == "yes"
  235. $RPM_INSTALL_PREFIX/sbin/pamtool --add --smart --name=openssh
  236. %endif
  237. %preun
  238. # remove PAM configuration entry
  239. %if "%{with_pam}" == "yes"
  240. $RPM_INSTALL_PREFIX/sbin/pamtool --remove --smart --name=openssh
  241. %endif