Ticket #53108: Portfile

File Portfile, 9.9 KB (added by Schamschula (Marius Schamschula), 7 years ago)

Portfile for 7.6p1 only default variant fixed

Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2
3PortSystem          1.0
4
5name                openssh
6version             7.6p1
7categories          net
8platforms           darwin
9maintainers         nomaintainer
10license             BSD
11installs_libs       no
12
13description         OpenSSH secure login server
14
15long_description    OpenSSH is a FREE version of the SSH protocol suite of \
16                    network connectivity tools that increasing numbers of people on the \
17                    Internet are coming to rely on. Many users of telnet, rlogin, ftp, \
18                    and other such programs might not realize that their password is \
19                    transmitted across the Internet unencrypted, but it is. OpenSSH \
20                    encrypts all traffic (including passwords) to effectively eliminate \
21                    eavesdropping, connection hijacking, and other network-level \
22                    attacks. Additionally, OpenSSH provides a myriad of secure \
23                    tunneling capabilities, as well as a variety of authentication \
24                    methods.
25
26homepage            http://www.openbsd.org/openssh/
27
28checksums           ${distfiles} \
29                    rmd160  486ae743f51ffbf8197d564aab9ae54f9e2ac9da \
30                    sha256  a323caeeddfe145baaa0db16e98d784b1fbc7dd436a6bf1f479dfd5cd1d21723
31
32master_sites        openbsd:OpenSSH/portable \
33                    ftp://ftp.cise.ufl.edu/pub/mirrors/openssh/portable/ \
34                    ftp://reflection.ncsa.uiuc.edu/pub/OpenBSD/OpenSSH/portable/ \
35                    ftp://ftp.cse.buffalo.edu/pub/OpenBSD/OpenSSH/portable/ \
36                    ftp://openbsd.mirrors.pair.com/ftp/OpenSSH/portable \
37                    ftp://openbsd.secsup.org/pub/openbsd/OpenSSH/portable/
38
39depends_lib         path:lib/libssl.dylib:openssl \
40                    port:libedit \
41                    port:ncurses \
42                    port:zlib
43depends_run         port:ssh-copy-id
44
45# the HPN patch needs this, so rewrite all other patches to support it, too
46patch.args          -p1
47patchfiles          launchd.patch \
48                    pam.patch \
49                    patch-sandbox-darwin.c-apple-sandbox-named-external.diff \
50                    patch-sshd.c-apple-sandbox-named-external.diff
51
52# We need a couple of patches
53# - pam.patch
54#   getpwnam(3) on OS X always returns "*********" in the pw_passwd field even
55#   when run as root, so it can't be used for authentication. This patch just
56#   forces the use of PAM regardless of the configuration.
57# - patch-*-apple-sandbox-named-external.diff
58#   Use Apple's sandbox_init(3) in addition to standard privilege separation.
59#   This requires a sandbox profile (which we provide) and the sandbox_init(3)
60#   call before the chroot(2) to privsep-path ($prefix/var/empty), or it will
61#   fail to load the sandbox description and libsandbox.1.dylib.
62
63post-patch {
64    # reinplace prefix in path to sandbox definition added by
65    # patch-sandbox-darwin.c-apple-sandbox-named-external.diff
66    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/sandbox-darwin.c
67}
68
69# strnvis(3) isn't actually "broken".  OpenBSD decided to be special and flip
70# the order of arguments to strnvis and considers everyone else to be broken.
71configure.cppflags-append -DBROKEN_STRNVIS=1
72
73# Use Apple's sandboxing feature
74configure.cppflags-append -D__APPLE_SANDBOX_NAMED_EXTERNAL__ \
75                          -D__APPLE_API_STRICT_CONFORMANCE
76configure.ldflags-append  -Wl,-search_paths_first
77configure.args      --with-ssl-dir=${prefix} \
78                    --sysconfdir=${prefix}/etc/ssh \
79                    --with-privsep-path=/var/empty \
80                    --with-md5-passwords \
81                    --with-pid-dir=${prefix}/var/run \
82                    --with-pam \
83                    --mandir=${prefix}/share/man \
84                    --with-zlib=${prefix} \
85                    --without-kerberos5 \
86                    --with-libedit \
87                    --with-pie \
88                    --without-xauth
89
90use_parallel_build  yes
91
92destroot.target     install-nokeys
93
94test.run            yes
95test.target         tests
96
97post-destroot {
98    destroot.keepdirs ${destroot}${prefix}/var/run
99
100    # switch default port to avoid conflict with system sshd
101    reinplace "s|#Port 22|Port 2222|g" ${destroot}${prefix}/etc/ssh/sshd_config
102
103    # install sandbox definition
104    xinstall -m 755 -d ${destroot}${prefix}/share/${name}
105    xinstall -m 644 ${filespath}/org.openssh.sshd.sb ${destroot}${prefix}/share/${name}
106
107    file rename "${destroot}${prefix}/etc/ssh/sshd_config" "${destroot}${prefix}/etc/ssh/sshd_config.example"
108    file rename "${destroot}${prefix}/etc/ssh/ssh_config" "${destroot}${prefix}/etc/ssh/ssh_config.example"
109}
110
111post-activate {
112    if {![file exists "${prefix}/etc/ssh/sshd_config"]} {
113        copy "${prefix}/etc/ssh/sshd_config.example" "${prefix}/etc/ssh/sshd_config"
114    }
115    if {![file exists "${prefix}/etc/ssh/ssh_config"]} {
116        copy "${prefix}/etc/ssh/ssh_config.example" "${prefix}/etc/ssh/ssh_config"
117    }
118}
119
120variant xauth description {Build with support for xauth} {
121    configure.args-delete   --without-xauth
122    configure.args-append   --with-xauth=${prefix}/bin/xauth
123    depends_run-append      port:xauth
124}
125
126variant hpn conflicts gsskex description {Apply high performance patch} {
127    # Old location(s):
128    #   http://www.psc.edu/index.php/hpn-ssh
129    # Current location(s):
130    #   http://hpnssh.sourceforge.net/
131    #   http://www.freshports.org/security/openssh-portable/
132    #     (is usually quick in updating the HPN patch for new versions,
133    #      take a look there, too.)
134
135    # Formerly from FreeBSD, now copied over from FreeBSD's ports directory.
136    #patch_sites-append     http://mirror.shatow.net/freebsd/${name}/ \
137    #                       freebsd
138    #set hpn_patchfile      ${name}-6.7p1-hpnssh14v5.diff.gz
139    #checksums-append       ${hpn_patchfile} \
140    #                       rmd160  0cf7ffdd9b60d518d76076faf31df6a7a6d4ae52 \
141    #                       sha256  846ad51577de8308d60dbfaa58ba18d112d0732fdf21063ebc78407fc8e4a7b6
142
143    set hpn_patchfile       ${name}-${version}-hpnssh14v11.diff
144    patchfiles-append       ${hpn_patchfile}
145
146    use_autoreconf          yes
147
148    configure.args-append   --with-hpn
149}
150
151variant gsskex conflicts hpn requires kerberos5 description "Add OpenSSH GSSAPI key exchange patch" {
152    use_autoreconf          yes
153    patchfiles-append       0002-Apple-keychain-integration-other-changes.patch \
154                            openssh-7.3p1-gsskex-all-20141021-mp-20160929.patch
155    configure.cppflags-append \
156                            -F/System/Library/Frameworks/DirectoryService.framework \
157                            -F/System/Library/Frameworks/CoreFoundation.framework \
158                            -D_UTMPX_COMPAT \
159                            -D__APPLE_LAUNCHD__ \
160                            -D__APPLE_MEMBERSHIP__ \
161                            -D__APPLE_XSAN__
162    configure.ldflags-append \
163                            -Wl,-pie \
164                            -framework CoreFoundation \
165                            -framework DirectoryService
166    configure.cflags-append -fPIE
167    configure.args-append   --with-4in6 \
168                            --with-audit=bsm \
169                            --with-keychain=apple \
170                            --disable-utmp \
171                            --disable-wtmp \
172                            --with-privsep-user=_sshd
173}
174
175variant kerberos5 description "Add Kerberos5 support" {
176    depends_lib-append      port:kerberos5
177    configure.args-delete   --without-kerberos5
178    configure.args-append   --with-kerberos5=${prefix}
179
180    if {${os.platform} eq "darwin"} {
181        post-extract {
182            xinstall -m 0755 -W "${filespath}" slogin "${worksrcpath}/"
183        }
184
185        pre-configure {
186            reinplace -W "${worksrcpath}" "s|@@PREFIX@@|${prefix}|" slogin
187        }
188
189        post-destroot {
190            xinstall -m 0755 ${worksrcpath}/slogin \
191                             ${destroot}${prefix}/bin/
192        }
193    }
194}
195
196variant ldns description "Use ldns for DNSSEC support" {
197    configure.args-append   --with-ldns
198    depends_lib-append      port:ldns
199}
200
201default_variants            +kerberos5 +xauth
202
203platform darwin {
204    # create link to /usr/include/pam because 'security' was renamed to 'pam'
205    # in OS X.
206    pre-configure {
207        xinstall -d ${workpath}/include
208        file delete ${workpath}/include/security
209        ln -s /usr/include/pam ${workpath}/include/security
210    }
211}
212
213platform darwin 9 {
214    # 10.5/ppc doesn't like the sandbox file we supply
215    configure.cppflags-delete -D__APPLE_SANDBOX_NAMED_EXTERNAL__
216}
217
218startupitem.create  yes
219startupitem.name    OpenSSH
220startupitem.start   \
221    "if \[ -x ${prefix}/sbin/sshd ]; then
222        if \[ ! -f ${prefix}/etc/ssh/ssh_host_dsa_key \]; then
223            ${prefix}/bin/ssh-keygen -t dsa -f \\
224            ${prefix}/etc/ssh/ssh_host_dsa_key -N \"\" -C `hostname`
225        fi
226        if \[ ! -f ${prefix}/etc/ssh/ssh_host_rsa_key \]; then
227            ${prefix}/bin/ssh-keygen -t rsa -f \\
228            ${prefix}/etc/ssh/ssh_host_rsa_key -N \"\" -C `hostname`
229        fi
230        if \[ ! -f ${prefix}/etc/ssh/ssh_host_ecdsa_key \]; then
231            ${prefix}/bin/ssh-keygen -t ecdsa -f \\
232            ${prefix}/etc/ssh/ssh_host_ecdsa_key -N \"\" -C `hostname`
233        fi
234        if \[ ! -f ${prefix}/etc/ssh/ssh_host_ed25519_key \]; then
235            ${prefix}/bin/ssh-keygen -t ed25519 -f \\
236            ${prefix}/etc/ssh/ssh_host_ed25519_key -N \"\" -C `hostname`
237        fi
238        ${prefix}/sbin/sshd
239    fi"
240startupitem.stop    \
241    "if \[ -r ${prefix}/var/run/sshd.pid \]; then
242        kill `cat ${prefix}/var/run/sshd.pid`
243    fi"
244
245livecheck.type      regex
246livecheck.url       http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/
247livecheck.regex     openssh-(\[5-9\].\[0-9\]p\[0-9\])[quotemeta ${extract.suffix}]