guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#30216] [WIP] services: agetty: Make tty optional.


From: Danny Milosavljevic
Subject: [bug#30216] [WIP] services: agetty: Make tty optional.
Date: Tue, 23 Jan 2018 00:26:43 +0100

* gnu/services/base.scm (default-tty): New variable.
(agetty-shepherd-service): Make tty optional, default to the above.
* gnu/system/install.scm (arm-installation-os): New variable.  Use the above.
---
 gnu/services/base.scm  | 27 ++++++++++++++++++++++++---
 gnu/system/install.scm |  8 +++++++-
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 8e30bcd34..d29da29ff 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -817,7 +817,7 @@ the message of the day, among other things."
   agetty-configuration?
   (agetty           agetty-configuration-agetty   ;<package>
                     (default util-linux))
-  (tty              agetty-configuration-tty)     ;string
+  (tty              agetty-configuration-tty)     ;string | #f
   (term             agetty-term                   ;string | #f
                     (default #f))
   (baud-rate        agetty-baud-rate              ;string | #f
@@ -890,6 +890,27 @@ the message of the day, among other things."
 ;;;                 (default #f))
   )
 
+(define (default-tty)
+  #~(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 (ice-9 textual-ports))
+      (let* ((command (call-with-input-file "/proc/cmdline" get-string-all))
+             (not-comma (char-set-complement (char-set #\,)))
+             (items (string-tokenize command))
+             (item-by-key (lambda (key)
+                            (let ((keylen (string-length key)))
+                              (map (lambda (a) (string-drop a keylen))
+                                   (filter (lambda (b) (string-prefix? key b)) 
items)))))
+             (agetty-ttys (item-by-key "agetty.tty="))
+             (console-ttys (item-by-key "console="))
+             (ttys (or agetty-ttys (map car (string-tokenize console-ttys 
not-comma)))))
+        (if (null? ttys)
+          "XXX"
+          (car ttys)))))
+
 (define agetty-shepherd-service
   (match-lambda
     (($ <agetty-configuration> agetty tty term baud-rate auto-login
@@ -901,7 +922,7 @@ the message of the day, among other things."
      (list
        (shepherd-service
          (documentation "Run agetty on a tty.")
-         (provision (list (symbol-append 'term- (string->symbol tty))))
+         (provision (list (symbol-append 'term- (string->symbol (or tty 
"auto")))))
 
          ;; Since the login prompt shows the host name, wait for the 
'host-name'
          ;; service to be done.  Also wait for udev essentially so that the tty
@@ -1009,7 +1030,7 @@ the message of the day, among other things."
                           #$@(if login-pause?
                                  #~("--login-pause")
                                  #~())
-                          #$tty
+                          #$(or tty (default-tty))
                           #$@(if baud-rate
                                  #~(#$baud-rate)
                                  #~())
diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index 286415052..19a129ce3 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -47,6 +47,7 @@
             a20-olinuxino-lime-installation-os
             a20-olinuxino-lime2-emmc-installation-os
             a20-olinuxino-micro-installation-os
+            arm-installation-os
             banana-pi-m2-ultra-installation-os
             beaglebone-black-installation-os
             nintendo-nes-classic-edition-installation-os))
@@ -381,7 +382,7 @@ You have been warned.  Thanks for being so brave.\x1b[0m
                      nvi                          ;:wq!
                      %base-packages))))
 
-(define* (agetty-default-service #:optional (tty "ttyS0"))
+(define* (agetty-default-service #:optional (tty #f))
   "Return an agetty-service on the given TTY"
   (agetty-service (agetty-configuration
                    (extra-options '("-L"))
@@ -408,6 +409,11 @@ The bootloader BOOTLOADER is installed to 
BOOTLOADER-TARGET."
     (services (cons* (agetty-default-service tty)
                      (operating-system-user-services installation-os)))))
 
+(define arm-installation-os
+  (embedded-installation-os u-boot-bootloader
+                            "/dev/null"
+                            #f))
+
 (define beaglebone-black-installation-os
   (embedded-installation-os u-boot-beaglebone-black-bootloader
                             "/dev/sda"





reply via email to

[Prev in Thread] Current Thread [Next in Thread]