Switch to the official hpn patches.
authorMike Frysinger <vapier@gentoo.org>
Sun, 20 Jun 2010 22:29:39 +0000 (22:29 +0000)
committerMike Frysinger <vapier@gentoo.org>
Sun, 20 Jun 2010 22:29:39 +0000 (22:29 +0000)
Package-Manager: portage-2.2_rc67/cvs/Linux x86_64

net-misc/openssh/ChangeLog
net-misc/openssh/Manifest
net-misc/openssh/openssh-5.4_p1-r3.ebuild [new file with mode: 0644]
net-misc/openssh/openssh-5.5_p1-r2.ebuild [new file with mode: 0644]

index 61cd33df8ad6cc88733bac8e2abaa8a4be989cb3..23d9faa22503c4ec0772edbd2ede60ff02211b36 100644 (file)
@@ -1,6 +1,13 @@
 # ChangeLog for net-misc/openssh
 # Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-misc/openssh/ChangeLog,v 1.381 2010/04/20 04:50:38 robbat2 Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/openssh/ChangeLog,v 1.382 2010/06/20 22:29:39 vapier Exp $
+
+*openssh-5.5_p1-r2 (20 Jun 2010)
+*openssh-5.4_p1-r3 (20 Jun 2010)
+
+  20 Jun 2010; Mike Frysinger <vapier@gentoo.org> +openssh-5.4_p1-r3.ebuild,
+  +openssh-5.5_p1-r2.ebuild:
+  Switch to the official hpn patches.
 
 *openssh-5.5_p1-r1 (20 Apr 2010)
 
index 5889e01d912a7fc080f060958a7a913cfe8dcd20..597e6e8aaf1939e2f03b375c5c23f4040d3689bc 100644 (file)
@@ -27,8 +27,10 @@ DIST openssh-5.3p1.tar.gz 1027130 RMD160 f8c98b4b91b7e0e02b33837ef6978e8b7570cf9
 DIST openssh-5.4p1+x509-6.2.3.diff.gz 156621 RMD160 20be6252837563c299dfc8d32ac8823f21efbba4 SHA1 fe77afbe1a2884ee9545b027c311b9e7d4b84115 SHA256 90a21d282b846c28d8c8123dbc6f9bf9e1ec21d818ffe4260027875667164b0b
 DIST openssh-5.4p1-hpn13v7-x509variant.diff.gz 22941 RMD160 383b3883984ee0e6068363fdd645d2dd24c7964c SHA1 d3f04c938ab6e5e10587d0ffb717af37360a8dd6 SHA256 c2b1a81c6952ae73cc4dfd1528d560588c45cf1242ea8b0e6eadb0cc83b50377
 DIST openssh-5.4p1-hpn13v7.diff.gz 22848 RMD160 c3e151d7804ec2fa60769e1c73d369bffab6d4b1 SHA1 bbf7778dd57a25c0d742ca66f29b46bbbf607435 SHA256 fdfd7205ec8aa2b3dd7a69c9c2050b91d0623ee1eff07f27a58bf9190e605cf6
+DIST openssh-5.4p1-hpn13v8.diff.gz 22937 RMD160 40ce779b379c299d8079edbd0538c0927f11f238 SHA1 816ee2a3d0943aa7ccdaad3e0c516c22de000827 SHA256 03a5322a47f7c2011ec2cc5aee64e69b3ead08bde3eb64a20afd2c5ca1fe2529
 DIST openssh-5.4p1.tar.gz 1094604 RMD160 2382307f19edc727a108da262e531ecf3671cf09 SHA1 2a3042372f08afb1415ceaec8178213276a36302 SHA256 ae96e70d04104824ab10f0d7aaef4584ac96b2a870adfcd8b457d836c8c5404e
 DIST openssh-5.5p1+x509-6.2.3.diff.gz 156737 RMD160 cf6d9e5f51512b3e22a3561ff7e1c6daad80d016 SHA1 5f163b03b3086605d9759b76565e6f3a5fa8cb85 SHA256 a2fdf904c21036fe6ee89da7572a37f4763ef414348f9a953c7c7e0fb3562a7f
