Subject: [bug#47435] gnu: mail: Make the sendmail package actually output its binary

From: Rovanion Luckey <[email-masked]>
Date: Sun, 28 Mar 2021 13:57:08 +0200

> We can see helpfile and statistics file go into etc/mail, then sendmailgoes
into sbin, smrsh is missing in sbin.

Fixed.

In addition to Léo Le Bouter's comments, I suggest either omitting or
> amending this part. A Maildir is where the user's emails will be kept,
> but it cannot be stored in the build output, because that directory will
> be immutable after the build is complete.

> What is the default?

`/etc/mail` is the default it seems. I modified the patch to use
`$out/var/spool/mail` instead. `/var/spool/mail` is where I would like to
put it on a conventional linux distribution. But I don't know if MAILDIR
means "where the user's mail will be kept" in this context because when I
do that I end up with the following file tree:

$ tree /gnu/store/05wxmp6m3pfg5d2jrwbx4rx5p3nxyyvc-sendmail-8.15.2
> /gnu/store/05wxmp6m3pfg5d2jrwbx4rx5p3nxyyvc-sendmail-8.15.2
> ├── bin
> │   ├── hoststat ->
> /gnu/store/05wxmp6m3pfg5d2jrwbx4rx5p3nxyyvc-sendmail-8.15.2/sbin/sendmail
> │   ├── mailq ->
> /gnu/store/05wxmp6m3pfg5d2jrwbx4rx5p3nxyyvc-sendmail-8.15.2/sbin/sendmail
> │   ├── newaliases ->
> /gnu/store/05wxmp6m3pfg5d2jrwbx4rx5p3nxyyvc-sendmail-8.15.2/sbin/sendmail
> │   ├── purgestat ->
> /gnu/store/05wxmp6m3pfg5d2jrwbx4rx5p3nxyyvc-sendmail-8.15.2/sbin/sendmail
> │   └── vacation
> ├── etc
> │   └── mail
> │       ├── helpfile
> │       └── statistics
> ├── libexec
> │   └── smrsh
> ├── sbin
> │   ├── editmap
> │   ├── mailstats
> │   ├── makemap
> │   ├── praliases
> │   └── sendmail
> ├── share
> │   └── doc
> │       └── sendmail-8.15.2
> │           └── LICENSE
> └── var
>     └── spool
>         └── mail
>             ├── sendmail.cf
>             └── submit.cf
>

with config files for sendmail in `$out/var/spool/mail`.
From 66b04a58ee3e3b5d301a16377afffc600e74c7db Mon Sep 17 00:00:00 2001
From: Rovanion Luckey <[email-masked]>
Date: Sat, 27 Mar 2021 18:28:02 +0100
Subject: [PATCH] gnu: sendmail: Fix output's directory structure.

* gnu/packages/mail.scm (sendmail)[arguments]<#:phases>: Properly specify output directories in replacement 'configure and 'pre-> install.
---
 gnu/packages/mail.scm | 35 ++++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index b02f547e03..ed0e96a6e3 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -2761,23 +2761,41 @@ powerful user customization features.")
                (("SHELL=/bin/sh") (string-append "SHELL=" (which "sh"))))
              #t))
          (replace 'configure
-           (lambda _
+           (lambda* (#:key outputs #:allow-other-keys)
 
              ;; Render harmless any attempts to chown or chgrp
              (substitute* "devtools/bin/install.sh"
                (("owner=\\$2") "owner=''")
                (("group=\\$2") "group=''"))
 
-             (with-output-to-file "devtools/Site/site.config.m4"
-               (lambda ()
-                 (format #t "
+             (let ((out (assoc-ref outputs "out")))
+               (with-output-to-file "devtools/Site/site.config.m4"
+                 (lambda ()
+                   ;; See 'devtools/M4/UNIX/defines.m4' for the list of
+                   ;; installation directories.
+                   (format #t "
 define(`confCC', `gcc')
 define(`confOPTIMIZE', `-g -O2')
 define(`confLIBS', `-lresolv')
 define(`confINSTALL', `~a/devtools/bin/install.sh')
 define(`confDEPEND_TYPE', `CC-M')
 define(`confINST_DEP', `')
-" (getcwd))))
+
+define(`confHFDIR',   `~a/etc/mail')
+define(`confSTDIR',   `~a/etc/mail')
+define(`confMBINDIR', `~a/sbin')
+define(`confUBINDIR', `~a/bin')
+define(`confSBINDIR', `~a/sbin')
+define(`confEBINDIR', `~a/sbin')
+define(`confMANROOT', `~a/share/man')~%"
+                           (getcwd)
+                           out out out out out out out))))
+
+             (substitute* "cf/cf/Makefile"
+               (("^MAILDIR=.*")
+                (string-append "MAILDIR = "
+                               (assoc-ref outputs "out")
+                               "/var/spool/mail\n")))
              #t))
          (replace 'build
            (lambda _
@@ -2789,10 +2807,9 @@ define(`confINST_DEP', `')
          (add-before 'install 'pre-install
            (lambda _
              (let ((out (assoc-ref %outputs "out")))
-               (mkdir-p (string-append out "/usr/bin"))
-               (mkdir-p (string-append out "/usr/sbin"))
-               (mkdir-p (string-append out "/etc/mail"))
-               (setenv "DESTDIR" out)
+               (mkdir-p (string-append out "/bin"))
+               (mkdir-p (string-append out "/sbin"))
+               (mkdir-p (string-append out "/var/spool/mail"))
                (with-directory-excursion "cf/cf"
                  (invoke "sh" "Build" "install-cf"))
                #t))))
-- 
2.30.0