unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: 30216@debbugs.gnu.org
Subject: [bug#30216] [WIP v5] services: agetty: Make tty optional.
Date: Tue, 30 Jan 2018 21:56:37 +0100	[thread overview]
Message-ID: <87r2q7vzei.fsf@gnu.org> (raw)
In-Reply-To: <20180124133147.15060-1-dannym@scratchpost.org> (Danny Milosavljevic's message of "Wed, 24 Jan 2018 14:31:47 +0100")

Hi,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> * gnu/system/install.scm (agetty-default-service): Delete variable.
> (beaglebone-black-installation-os): Do not specify tty.
> (a20-olinuxino-lime-installation-os): Do not specify tty.
> (a20-olinuxino-lime2-emmc-installation-os): Do not specify tty.
> (a20-olinuxino-micro-installation-os): Do not specify tty.
> (banana-pi-m2-ultra-installation-os): Do not specify tty.
> (nintendo-nes-classic-edition-installation-os): Do not specify tty.
> (embedded-installation-os): Move agetty-service instantiation to...
> * gnu/services/base.scm (%base-services): ...here.
> (default-tty): New variable.
> (agetty-shepherd-service): Make tty optional, default to the above.

Neat, it looks better than hardcoding a default tty for each of these
machines.  :-)

> +(define (default-tty)

Could you add a docstring, like, IIUC: “Return a gexp that determines a
reasonable default serial port to use as the tty.  This is primarily
useful for headless systems such as ARM SoCs.”

In the manual, for the agetty service, it would be good to document the
‘agetty.tty’ kernel command-line option.

Perhaps ‘default-serial-port’ is more appropriate in fact?

> +  #~(begin
> +      ;; console=device,options
> +      ;; device: can be tty0, ttyS0, lp0, ttyUSB0 (serial).
> +      ;; options: BBBBPNF. P n|o|e, N number of bits,
> +      ;; F flow control (r RTS)
> +      (use-modules (rnrs io ports))
> +      (let* ((command (call-with-input-file "/proc/cmdline" get-string-all))
> +             (not-comma (char-set-complement (char-set #\,)))
> +             (items (string-tokenize command))
> +             (items-by-key (lambda (key target-prefix)
> +                            (let ((keylen (string-length key)))
> +                              (map (lambda (a)
> +                                     (string-append target-prefix
> +                                                    (string-drop a keylen)))
> +                                   (filter (lambda (b)
> +                                             (string-prefix? key b)) items)))))
> +             (agetty-ttys (items-by-key "agetty.tty=" ""))

Rather use ‘linux-command-line’ from (gnu build linux-boot).
‘find-long-option’ in the same module does almost what you want, but if
you really want to support repeated “agetty.tty” options, you’ll have to
make a new ‘find-long-options’ (plural) variant.

> +             (console-ttys (filter (lambda (tty)
> +                                     (not (or
> +                                            (string-prefix? tty "tty0")
> +                                            (string-prefix? tty "tty1")
> +                                            (string-prefix? tty "tty2")
> +                                            (string-prefix? tty "tty3")
> +                                            (string-prefix? tty "tty4")
> +                                            (string-prefix? tty "tty5")
> +                                            (string-prefix? tty "tty6")
> +                                            (string-prefix? tty "tty7")
> +                                            (string-prefix? tty "tty8")
> +                                            (string-prefix? tty "tty9"))))
> +                                   (items-by-key "console=tty" "tty")))

I think this would work:

  (let* ((consoles     (find-long-option "console" (linux-command-line)))
         (console-ttys (remove (lambda (console)
                                 (string-prefix? "tty" console))
                               (string-tokenize consoles not-comma))))
    …)

> +             (ttys (or agetty-ttys (map (lambda (console-spec)
> +                                          ;; Extract device name.
> +                                          (car (string-tokenize console-spec
> +                                                                not-comma)))
> +                                        console-ttys))))
> +        (if (null? ttys)
> +          "XXX" ; would crash entire boot process: (error "agetty: No default tty found.")
> +          (car ttys)))))

Maybe default to /dev/ttyS0?

Could you send an updated patch?

Thanks,
Ludo’.

  reply	other threads:[~2018-01-30 20:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 22:00 [bug#30216] [FIXME] system: Add ARM installer Danny Milosavljevic
2018-01-22 23:26 ` [bug#30216] [WIP] services: agetty: Make tty optional Danny Milosavljevic
2018-01-23 14:34   ` [bug#30216] [WIP v2] " Danny Milosavljevic
2018-01-23 14:40     ` [bug#30216] [WIP v3] " Danny Milosavljevic
2018-01-24 13:12       ` [bug#30216] [WIP v4] " Danny Milosavljevic
2018-01-24 13:31         ` [bug#30216] [WIP v5] " Danny Milosavljevic
2018-01-30 20:56           ` Ludovic Courtès [this message]
2018-01-30 23:24             ` Danny Milosavljevic
2018-01-30 23:30             ` Danny Milosavljevic
2018-01-31  9:09               ` Ludovic Courtès
2018-01-23 11:39 ` [bug#30216] [FIXME] system: Add ARM installer Ludovic Courtès
2018-01-23 13:54   ` [bug#30216] [WIP] system: Add ARM installer; services: agetty: Make tty optional Danny Milosavljevic
2018-01-25 14:56     ` Ludovic Courtès
2018-01-25 22:33       ` Danny Milosavljevic
2018-01-26 10:36         ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r2q7vzei.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=30216@debbugs.gnu.org \
    --cc=dannym@scratchpost.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).