+DIST openssh-5.5p1-hpn13v9.diff.gz 22657 RMD160 bb9d44589018030fa3102898f85f4dfd7032d2f0 SHA1 8601fabf0067ff9c59501dc0006ad3853dbb3de0 SHA256 0556ad75cbd29cba71263a5b7ddc44c03d17c09297a6c41a16d39d3549e5079c
 DIST openssh-5.5p1.tar.gz 1097574 RMD160 7cee614112b691da5daac9f2579becba2409b727 SHA1 361c6335e74809b26ea096b34062ba8ff6c97cd6 SHA256 36eedd6efe6663186ed23573488670f9b02e34744694e94a9f869b6f25e47e8a
 DIST openssh-lpk-5.2p1-0.3.11.patch.gz 18116 RMD160 2ff9bdff19e0854a96063be1e0589fa3f85da0d7 SHA1 33b36cf94f68a80fca497da110529ce69d62fbb0 SHA256 450b56a989767aa65a974213e8f7e9d0ee9d08522247db7b787730e53685bebd
 DIST openssh-lpk-5.3p1-0.3.11.patch.gz 18137 RMD160 3e316722d521e163a82d661465abef7f128d736b SHA1 870a703e2cafa744681733766e48faf3229e3b7e SHA256 34d8dbccde3b1fedb6b75d7a725ade8b37389c46f5b13a2e5a80d8cd8e6ffaaa
@@ -36,13 +38,15 @@ DIST openssh-lpk-5.4p1-0.3.13.patch.gz 18105 RMD160 734b2c3ea740b6de610e3bfa91c9
 EBUILD openssh-5.2_p1-r3.ebuild 8150 RMD160 b9049bb12151086a4261cfc70aad4ba0def0d4a7 SHA1 a9f0ec39435444e2ca4ca2e0ca99d3a10ded6bd8 SHA256 ba524fd8817de5ece224ba2fca841964020069bd580ae644c99ad9ff3587af1d
 EBUILD openssh-5.3_p1-r1.ebuild 8321 RMD160 c632f38bae4c60e4836c96ca7e35dd103b598159 SHA1 1a7f59e8144586def7d83b6c6721d6da5c9e8d40 SHA256 1fa0285b909c4bd834bf495d3140aa8c7e6586ca1f85ec0c46aa0e0b4ee8df5d
 EBUILD openssh-5.4_p1-r2.ebuild 8272 RMD160 0ceae73fbee90c61e62d0a38009c21d54333951a SHA1 3e314540758e06cd84ed897bc7fb12ca330a145c SHA256 020cf22f04921cb841449b4d86deb9ea6cc4135fbec5884fb24987d638cc7246
+EBUILD openssh-5.4_p1-r3.ebuild 8268 RMD160 0116016c792b5f56411dddf5a5f037dc4126361e SHA1 55e4e4e09ad214d3bb82304d1a1848ae45101099 SHA256 cbe163e47210ca42bf24545375aec9f9757af200eab68b9d539c7b2c39926f03
 EBUILD openssh-5.5_p1-r1.ebuild 8195 RMD160 14b3fb4ee1ca2a7fde0d30081ff816b5517c1c9e SHA1 ad49e8ff2cfafd9b2f43bd60e6e16788ce6d3050 SHA256 ac37347ba4a8cde38ce73832daae32bd96918d096e9f92ee5afaa37e89976a2f
-MISC ChangeLog 59873 RMD160 089e269cc59f79173d092ea6a1c119a4efbb04e7 SHA1 fe44bf8e80d39ab6f1b06cdd7bd0dc0dfcccc841 SHA256 84242f592f249f2b61f4c68102d91fc280c1dee30b8bccd7968602120e7c2d43
+EBUILD openssh-5.5_p1-r2.ebuild 8191 RMD160 d84a8d8be877e9d2ac4d9ca6c4a1bdf4667fb56f SHA1 4240b0eacc02902cd444658a18686e150593d863 SHA256 82ed01d20f7ddc9de169a7208aa4fb1ad2a3ba00d02551c8605c063ae3066d72
+MISC ChangeLog 60084 RMD160 16cf2280dc33679c4a99e7d087a1c15538fbfb75 SHA1 bcac5124aedb2298a4cb2072d40e8c5993a7854a SHA256 9ccdb88b073a078e63dfeed46c59fa7fa3a525c3143f42e8060b0b842551fc0a
 MISC metadata.xml 1641 RMD160 b5ae0d7b86c8dcb36414bc31da6fd22a807ced0b SHA1 31923a9db53fcad2b9cca72c39e733376bf6c501 SHA256 d34bb27c9f775ce973246c2a6b32ccd17d300de562920afbdd47312056cd8946
 -----BEGIN PGP SIGNATURE-----
