openssh.spec 9.4 KB

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