Ticket #67539: Portfile.openssh9.3.p1_rev2

File Portfile.openssh9.3.p1_rev2, 11.0 KB (added by artkiver (グレェ), 11 months ago)

Portfile rev2 with compiler.blacklist suggestions from ryandesign comment 43.

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
5PortGroup           compiler_blacklist_versions 1.0
6
7name                openssh
8version             9.3p1
9revision            2
10categories          net
11maintainers         {@artkiver gmail.com:artkiver} openmaintainer
12license             BSD
13installs_libs       no
14conflicts           lsh pkixssh
15
16description         OpenSSH secure login server
17
18long_description    OpenSSH is a FREE version of the SSH protocol suite of \
19                    network connectivity tools that increasing numbers of people on the \
20                    Internet are coming to rely on. Many users of telnet, rlogin, ftp, \
21                    and other such programs might not realize that their password is \
22                    transmitted across the Internet unencrypted, but it is. OpenSSH \
23                    encrypts all traffic (including passwords) to effectively eliminate \
24                    eavesdropping, connection hijacking, and other network-level \
25                    attacks. Additionally, OpenSSH provides a myriad of secure \
26                    tunneling capabilities, as well as a variety of authentication \
27                    methods.
28
29homepage            https://www.openbsd.org/openssh/
30
31checksums           rmd160  29768ab6830484f797d0138d2c7f53791a319d4c \
32                    sha256  e9baba7701a76a51f3d85a62c383a3c9dcd97fa900b859bc7db114c1868af8a8 \
33                    size    1856839
34
35master_sites        openbsd:OpenSSH/portable \
36                    ftp://ftp.cise.ufl.edu/pub/mirrors/openssh/portable/ \
37                    http://openbsd.mirrors.pair.com/OpenSSH/portable
38
39if {${name} eq ${subport}} {
40    depends_lib         path:lib/libssl.dylib:openssl \
41                        port:libedit \
42                        port:ncurses \
43                        port:zlib
44    depends_run         port:ssh-copy-id
45
46    platform darwin 10 {
47        # /usr/bin/ranlib: object: libopenbsd-compat.a(base64.o) malformed object (unknown load command 2)
48        depends_build-append port:cctools
49    }
50
51    patch.args          -p1
52    patchfiles          launchd.patch \
53                        agent.patch \
54                        pam.patch \
55                        patch-sandbox-darwin.c-apple-sandbox-named-external.diff \
56                        patch-sshd.c-apple-sandbox-named-external.diff \
57                        macports-config.patch
58
59    # We need a couple of patches
60    # - pam.patch
61    #   getpwnam(3) on OS X always returns "*********" in the pw_passwd field even
62    #   when run as root, so it can't be used for authentication. This patch just
63    #   forces the use of PAM regardless of the configuration.
64    # - patch-*-apple-sandbox-named-external.diff
65    #   Use Apple's sandbox_init(3) in addition to standard privilege separation.
66    #   This requires a sandbox profile (which we provide) and the sandbox_init(3)
67    #   call before the chroot(2) to privsep-path (${prefix}/var/empty), or it will
68    #   fail to load the sandbox description and libsandbox.1.dylib.
69    # - macports-config.patch
70    #   Changes the default configuration from the upstream-provided one by popular
71    #   request.
72    # - agent.patch
73    #   Adds -l flag to ssh-agent to work with launchd.
74
75    post-patch {
76        # reinplace prefix in path to sandbox definition added by
77        # patch-sandbox-darwin.c-apple-sandbox-named-external.diff
78        reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/sandbox-darwin.c
79    }
80
81    use_autoreconf          yes
82
83    # strnvis(3) isn't actually "broken".  OpenBSD decided to be special and flip
84    # the order of arguments to strnvis and considers everyone else to be broken.
85    configure.cppflags-append -DBROKEN_STRNVIS=1
86
87    # Use Apple's sandboxing feature
88    configure.cppflags-append   -D__APPLE_SANDBOX_NAMED_EXTERNAL__ \
89                                -D__APPLE_API_STRICT_CONFORMANCE
90
91    # Support Apple's launchd in ssh-agent
92    configure.cppflags-append -D__APPLE_LAUNCHD__
93
94    configure.ldflags-append  -Wl,-search_paths_first
95    configure.args      --with-ssl-dir=${prefix} \
96                        --sysconfdir=${prefix}/etc/ssh \
97                        --with-privsep-path=/var/empty \
98                        --with-md5-passwords \
99                        --with-pid-dir=${prefix}/var/run \
100                        --with-pam \
101                        --mandir=${prefix}/share/man \
102                        --with-zlib=${prefix} \
103                        --without-kerberos5 \
104                        --with-libedit \
105                        --with-pie \
106                        --without-xauth \
107                        --without-ldns \
108                        --with-audit=bsm \
109                        --with-keychain=apple
110
111    use_parallel_build  yes
112
113    platform macosx {
114        if {${os.major} < 10 || (${os.major} == 10 && ${configure.build_arch} eq "ppc")} {
115            # See: https://trac.macports.org/ticket/60385
116            # clang does not work for ppc on 10.6.8 Rosetta
117            # See also: https://trac.macports.org/ticket/65613
118            configure.args-delete   --with-keychain=apple
119        } elseif {${os.major} <= 11} {
120            # clang is required to build the new Apple Keychain integration due
121            # to it using the Object Subscripting feature, c.f. #59397.
122            # We'll keep it simple and just blacklist any gcc version, cc
123            # (which could be anything), system clang versions prior to those
124            # shipped with Xcode 4.4.
125            # Regarding the macports-clang versions, any version in the
126            # MacPorts tree should suit our needs, since the clang
127            # documentation lists FOSS clang/llvm 3.1 as the first version to
128            # support Object Subscripting and the oldest version in our tree is
129            # now 3.3.
130            compiler.blacklist-append   *gcc* cc {clang < 421} {clang >= 1403 < 1500}
131        }
132    }
133
134    destroot.target     install-nokeys
135
136    test.run            yes
137    test.target         tests
138
139    post-destroot {
140        destroot.keepdirs ${destroot}${prefix}/var/run
141
142        # switch default port to avoid conflict with system sshd
143        reinplace "s|#Port 22|Port 2222|g" ${destroot}${prefix}/etc/ssh/sshd_config
144
145        # install sandbox definition
146        xinstall -m 755 -d ${destroot}${prefix}/share/${name}
147        xinstall -m 644 ${filespath}/com.openssh.sshd.sb ${destroot}${prefix}/share/${name}
148
149        file rename "${destroot}${prefix}/etc/ssh/sshd_config" "${destroot}${prefix}/etc/ssh/sshd_config.example"
150        file rename "${destroot}${prefix}/etc/ssh/ssh_config" "${destroot}${prefix}/etc/ssh/ssh_config.example"
151    }
152
153    post-activate {
154        if {![file exists "${prefix}/etc/ssh/sshd_config"]} {
155            copy "${prefix}/etc/ssh/sshd_config.example" "${prefix}/etc/ssh/sshd_config"
156        }
157        if {![file exists "${prefix}/etc/ssh/ssh_config"]} {
158            copy "${prefix}/etc/ssh/ssh_config.example" "${prefix}/etc/ssh/ssh_config"
159        }
160    }
161
162    variant xauth description {Build with support for xauth} {
163        configure.args-replace  --without-xauth \
164                                --with-xauth=${prefix}/bin/xauth
165        depends_run-append      port:xauth
166    }
167
168    variant kerberos5 description "Add Kerberos5 support" {
169        depends_lib-append      port:kerberos5
170        configure.args-delete   --without-kerberos5
171        configure.args-append   --with-kerberos5=${prefix}
172
173        if {${os.platform} eq "darwin"} {
174            post-extract {
175                xinstall -m 0755 -W "${filespath}" slogin "${worksrcpath}/"
176            }
177
178            pre-configure {
179                reinplace -W "${worksrcpath}" "s|@@PREFIX@@|${prefix}|" slogin
180            }
181
182            post-destroot {
183                xinstall -m 0755 ${worksrcpath}/slogin \
184                                 ${destroot}${prefix}/bin/
185            }
186        }
187    }
188
189    variant ldns description "Use ldns for DNSSEC support" {
190        configure.args-replace  --without-ldns \
191                                --with-ldns
192        depends_lib-append      port:ldns
193    }
194
195    variant fido2 description "Enable fido2 support" {
196        configure.args-delete  --without-security-key-builtin
197        configure.args-append  --with-security-key-builtin
198        depends_lib-append      port:libfido2
199    }
200
201
202    platform darwin {
203        # create link to /usr/include/pam because 'security' was renamed to 'pam'
204        # in OS X.
205        # And then again back to security in 10.6.
206        if {${os.major} < 10} {
207            pre-configure {
208                xinstall -d ${workpath}/include
209                file delete ${workpath}/include/security
210                ln -s /usr/include/pam ${workpath}/include/security
211                configure.cppflags-append "-I${workpath}/include"
212            }
213        }
214    }
215
216    platform darwin 9 {
217        # 10.5/ppc doesn't like the sandbox file we supply
218        configure.cppflags-delete -D__APPLE_SANDBOX_NAMED_EXTERNAL__
219    }
220
221    startupitem.create  yes
222    startupitem.name    OpenSSH
223    startupitem.start   \
224        "if \[ -x ${prefix}/sbin/sshd \]; then
225            if \[ ! -f ${prefix}/etc/ssh/ssh_host_dsa_key \]; then
226                ${prefix}/bin/ssh-keygen -t dsa -f \\
227                ${prefix}/etc/ssh/ssh_host_dsa_key -N \"\" -C `hostname`
228            fi
229            if \[ ! -f ${prefix}/etc/ssh/ssh_host_rsa_key \]; then
230                ${prefix}/bin/ssh-keygen -t rsa -f \\
231                ${prefix}/etc/ssh/ssh_host_rsa_key -N \"\" -C `hostname`
232            fi
233            if \[ ! -f ${prefix}/etc/ssh/ssh_host_ecdsa_key \]; then
234                ${prefix}/bin/ssh-keygen -t ecdsa -f \\
235                ${prefix}/etc/ssh/ssh_host_ecdsa_key -N \"\" -C `hostname`
236            fi
237            if \[ ! -f ${prefix}/etc/ssh/ssh_host_ed25519_key \]; then
238                ${prefix}/bin/ssh-keygen -t ed25519 -f \\
239                ${prefix}/etc/ssh/ssh_host_ed25519_key -N \"\" -C `hostname`
240            fi
241            ${prefix}/sbin/sshd
242        fi"
243    startupitem.stop    \
244        "if \[ -r ${prefix}/var/run/sshd.pid \]; then
245            kill `cat ${prefix}/var/run/sshd.pid`
246        fi"
247}
248
249subport ssh-copy-id {
250    revision            0
251    platforms           any
252    supported_archs     noarch
253    maintainers         {l2dy @l2dy} openmaintainer
254    description         Shell script to install your public key(s) on a remote machine
255    long_description    {*}${description}
256
257    # Make sure to not create multiple copies of the same distfile.
258    distname            openssh-${version}
259    dist_subdir         openssh
260
261    use_configure       no
262    build               {}
263
264    destroot {
265        xinstall -m 755 ${worksrcpath}/contrib/ssh-copy-id ${destroot}${prefix}/bin
266        xinstall -m 644 ${worksrcpath}/contrib/ssh-copy-id.1 ${destroot}${prefix}/share/man/man1
267    }
268}
269
270livecheck.type      regex
271livecheck.url       https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/
272livecheck.regex     openssh-(\[5-9\]+.\[0-9\]+p\[0-9\]+)[quotemeta ${extract.suffix}]