all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#30216] [FIXME] system: Add ARM installer.
@ 2018-01-22 22:00 Danny Milosavljevic
  2018-01-22 23:26 ` [bug#30216] [WIP] services: agetty: Make tty optional Danny Milosavljevic
  2018-01-23 11:39 ` [bug#30216] [FIXME] system: Add ARM installer Ludovic Courtès
  0 siblings, 2 replies; 15+ messages in thread
From: Danny Milosavljevic @ 2018-01-22 22:00 UTC (permalink / raw)
  To: 30216

* gnu/system/install.scm (arm-installation-os): New exported variable.
---
 gnu/system/install.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index 286415052..a708e57f3 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))
@@ -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"
+                            "ttyS0"))
+
 (define beaglebone-black-installation-os
   (embedded-installation-os u-boot-beaglebone-black-bootloader
                             "/dev/sda"

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP] services: agetty: Make tty optional.
  2018-01-22 22:00 [bug#30216] [FIXME] system: Add ARM installer Danny Milosavljevic
@ 2018-01-22 23:26 ` Danny Milosavljevic
  2018-01-23 14:34   ` [bug#30216] [WIP v2] " Danny Milosavljevic
  2018-01-23 11:39 ` [bug#30216] [FIXME] system: Add ARM installer Ludovic Courtès
  1 sibling, 1 reply; 15+ messages in thread
From: Danny Milosavljevic @ 2018-01-22 23:26 UTC (permalink / raw)
  To: 30216

* 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"

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [bug#30216] [FIXME] system: Add ARM installer.
  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 11:39 ` Ludovic Courtès
  2018-01-23 13:54   ` [bug#30216] [WIP] system: Add ARM installer; services: agetty: Make tty optional Danny Milosavljevic
  1 sibling, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2018-01-23 11:39 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 30216

Hi Danny!

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> * gnu/system/install.scm (arm-installation-os): New exported variable.

What would it mean to have an “ARM” installer?  I’d expect these things
to be board-specific, no?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP] system: Add ARM installer; services: agetty: Make tty optional
  2018-01-23 11:39 ` [bug#30216] [FIXME] system: Add ARM installer Ludovic Courtès
@ 2018-01-23 13:54   ` Danny Milosavljevic
  2018-01-25 14:56     ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Danny Milosavljevic @ 2018-01-23 13:54 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 30216

Hi Ludo,

On Tue, 23 Jan 2018 12:39:10 +0100
ludo@gnu.org (Ludovic Courtès) wrote:

> What would it mean to have an “ARM” installer?  I’d expect these things
> to be board-specific, no?

I hope it's not that board-specific.  There are minimal differences but
many ARM boards use the same Linux kernel (with the same config).

This was one of the motivation to create u-boot:  u-boot is like a
board-specific mini-Linux kernel.  The Linux kernel that u-boot then
loads later is not board-specific.

In the past, board vendors kept putting huge board configuration tables inside
Linux until Linus put a stop to it.

Nowadays it should not be the case anymore that Linux is board-specific.

Therefore, I think it would be preferrable in the long run if
Hydra didn't build 1000 different 1 GB images for different boards
where the only different part is u-boot.

This is preparatory work which is very much work-in-progress, mostly
as a discussion basis.

There's a thread about it on guix-devel, "Porting GuixSD to ARM article.".

So long story short, about 99% of the image this arm-installer generates
will work and be identical for almost every ARMv7 board, except for u-boot
(u-boot is kinda important, though).

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP v2] services: agetty: Make tty optional.
  2018-01-22 23:26 ` [bug#30216] [WIP] services: agetty: Make tty optional Danny Milosavljevic
@ 2018-01-23 14:34   ` Danny Milosavljevic
  2018-01-23 14:40     ` [bug#30216] [WIP v3] " Danny Milosavljevic
  0 siblings, 1 reply; 15+ messages in thread
From: Danny Milosavljevic @ 2018-01-23 14:34 UTC (permalink / raw)
  To: 30216

* 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  | 45 ++++++++++++++++++++++++++++++++++++++++++---
 gnu/system/install.scm |  8 +++++++-
 2 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 8e30bcd34..3874c22b8 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,42 @@ 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))
+             (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=" ""))
+             (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")))
+             (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 +937,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
@@ -946,6 +982,9 @@ the message of the day, among other things."
                                         ('always "--local-line=always")
                                         ('never "-local-line=never")))
                                  #~())
+                          #$@(if tty
+                                 #~()
+                                 #~("--keep-baud"))
                           #$@(if extract-baud?
                                  #~("--extract-baud")
                                  #~())
@@ -1009,7 +1048,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 e4b2e8237..cde30ec3b 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"

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP v3] services: agetty: Make tty optional.
  2018-01-23 14:34   ` [bug#30216] [WIP v2] " Danny Milosavljevic
@ 2018-01-23 14:40     ` Danny Milosavljevic
  2018-01-24 13:12       ` [bug#30216] [WIP v4] " Danny Milosavljevic
  0 siblings, 1 reply; 15+ messages in thread
From: Danny Milosavljevic @ 2018-01-23 14:40 UTC (permalink / raw)
  To: 30216

* 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  | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
 gnu/system/install.scm |  8 +++++++-
 2 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 8e30bcd34..45b057eb8 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,46 @@ 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))
+             (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=" ""))
+             (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")))
+             (ttys (or agetty-ttys (map (lambda (console-spec)
+                                          ;; Extract device name.
+                                          (car (string-tokenize console-spec
+                                                                not-comma)))
+                                        console-ttys))))
+        (if (null? ttys)
+          "XXX"
+          (car ttys)))))
+
 (define agetty-shepherd-service
   (match-lambda
     (($ <agetty-configuration> agetty tty term baud-rate auto-login
@@ -901,7 +941,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
@@ -946,6 +986,9 @@ the message of the day, among other things."
                                         ('always "--local-line=always")
                                         ('never "-local-line=never")))
                                  #~())
+                          #$@(if tty
+                                 #~()
+                                 #~("--keep-baud"))
                           #$@(if extract-baud?
                                  #~("--extract-baud")
                                  #~())
@@ -1009,7 +1052,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 e4b2e8237..cde30ec3b 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"

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP v4] services: agetty: Make tty optional.
  2018-01-23 14:40     ` [bug#30216] [WIP v3] " Danny Milosavljevic
@ 2018-01-24 13:12       ` Danny Milosavljevic
  2018-01-24 13:31         ` [bug#30216] [WIP v5] " Danny Milosavljevic
  0 siblings, 1 reply; 15+ messages in thread
From: Danny Milosavljevic @ 2018-01-24 13:12 UTC (permalink / raw)
  To: 30216

* gnu/system/install.scm (agetty-default-service): Delete variable.
(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.
---
 gnu/services/base.scm  | 55 +++++++++++++++++++++++++++++++++++++++++++++++---
 gnu/system/install.scm | 12 +----------
 2 files changed, 53 insertions(+), 14 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 8e30bcd34..90b45920d 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,47 @@ 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 (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=" ""))
+             (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")))
+             (ttys (or agetty-ttys (map (lambda (console-spec)
+                                          ;; Extract device name.
+                                          (car (string-tokenize console-spec
+                                                                not-comma)))
+                                        console-ttys))))
+        (if (null? ttys)
+          "XXX" ; crashes entire boot: (error "agetty: 'tty' not specified and no default tty found.
+;Try specifying 'agetty.tty' or 'console' on the kernel command line.")
+          (car ttys)))))
+
 (define agetty-shepherd-service
   (match-lambda
     (($ <agetty-configuration> agetty tty term baud-rate auto-login
@@ -901,7 +942,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
@@ -946,6 +987,9 @@ the message of the day, among other things."
                                         ('always "--local-line=always")
                                         ('never "-local-line=never")))
                                  #~())
+                          #$@(if tty
+                                 #~()
+                                 #~("--keep-baud"))
                           #$@(if extract-baud?
                                  #~("--extract-baud")
                                  #~())
@@ -1009,7 +1053,7 @@ the message of the day, among other things."
                           #$@(if login-pause?
                                  #~("--login-pause")
                                  #~())
-                          #$tty
+                          #$(or tty (default-tty))
                           #$@(if baud-rate
                                  #~(#$baud-rate)
                                  #~())
@@ -2012,6 +2056,11 @@ This service is not part of @var{%base-services}."
                         (cons tty %default-console-font))
                       '("tty1" "tty2" "tty3" "tty4" "tty5" "tty6")))
 
+        (agetty-service (agetty-configuration
+                         (extra-options '("-L")) ; no carrier detect
+                         (term "vt100")
+                         (tty #f))) ; automatic
+
         (mingetty-service (mingetty-configuration
                            (tty "tty1")))
         (mingetty-service (mingetty-configuration
diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index e4b2e8237..27bc05c95 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -381,14 +381,6 @@ You have been warned.  Thanks for being so brave.\x1b[0m
                      nvi                          ;:wq!
                      %base-packages))))
 
-(define* (agetty-default-service #:optional (tty "ttyS0"))
-  "Return an agetty-service on the given TTY"
-  (agetty-service (agetty-configuration
-                   (extra-options '("-L"))
-                   (baud-rate "115200")
-                   (term "vt100")
-                   (tty tty))))
-
 (define* (embedded-installation-os bootloader bootloader-target tty
                                    #:key (extra-modules '()))
   "Return an installation os for embedded systems.
@@ -404,9 +396,7 @@ The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
     (initrd (lambda (fs . rest)
               (apply base-initrd fs
                      #:extra-modules extra-modules
-                     rest)))
-    (services (cons* (agetty-default-service tty)
-                     (operating-system-user-services installation-os)))))
+                     rest)))))
 
 (define beaglebone-black-installation-os
   (embedded-installation-os u-boot-beaglebone-black-bootloader

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP v5] services: agetty: Make tty optional.
  2018-01-24 13:12       ` [bug#30216] [WIP v4] " Danny Milosavljevic
@ 2018-01-24 13:31         ` Danny Milosavljevic
  2018-01-30 20:56           ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Danny Milosavljevic @ 2018-01-24 13:31 UTC (permalink / raw)
  To: 30216

* 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.
---
 gnu/services/base.scm  | 54 +++++++++++++++++++++++++++++++++++++++++++++++---
 gnu/system/install.scm | 37 +++++++++++-----------------------
 2 files changed, 63 insertions(+), 28 deletions(-)

diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 8e30bcd34..e8c0240bf 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,46 @@ 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 (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=" ""))
+             (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")))
+             (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)))))
+
 (define agetty-shepherd-service
   (match-lambda
     (($ <agetty-configuration> agetty tty term baud-rate auto-login
@@ -901,7 +941,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
@@ -946,6 +986,9 @@ the message of the day, among other things."
                                         ('always "--local-line=always")
                                         ('never "-local-line=never")))
                                  #~())
+                          #$@(if tty
+                                 #~()
+                                 #~("--keep-baud"))
                           #$@(if extract-baud?
                                  #~("--extract-baud")
                                  #~())
@@ -1009,7 +1052,7 @@ the message of the day, among other things."
                           #$@(if login-pause?
                                  #~("--login-pause")
                                  #~())
-                          #$tty
+                          #$(or tty (default-tty))
                           #$@(if baud-rate
                                  #~(#$baud-rate)
                                  #~())
@@ -2012,6 +2055,11 @@ This service is not part of @var{%base-services}."
                         (cons tty %default-console-font))
                       '("tty1" "tty2" "tty3" "tty4" "tty5" "tty6")))
 
+        (agetty-service (agetty-configuration
+                         (extra-options '("-L")) ; no carrier detect
+                         (term "vt100")
+                         (tty #f))) ; automatic
+
         (mingetty-service (mingetty-configuration
                            (tty "tty1")))
         (mingetty-service (mingetty-configuration
diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index e4b2e8237..db06b7a52 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -381,19 +381,10 @@ You have been warned.  Thanks for being so brave.\x1b[0m
                      nvi                          ;:wq!
                      %base-packages))))
 
-(define* (agetty-default-service #:optional (tty "ttyS0"))
-  "Return an agetty-service on the given TTY"
-  (agetty-service (agetty-configuration
-                   (extra-options '("-L"))
-                   (baud-rate "115200")
-                   (term "vt100")
-                   (tty tty))))
-
-(define* (embedded-installation-os bootloader bootloader-target tty
+(define* (embedded-installation-os bootloader bootloader-target
                                    #:key (extra-modules '()))
   "Return an installation os for embedded systems.
 The initrd gets the extra modules EXTRA-MODULES.
-A getty is provided on TTY.
 The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
   (operating-system
     (inherit installation-os)
@@ -404,43 +395,39 @@ The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
     (initrd (lambda (fs . rest)
               (apply base-initrd fs
                      #:extra-modules extra-modules
-                     rest)))
-    (services (cons* (agetty-default-service tty)
-                     (operating-system-user-services installation-os)))))
+                     rest)))))
 
 (define beaglebone-black-installation-os
   (embedded-installation-os u-boot-beaglebone-black-bootloader
                             "/dev/sda"
-                            "ttyO0"
                             #:extra-modules
                             ;; This module is required to mount the sd card.
                             '("omap_hsmmc")))
 
-
 (define a20-olinuxino-lime-installation-os
   (embedded-installation-os u-boot-a20-olinuxino-lime-bootloader
-                            "/dev/mmcblk0" ; SD card storage
-                            "ttyS0"))
+                            ;; SD card storage
+                            "/dev/mmcblk0"))
 
 (define a20-olinuxino-lime2-emmc-installation-os
   (embedded-installation-os u-boot-a20-olinuxino-lime2-bootloader
-                            "/dev/mmcblk1" ; eMMC storage
-                            "ttyS0"))
+                            ;; eMMC storage
+                            "/dev/mmcblk1"))
 
 (define a20-olinuxino-micro-installation-os
   (embedded-installation-os u-boot-a20-olinuxino-micro-bootloader
-                            "/dev/mmcblk0" ; SD card storage
-                            "ttyS0"))
+                            ;; SD card storage
+                            "/dev/mmcblk0"))
 
 (define banana-pi-m2-ultra-installation-os
   (embedded-installation-os u-boot-banana-pi-m2-ultra-bootloader
-                            "/dev/mmcblk1" ; eMMC storage
-                            "ttyS0"))
+                            ;; eMMC storage
+                            "/dev/mmcblk1"))
 
 (define nintendo-nes-classic-edition-installation-os
   (embedded-installation-os u-boot-nintendo-nes-classic-edition-bootloader
-                            "/dev/mmcblk0" ; SD card (solder it yourself)
-                            "ttyS0"))
+                            ;; SD card storage (solder it yourself)
+                            "/dev/mmcblk0"))
 
 ;; Return the default os here so 'guix system' can consume it directly.
 installation-os

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP] system: Add ARM installer; services: agetty: Make tty optional
  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
  0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2018-01-25 14:56 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 30216

Hello!

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> I hope it's not that board-specific.  There are minimal differences but
> many ARM boards use the same Linux kernel (with the same config).
>
> This was one of the motivation to create u-boot:  u-boot is like a
> board-specific mini-Linux kernel.  The Linux kernel that u-boot then
> loads later is not board-specific.
>
> In the past, board vendors kept putting huge board configuration tables inside
> Linux until Linus put a stop to it.
>
> Nowadays it should not be the case anymore that Linux is board-specific.

Understood.

> Therefore, I think it would be preferrable in the long run if
> Hydra didn't build 1000 different 1 GB images for different boards
> where the only different part is u-boot.

Definitely!

> So long story short, about 99% of the image this arm-installer generates
> will work and be identical for almost every ARMv7 board, except for u-boot
> (u-boot is kinda important, though).

Yes, but… this 1% is enough to make a non-bootable image though, which
is what I’m concerned with.  :-)

I suppose fixing it would mean having a universal ARM U-Boot?  Or do you
have other solutions in mind?

Ludo’.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP] system: Add ARM installer; services: agetty: Make tty optional
  2018-01-25 14:56     ` Ludovic Courtès
@ 2018-01-25 22:33       ` Danny Milosavljevic
  2018-01-26 10:36         ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Danny Milosavljevic @ 2018-01-25 22:33 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 30216

> I suppose fixing it would mean having a universal ARM U-Boot?  

Well, I guess that's for u-boot upstream to get to work.

> Or do you have other solutions in mind?

User boots the (u-boot-less) image using qemu and sets up u-boot on there - and
only then copies the whole (new) image to the SD card.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP] system: Add ARM installer; services: agetty: Make tty optional
  2018-01-25 22:33       ` Danny Milosavljevic
@ 2018-01-26 10:36         ` Ludovic Courtès
  0 siblings, 0 replies; 15+ messages in thread
From: Ludovic Courtès @ 2018-01-26 10:36 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 30216

Danny Milosavljevic <dannym@scratchpost.org> skribis:

>> I suppose fixing it would mean having a universal ARM U-Boot?  
>
> Well, I guess that's for u-boot upstream to get to work.
>
>> Or do you have other solutions in mind?
>
> User boots the (u-boot-less) image using qemu and sets up u-boot on there - and
> only then copies the whole (new) image to the SD card.

OK.  I guess that’d work, though it doesn’t sound particularly
convenient.

Ludo’.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP v5] services: agetty: Make tty optional.
  2018-01-24 13:31         ` [bug#30216] [WIP v5] " Danny Milosavljevic
@ 2018-01-30 20:56           ` Ludovic Courtès
  2018-01-30 23:24             ` Danny Milosavljevic
  2018-01-30 23:30             ` Danny Milosavljevic
  0 siblings, 2 replies; 15+ messages in thread
From: Ludovic Courtès @ 2018-01-30 20:56 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 30216

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’.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP v5] services: agetty: Make tty optional.
  2018-01-30 20:56           ` Ludovic Courtès
@ 2018-01-30 23:24             ` Danny Milosavljevic
  2018-01-30 23:30             ` Danny Milosavljevic
  1 sibling, 0 replies; 15+ messages in thread
From: Danny Milosavljevic @ 2018-01-30 23:24 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 30216

> +(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.

Sure.

> 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.

It's more for the repeated "console=" options which Linux supports.

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

Yeah.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP v5] services: agetty: Make tty optional.
  2018-01-30 20:56           ` Ludovic Courtès
  2018-01-30 23:24             ` Danny Milosavljevic
@ 2018-01-30 23:30             ` Danny Milosavljevic
  2018-01-31  9:09               ` Ludovic Courtès
  1 sibling, 1 reply; 15+ messages in thread
From: Danny Milosavljevic @ 2018-01-30 23:30 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 30216

Hi Ludo,

> 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))))

"ttyS0" starts with "tty" but should not be removed...

> Maybe default to /dev/ttyS0?

Sounds unsafe.  Also, on x86_64 that's not really useful either.  It would be
good to have a way to the not start the service after all in that case.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [bug#30216] [WIP v5] services: agetty: Make tty optional.
  2018-01-30 23:30             ` Danny Milosavljevic
@ 2018-01-31  9:09               ` Ludovic Courtès
  0 siblings, 0 replies; 15+ messages in thread
From: Ludovic Courtès @ 2018-01-31  9:09 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 30216

Hey Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

>> 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))))
>
> "ttyS0" starts with "tty" but should not be removed...
>
>> Maybe default to /dev/ttyS0?
>
> Sounds unsafe.  Also, on x86_64 that's not really useful either.  It would be
> good to have a way to the not start the service after all in that case.

What about having ‘default-serial-port’ return #f in that case, and do
something like:

  #:start #~(let ((tty #$(default-serial-port)))
              (if tty
                  (make-forkexec-constructor …)
                  (const #f)))   ;never start

?

Ludo’.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-01-31  9:11 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.