-Version: GnuPG v2.0.14 (GNU/Linux)
+Version: GnuPG v2.0.15 (GNU/Linux)
 
-iF4EAREIAAYFAkvRFN0ACgkQTwhj9JtAlp6kWAEAxkVFaITpdKizt7bqQ8sdcjaH
-rU1k2uRIq8xDCgt3m1oBAMMFlF+XNio21M80/ZSVzuws1urTLa2jLTdBfXeC9yNe
-=5lsz
+iF4EAREIAAYFAkwellMACgkQTwhj9JtAlp49swD9HQJoMcP2ph+agLvAKCFe1WdJ
+bDCSAk/4FL44kQufbPMA/iz9zT5r5DDveN8UumNZN267Q1RBCpgPBaHGeex+BCN4
+=IiKw
 -----END PGP SIGNATURE-----
diff --git a/net-misc/openssh/openssh-5.4_p1-r3.ebuild b/net-misc/openssh/openssh-5.4_p1-r3.ebuild
new file mode 100644 (file)
index 0000000..eeb44a9
--- /dev/null
@@ -0,0 +1,270 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/openssh/openssh-5.4_p1-r3.ebuild,v 1.1 2010/06/20 22:29:39 vapier Exp $
+
+EAPI="2"
+inherit eutils flag-o-matic multilib autotools pam
+
+# Make it more portable between straight releases
+# and _p? releases.
+PARCH=${P/_/}
+
+HPN_PATCH="${PARCH}-hpn13v8.diff.gz"
+HPN_X509_PATCH="${PARCH}-hpn13v7-x509variant.diff.gz"
+LDAP_PATCH="${PARCH/openssh/openssh-lpk}-0.3.13.patch.gz"
+X509_VER="6.2.3" X509_PATCH="${PARCH}+x509-${X509_VER}.diff.gz"
+
+DESCRIPTION="Port of OpenBSD's free SSH release"
+HOMEPAGE="http://www.openssh.org/"
+SRC_URI="mirror://openbsd/OpenSSH/portable/${PARCH}.tar.gz
+       ${HPN_PATCH:+hpn? ( http://www.psc.edu/networking/projects/hpn-ssh/${HPN_PATCH} mirror://gentoo/${HPN_PATCH} )}
+       ${LDAP_PATCH:+ldap? ( mirror://gentoo/${LDAP_PATCH} )}
+       ${X509_PATCH:+X509? ( http://roumenpetrov.info/openssh/x509-${X509_VER}/${X509_PATCH} )}
+       ${HPN_X509_PATCH:+hpn? ( X509? ( mirror://gentoo/${HPN_X509_PATCH} ) )}
+       "
+
+LICENSE="as-is"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
+IUSE="hpn kerberos ldap libedit pam selinux skey static tcpd X X509"
+
+RDEPEND="pam? ( virtual/pam )
+       kerberos? ( virtual/krb5 )
+       selinux? ( >=sys-libs/libselinux-1.28 )
+       skey? ( >=sys-auth/skey-1.1.5-r1 )
+       ldap? ( net-nds/openldap )
+       libedit? ( dev-libs/libedit )
+       >=dev-libs/openssl-0.9.6d
+       >=sys-libs/zlib-1.2.3
+       tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
+       X? ( x11-apps/xauth )
+       userland_GNU? ( sys-apps/shadow )"
+DEPEND="${RDEPEND}
+       dev-util/pkgconfig
+       virtual/os-headers
+       sys-devel/autoconf"
+RDEPEND="${RDEPEND}
+       pam? ( >=sys-auth/pambase-20081028 )"
+PROVIDE="virtual/ssh"
+
+S=${WORKDIR}/${PARCH}
+
+pkg_setup() {
+       # this sucks, but i'd rather have people unable to `emerge -u openssh`
+       # than not be able to log in to their server any more
+       maybe_fail() { [[ -z ${!2} ]] && echo ${1} ; }
+       local fail="
+               $(use X509 && maybe_fail X509 X509_PATCH)
+               $(use ldap && maybe_fail ldap LDAP_PATCH)
+               $(use hpn && maybe_fail hpn HPN_PATCH)
+               $(use X509 && use hpn && maybe_fail x509+hpn HPN_X509_PATCH)
+       "
+       fail=$(echo ${fail})
+       if [[ -n ${fail} ]] ; then
+               eerror "Sorry, but this version does not yet support features"
+               eerror "that you requested:      ${fail}"
+               eerror "Please mask ${PF} for now and check back later:"
+               eerror " # echo '=${CATEGORY}/${PF}' >> /etc/portage/package.mask"
+               die "booooo"
+       fi
+}
+
+src_prepare() {
+       sed -i \
+               -e '/_PATH_XAUTH/s:/usr/X11R6/bin/xauth:/usr/bin/xauth:' \
+               pathnames.h || die
+       # keep this as we need it to avoid the conflict between LPK and HPN changing
+       # this file.
+       cp version.h version.h.pristine
+
+       if use X509 ; then
+               # Apply X509 patch
+               epatch "${DISTDIR}"/${X509_PATCH}
+               # Apply glue so that HPN will still work after X509
+               #epatch "${FILESDIR}"/${PN}-5.2_p1-x509-hpn-glue.patch
+       fi
+       if ! use X509 ; then
+               if [[ -n ${LDAP_PATCH} ]] && use ldap ; then
+                       epatch "${DISTDIR}"/${LDAP_PATCH}
+                       epatch "${FILESDIR}"/${PN}-5.2p1-ldap-stdargs.diff #266654
+                       # version.h patch conflict avoidence
+                       mv version.h version.h.lpk
+                       cp -f version.h.pristine version.h
+               fi
+       else
+               use ldap && ewarn "Sorry, X509 and LDAP conflict internally, disabling LDAP"
+       fi
+       epatch "${FILESDIR}"/${P}-openssl.patch
+       epatch "${FILESDIR}"/${P}-pkcs11.patch #310929
+       epatch "${FILESDIR}"/${P}-relative-AuthorizedKeysFile.patch #308939
+       epatch "${FILESDIR}"/${PN}-4.7_p1-GSSAPI-dns.patch #165444 integrated into gsskex
+       if [[ -n ${HPN_PATCH} ]] && use hpn; then
+               if use X509 ; then
+                       epatch "${DISTDIR}"/${HPN_X509_PATCH}
+               else
+                       epatch "${DISTDIR}"/${HPN_PATCH}
+               fi
+               # version.h patch conflict avoidence
+               mv version.h version.h.hpn
+               cp -f version.h.pristine version.h
+               # The AES-CTR multithreaded variant is temporarily broken, and
+               # causes random hangs when combined with the -f switch of ssh.
+               # To avoid this, we change the internal table to use the non-multithread
+               # version for the meantime.
+               sed -i \
+                       -e '/aes...-ctr.*SSH_CIPHER_SSH2/s,evp_aes_ctr_mt,evp_aes_128_ctr,' \
+                       cipher.c || die
+       fi
+       epatch "${FILESDIR}"/${PN}-5.2_p1-autoconf.patch
+
+       sed -i "s:-lcrypto:$(pkg-config --libs openssl):" configure{,.ac} || die
+
+       # Disable PATH reset, trust what portage gives us. bug 254615
+       sed -i -e 's:^PATH=/:#PATH=/:' configure || die
+
+       # Now we can build a sane merged version.h
+       t="${T}"/version.h
+       m="${t}.merge" f="${t}.final"
+       cat version.h.{hpn,pristine,lpk} 2>/dev/null \
+               | sed '/^#define SSH_RELEASE/d' \
+               | sort | uniq >"${m}"
+       sed -n -r \
+               -e '/^\//p' \
+               <"${m}" >"${f}"
+       sed -n -r \
+               -e '/SSH_LPK/s,"lpk","-lpk",g' \
+               -e '/^#define/p' \
+               <"${m}" >>"${f}"
+       v="SSH_VERSION SSH_PORTABLE"
+       [[ -f version.h.hpn ]] && v="${v} SSH_HPN"
+       [[ -f version.h.lpk ]] && v="${v} SSH_LPK"
+       echo "#define SSH_RELEASE ${v}" >>"${f}"
+       cp "${f}" version.h
+
+       eautoreconf
+}
+
+static_use_with() {
+       local flag=$1
+       if use static && use ${flag} ; then
+               ewarn "Disabling '${flag}' support because of USE='static'"
+               # rebuild args so that we invert the first one (USE flag)
+               # but otherwise leave everything else working so we can
+               # just leverage use_with
+               shift
+               [[ -z $1 ]] && flag="${flag} ${flag}"
+               set -- !${flag} "$@"
+       fi
+       use_with "$@"
+}
+
+src_configure() {
+       addwrite /dev/ptmx
+       addpredict /etc/skey/skeykeys #skey configure code triggers this
+
+       use static && append-ldflags -static
+
+       econf \
+               --with-ldflags="${LDFLAGS}" \
+               --disable-strip \
+               --sysconfdir=/etc/ssh \
+               --libexecdir=/usr/$(get_libdir)/misc \
+               --datadir=/usr/share/openssh \
+               --with-privsep-path=/var/empty \
+               --with-privsep-user=sshd \
+               --with-md5-passwords \
+               --with-ssl-engine \
+               $(static_use_with pam) \
+               $(static_use_with kerberos kerberos5 /usr) \
+               ${LDAP_PATCH:+$(use X509 || ( use ldap && use_with ldap ))} \
+               $(use_with libedit) \
+               $(use_with selinux) \
+               $(use_with skey) \
+               $(use_with tcpd tcp-wrappers) \
+               || die
+}
+
+src_compile() {
+       emake || die
+}
+
+src_install() {
+       emake install-nokeys DESTDIR="${D}" || die
+       fperms 600 /etc/ssh/sshd_config
+       dobin contrib/ssh-copy-id
+       newinitd "${FILESDIR}"/sshd.rc6 sshd
+       newconfd "${FILESDIR}"/sshd.confd sshd
+       keepdir /var/empty
+
+       newpamd "${FILESDIR}"/sshd.pam_include.2 sshd
+       if use pam ; then
+               sed -i \
+                       -e "/^#UsePAM /s:.*:UsePAM yes:" \
+                       -e "/^#PasswordAuthentication /s:.*:PasswordAuthentication no:" \
+                       -e "/^#PrintMotd /s:.*:PrintMotd no:" \
+                       -e "/^#PrintLastLog /s:.*:PrintLastLog no:" \
+                       "${D}"/etc/ssh/sshd_config || die "sed of configuration file failed"
+       fi
+
+       # This instruction is from the HPN webpage,
+       # Used for the server logging functionality
+       if [[ -n ${HPN_PATCH} ]] && use hpn; then
+               keepdir /var/empty/dev
+       fi
+
+       doman contrib/ssh-copy-id.1
+       dodoc ChangeLog CREDITS OVERVIEW README* TODO sshd_config
+
+       diropts -m 0700
+       dodir /etc/skel/.ssh
+}
+
+src_test() {
+       local t tests skipped failed passed shell
+       tests="interop-tests compat-tests"
+       skipped=""
+       shell=$(getent passwd ${UID} | cut -d: -f7)
+       if [[ ${shell} == */nologin ]] || [[ ${shell} == */false ]] ; then
+               elog "Running the full OpenSSH testsuite"
+               elog "requires a usable shell for the 'portage'"
+               elog "user, so we will run a subset only."
+               skipped="${skipped} tests"
+       else
+               tests="${tests} tests"
+       fi
+       for t in ${tests} ; do
+               # Some tests read from stdin ...
+               emake -k -j1 ${t} </dev/null \
+                       && passed="${passed}${t} " \
+                       || failed="${failed}${t} "
+       done
+       einfo "Passed tests: ${passed}"
+       ewarn "Skipped tests: ${skipped}"
+       if [[ -n ${failed} ]] ; then
+               ewarn "Failed tests: ${failed}"
+               die "Some tests failed: ${failed}"
+       else
+               einfo "Failed tests: ${failed}"
+               return 0
+       fi
+}
+
+pkg_postinst() {
+       enewgroup sshd 22
+       enewuser sshd 22 -1 /var/empty sshd
+
+       ewarn "Remember to merge your config files in /etc/ssh/ and then"
+       ewarn "reload sshd: '/etc/init.d/sshd reload'."
+       if use pam ; then
+               echo
+               ewarn "Please be aware users need a valid shell in /etc/passwd"
+               ewarn "in order to be allowed to login."
+       fi
+       # This instruction is from the HPN webpage,
+       # Used for the server logging functionality
+       if [[ -n ${HPN_PATCH} ]] && use hpn; then
+               echo
+               einfo "For the HPN server logging patch, you must ensure that"
+               einfo "your syslog application also listens at /var/empty/dev/log."
+       fi
+}
diff --git a/net-misc/openssh/openssh-5.5_p1-r2.ebuild b/net-misc/openssh/openssh-5.5_p1-r2.ebuild
new file mode 100644 (file)
index 0000000..6cb9a27
--- /dev/null
@@ -0,0 +1,269 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/openssh/openssh-5.5_p1-r2.ebuild,v 1.1 2010/06/20 22:29:39 vapier Exp $
+
+EAPI="2"
+inherit eutils flag-o-matic multilib autotools pam
+
+# Make it more portable between straight releases
+# and _p? releases.
+PARCH=${P/_/}
+PARCH_54=${PARCH/5.5/5.4}
+
+HPN_PATCH="${PARCH}-hpn13v9.diff.gz"
+HPN_X509_PATCH="${PARCH_54}-hpn13v7-x509variant.diff.gz"
+LDAP_PATCH="${PARCH_54/openssh/openssh-lpk}-0.3.13.patch.gz"
+X509_VER="6.2.3" X509_PATCH="${PARCH}+x509-${X509_VER}.diff.gz"
+
+DESCRIPTION="Port of OpenBSD's free SSH release"
+HOMEPAGE="http://www.openssh.org/"
+SRC_URI="mirror://openbsd/OpenSSH/portable/${PARCH}.tar.gz
+       ${HPN_PATCH:+hpn? ( http://www.psc.edu/networking/projects/hpn-ssh/${HPN_PATCH} mirror://gentoo/${HPN_PATCH} )}
+       ${LDAP_PATCH:+ldap? ( mirror://gentoo/${LDAP_PATCH} )}
+       ${X509_PATCH:+X509? ( http://roumenpetrov.info/openssh/x509-${X509_VER}/${X509_PATCH} )}
+       ${HPN_X509_PATCH:+hpn? ( X509? ( mirror://gentoo/${HPN_X509_PATCH} ) )}
+       "
+
+LICENSE="as-is"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
+IUSE="hpn kerberos ldap libedit pam selinux skey static tcpd X X509"
+
+RDEPEND="pam? ( virtual/pam )
+       kerberos? ( virtual/krb5 )
+       selinux? ( >=sys-libs/libselinux-1.28 )
+       skey? ( >=sys-auth/skey-1.1.5-r1 )
+       ldap? ( net-nds/openldap )
+       libedit? ( dev-libs/libedit )
+       >=dev-libs/openssl-0.9.6d
+       >=sys-libs/zlib-1.2.3
+       tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
+       X? ( x11-apps/xauth )
+       userland_GNU? ( sys-apps/shadow )"
+DEPEND="${RDEPEND}
+       dev-util/pkgconfig
+       virtual/os-headers
+       sys-devel/autoconf"
+RDEPEND="${RDEPEND}
+       pam? ( >=sys-auth/pambase-20081028 )"
+PROVIDE="virtual/ssh"
+
+S=${WORKDIR}/${PARCH}
+
+pkg_setup() {
+       # this sucks, but i'd rather have people unable to `emerge -u openssh`
+       # than not be able to log in to their server any more
+       maybe_fail() { [[ -z ${!2} ]] && echo ${1} ; }
+       local fail="
+               $(use X509 && maybe_fail X509 X509_PATCH)
+               $(use ldap && maybe_fail ldap LDAP_PATCH)
+               $(use hpn && maybe_fail hpn HPN_PATCH)
+               $(use X509 && use hpn && maybe_fail x509+hpn HPN_X509_PATCH)
+       "
+       fail=$(echo ${fail})
+       if [[ -n ${fail} ]] ; then
+               eerror "Sorry, but this version does not yet support features"
+               eerror "that you requested:      ${fail}"
+               eerror "Please mask ${PF} for now and check back later:"
+               eerror " # echo '=${CATEGORY}/${PF}' >> /etc/portage/package.mask"
+               die "booooo"
+       fi
+}
+
+src_prepare() {
+       sed -i \
+               -e '/_PATH_XAUTH/s:/usr/X11R6/bin/xauth:/usr/bin/xauth:' \
+               pathnames.h || die
+       # keep this as we need it to avoid the conflict between LPK and HPN changing
+       # this file.
+       cp version.h version.h.pristine
+
+       if use X509 ; then
+               # Apply X509 patch
+               epatch "${DISTDIR}"/${X509_PATCH}
+               # Apply glue so that HPN will still work after X509
+               #epatch "${FILESDIR}"/${PN}-5.2_p1-x509-hpn-glue.patch
+       fi
+       if ! use X509 ; then
+               if [[ -n ${LDAP_PATCH} ]] && use ldap ; then
+                       epatch "${DISTDIR}"/${LDAP_PATCH}
+                       epatch "${FILESDIR}"/${PN}-5.2p1-ldap-stdargs.diff #266654
+                       # version.h patch conflict avoidence
+                       mv version.h version.h.lpk
+                       cp -f version.h.pristine version.h
+               fi
+       else
+               use ldap && ewarn "Sorry, X509 and LDAP conflict internally, disabling LDAP"
+       fi
+       epatch "${FILESDIR}"/${PN}-5.4_p1-openssl.patch
+       epatch "${FILESDIR}"/${PN}-4.7_p1-GSSAPI-dns.patch #165444 integrated into gsskex
+       if [[ -n ${HPN_PATCH} ]] && use hpn; then
+               if use X509 ; then
+                       epatch "${DISTDIR}"/${HPN_X509_PATCH}
+               else
+                       epatch "${DISTDIR}"/${HPN_PATCH}
+               fi
+               # version.h patch conflict avoidence
+               mv version.h version.h.hpn
+               cp -f version.h.pristine version.h
+               # The AES-CTR multithreaded variant is temporarily broken, and
+               # causes random hangs when combined with the -f switch of ssh.
+               # To avoid this, we change the internal table to use the non-multithread
+               # version for the meantime.
+               sed -i \
+                       -e '/aes...-ctr.*SSH_CIPHER_SSH2/s,evp_aes_ctr_mt,evp_aes_128_ctr,' \
+                       cipher.c || die
+       fi
+       epatch "${FILESDIR}"/${PN}-5.2_p1-autoconf.patch
+
+       sed -i "s:-lcrypto:$(pkg-config --libs openssl):" configure{,.ac} || die
+
+       # Disable PATH reset, trust what portage gives us. bug 254615
+       sed -i -e 's:^PATH=/:#PATH=/:' configure || die
+
+       # Now we can build a sane merged version.h
+       t="${T}"/version.h
+       m="${t}.merge" f="${t}.final"
+       cat version.h.{hpn,pristine,lpk} 2>/dev/null \
+               | sed '/^#define SSH_RELEASE/d' \
+               | sort | uniq >"${m}"
+       sed -n -r \
+               -e '/^\//p' \
+               <"${m}" >"${f}"
+       sed -n -r \
+               -e '/SSH_LPK/s,"lpk","-lpk",g' \
+               -e '/^#define/p' \
+               <"${m}" >>"${f}"
+       v="SSH_VERSION SSH_PORTABLE"
+       [[ -f version.h.hpn ]] && v="${v} SSH_HPN"
+       [[ -f version.h.lpk ]] && v="${v} SSH_LPK"
+       echo "#define SSH_RELEASE ${v}" >>"${f}"
+       cp "${f}" version.h
+
+       eautoreconf
+}
+
+static_use_with() {
+       local flag=$1
+       if use static && use ${flag} ; then
+               ewarn "Disabling '${flag}' support because of USE='static'"
+               # rebuild args so that we invert the first one (USE flag)
+               # but otherwise leave everything else working so we can
+               # just leverage use_with
+               shift
+               [[ -z $1 ]] && flag="${flag} ${flag}"
+               set -- !${flag} "$@"
+       fi
+       use_with "$@"
+}
+
+src_configure() {
+       addwrite /dev/ptmx
+       addpredict /etc/skey/skeykeys #skey configure code triggers this
+
+       use static && append-ldflags -static
+
+       econf \
+               --with-ldflags="${LDFLAGS}" \
+               --disable-strip \
+               --sysconfdir=/etc/ssh \
+               --libexecdir=/usr/$(get_libdir)/misc \
+               --datadir=/usr/share/openssh \
+               --with-privsep-path=/var/empty \
+               --with-privsep-user=sshd \
+               --with-md5-passwords \
+               --with-ssl-engine \
+               $(static_use_with pam) \
+               $(static_use_with kerberos kerberos5 /usr) \
+               ${LDAP_PATCH:+$(use X509 || ( use ldap && use_with ldap ))} \
+               $(use_with libedit) \
+               $(use_with selinux) \
+               $(use_with skey) \
+               $(use_with tcpd tcp-wrappers) \
+               || die
+}
+
+src_compile() {
+       emake || die
+}
+
+src_install() {
+       emake install-nokeys DESTDIR="${D}" || die
+       fperms 600 /etc/ssh/sshd_config
+       dobin contrib/ssh-copy-id
+       newinitd "${FILESDIR}"/sshd.rc6 sshd
+       newconfd "${FILESDIR}"/sshd.confd sshd
+       keepdir /var/empty
+
+       newpamd "${FILESDIR}"/sshd.pam_include.2 sshd
+       if use pam ; then
+               sed -i \
+                       -e "/^#UsePAM /s:.*:UsePAM yes:" \
+                       -e "/^#PasswordAuthentication /s:.*:PasswordAuthentication no:" \
+                       -e "/^#PrintMotd /s:.*:PrintMotd no:" \
+                       -e "/^#PrintLastLog /s:.*:PrintLastLog no:" \
+                       "${D}"/etc/ssh/sshd_config || die "sed of configuration file failed"
+       fi
+
+       # This instruction is from the HPN webpage,
+       # Used for the server logging functionality
+       if [[ -n ${HPN_PATCH} ]] && use hpn; then
+               keepdir /var/empty/dev
+       fi
+
+       doman contrib/ssh-copy-id.1
+       dodoc ChangeLog CREDITS OVERVIEW README* TODO sshd_config
+
+       diropts -m 0700
+       dodir /etc/skel/.ssh
+}
+
+src_test() {
+       local t tests skipped failed passed shell
+       tests="interop-tests compat-tests"
+       skipped=""
+       shell=$(getent passwd ${UID} | cut -d: -f7)
+       if [[ ${shell} == */nologin ]] || [[ ${shell} == */false ]] ; then
+               elog "Running the full OpenSSH testsuite"
+               elog "requires a usable shell for the 'portage'"
+               elog "user, so we will run a subset only."
+               skipped="${skipped} tests"
+       else
+               tests="${tests} tests"
+       fi
+       for t in ${tests} ; do
+               # Some tests read from stdin ...
+               emake -k -j1 ${t} </dev/null \
+                       && passed="${passed}${t} " \
+                       || failed="${failed}${t} "
+       done
+       einfo "Passed tests: ${passed}"
+       ewarn "Skipped tests: ${skipped}"
+       if [[ -n ${failed} ]] ; then
+               ewarn "Failed tests: ${failed}"
+               die "Some tests failed: ${failed}"
+       else
+               einfo "Failed tests: ${failed}"
+               return 0
+       fi
+}
+
+pkg_postinst() {
+       enewgroup sshd 22
+       enewuser sshd 22 -1 /var/empty sshd
+
+       ewarn "Remember to merge your config files in /etc/ssh/ and then"
+       ewarn "reload sshd: '/etc/init.d/sshd reload'."
+       if use pam ; then
+               echo
+               ewarn "Please be aware users need a valid shell in /etc/passwd"
+               ewarn "in order to be allowed to login."
+       fi
+       # This instruction is from the HPN webpage,
+       # Used for the server logging functionality
+       if [[ -n ${HPN_PATCH} ]] && use hpn; then
+               echo
+               einfo "For the HPN server logging patch, you must ensure that"
+               einfo "your syslog application also listens at /var/empty/dev/log."
+       fi
+}