gnu: openssh: Use G-expressions.

* gnu/packages/ssh.scm (openssh)[arguments]:
Rewrite as G-expressions.
This commit is contained in:
Tobias Geerinckx-Rice 2023-07-16 02:00:03 +02:00
parent 12971d26ef
commit b56fe521de
No known key found for this signature in database
GPG key ID: 0DB0FF884F556D79

View file

@ -209,6 +209,69 @@ (define-public openssh
(base32
"1s3nqv57r3l7avsdkzwd575dvxra8h19xpqczl0z3cvcgwabw3i0"))))
(build-system gnu-build-system)
(arguments
(list
#:test-target "tests"
;; Otherwise, the test scripts try to use a nonexistent directory and fail.
#:make-flags
#~(list "REGRESSTMP=\"$${BUILDDIR}/regress\"")
#:configure-flags
#~(append
(list "--sysconfdir=/etc/ssh"
;; Default value of 'PATH' used by sshd.
"--with-default-path=/run/current-system/profile/bin"
;; configure needs to find krb5-config.
(string-append "--with-kerberos5="
#$(this-package-input "mit-krb5")
"/bin")
;; libedit is needed for sftp completion.
"--with-libedit")
;; Enable PAM support in sshd.
(if #$(target-hurd?)
'()
(list "--with-pam"
;; Support creation and use of ecdsa-sk, ed25519-sk keys.
"--with-security-key-builtin"))
;; "make install" runs "install -s" by default, which doesn't work for
;; cross-compiled binaries because it invokes 'strip' instead of
;; 'TRIPLET-strip'. Work around this.
(if #$(%current-target-system)
(list "--disable-strip")
'()))
#:phases
#~(modify-phases %standard-phases
(add-after 'configure 'reset-/var/empty
(lambda _
(substitute* "Makefile"
(("PRIVSEP_PATH=/var/empty")
(string-append "PRIVSEP_PATH=" #$output "/var/empty")))))
(add-after 'configure 'set-store-location
(lambda _
(substitute* "misc.c"
(("@STORE_DIRECTORY@")
(string-append "\"" (%store-directory) "\"")))))
(add-before 'check 'patch-tests
(lambda _
(substitute* "regress/test-exec.sh"
(("/bin/sh") (which "sh")))
;; Remove 't-exec' regress target which requires user 'sshd'.
(substitute* (list "Makefile"
"regress/Makefile")
(("^(tests:.*) t-exec(.*)" all pre post)
(string-append pre post)))))
(replace 'install
(lambda* (#:key (make-flags '()) #:allow-other-keys)
;; Install without host keys and system configuration files. This
;; will install /var/empty to the store, which is needed by the
;; system openssh-service-type.
(apply invoke "make" "install-nosysconf" make-flags)
(with-directory-excursion "contrib"
(chmod "ssh-copy-id" #o555)
(install-file "ssh-copy-id"
(string-append #$output "/bin/"))
(install-file "ssh-copy-id.1"
(string-append #$output "/share/man/man1/"))))))))
(native-inputs (list groff pkg-config))
(inputs
(cons* libedit
@ -220,79 +283,6 @@ (define-public openssh
'()
(list linux-pam
libfido2)))) ; fails to build on GNU/Hurd
(arguments
`(#:test-target "tests"
;; Otherwise, the test scripts try to use a nonexistent directory and
;; fail.
#:make-flags '("REGRESSTMP=\"$${BUILDDIR}/regress\"")
#:configure-flags `("--sysconfdir=/etc/ssh"
;; Default value of 'PATH' used by sshd.
"--with-default-path=/run/current-system/profile/bin"
;; configure needs to find krb5-config.
,(string-append "--with-kerberos5="
(assoc-ref %build-inputs "mit-krb5")
"/bin")
;; libedit is needed for sftp completion.
"--with-libedit"
;; Enable PAM support in sshd.
,,@(if (target-hurd?)
'()
'("--with-pam"
;; Support creation and use of ecdsa-sk,
;; ed25519-sk keys.
"--with-security-key-builtin"))
;; "make install" runs "install -s" by default,
;; which doesn't work for cross-compiled binaries
;; because it invokes 'strip' instead of
;; 'TRIPLET-strip'. Work around this.
,,@(if (%current-target-system)
'("--disable-strip")
'()))
#:phases
(modify-phases %standard-phases
(add-after 'configure 'reset-/var/empty
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(substitute* "Makefile"
(("PRIVSEP_PATH=/var/empty")
(string-append "PRIVSEP_PATH=" out "/var/empty"))))))
(add-after 'configure 'set-store-location
(lambda* _
(substitute* "misc.c"
(("@STORE_DIRECTORY@")
(string-append "\"" (%store-directory) "\"")))))
(add-before 'check 'patch-tests
(lambda _
(substitute* "regress/test-exec.sh"
(("/bin/sh") (which "sh")))
;; Remove 't-exec' regress target which requires user 'sshd'.
(substitute* (list "Makefile"
"regress/Makefile")
(("^(tests:.*) t-exec(.*)" all pre post)
(string-append pre post)))))
(replace 'install
(lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
;; Install without host keys and system configuration files.
;; This will install /var/empty to the store, which is needed
;; by the system openssh-service-type.
(apply invoke "make" "install-nosysconf" make-flags)
(with-directory-excursion "contrib"
(chmod "ssh-copy-id" #o555)
(install-file "ssh-copy-id"
(string-append out "/bin/"))
(install-file "ssh-copy-id.1"
(string-append out "/share/man/man1/")))))))))
(synopsis "Client and server for the secure shell (ssh) protocol")
(description
"The SSH2 protocol implemented in OpenSSH is standardised by the