diff options
| author | Rutherther <rutherther@ditigal.xyz> | 2026-01-03 15:36:00 +0100 |
|---|---|---|
| committer | Rutherther <rutherther@ditigal.xyz> | 2026-01-14 09:17:33 +0100 |
| commit | ab22501915fa57cf3a3f94dcc7fec86b433d85ad (patch) | |
| tree | 5008e84b52279284d7467ae78cc78b569a89e850 /gnu/build | |
| parent | 84a018b3569a26fbb99d0c71fdbd2addb5686467 (diff) | |
install: Register agetty on primary console on AArch64.
This adds the possibility to parse /proc/consoles to find a primary console.
Then, on AArch64 this is used in the installation image. On AArch64, the boot
usually happens with chosen device tree that contains the serial console.
On x86_64, this does not happen so often, so we keep the installation iso
minimal there.
The primary console is chosen, but there is a fallback to any non-virtual one.
Virtual console (/dev/tty0) is skipped, because that one can point to any
console, like /dev/tty1 and so on. So it's not safe to register agetty on it.
* gnu/build/linux-boot.scm (read-linux-consoles): New variable.
* gnu/services/base.scm (default-serial-console): Use primary console as
fallback.
* gnu/system/install.scm (%installation-services): Add agetty tty for
consoles.
Change-Id: Iae01f7bc85b5ffdef2e52b1d0710889915b0f54a
Signed-off-by: Rutherther <rutherther@ditigal.xyz>
Diffstat (limited to 'gnu/build')
| -rw-r--r-- | gnu/build/linux-boot.scm | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm index 61fa6716dba..e0743eae55a 100644 --- a/gnu/build/linux-boot.scm +++ b/gnu/build/linux-boot.scm | |||
| @@ -46,7 +46,26 @@ | |||
| 46 | make-static-device-nodes | 46 | make-static-device-nodes |
| 47 | configure-qemu-networking | 47 | configure-qemu-networking |
| 48 | 48 | ||
| 49 | boot-system)) | 49 | boot-system |
| 50 | |||
| 51 | linux-console | ||
| 52 | |||
| 53 | linux-console? | ||
| 54 | linux-console-device | ||
| 55 | linux-console-can-read? | ||
| 56 | linux-console-can-write? | ||
| 57 | linux-console-can-unblank? | ||
| 58 | linux-console-enabled? | ||
| 59 | linux-console-preferred? | ||
| 60 | linux-console-primary? | ||
| 61 | linux-console-printk? | ||
| 62 | linux-console-braille? | ||
| 63 | linux-console-safe-when-cpu-offline? | ||
| 64 | linux-console-major | ||
| 65 | linux-console-minor | ||
| 66 | linux-console-virtual? | ||
| 67 | |||
| 68 | read-linux-consoles)) | ||
| 50 | 69 | ||
| 51 | ;;; Commentary: | 70 | ;;; Commentary: |
| 52 | ;;; | 71 | ;;; |
| @@ -675,4 +694,56 @@ the root file system...\n" root-delay) | |||
| 675 | (start-repl))))) | 694 | (start-repl))))) |
| 676 | #:on-error on-error)) | 695 | #:on-error on-error)) |
| 677 | 696 | ||
| 697 | (define-record-type <linux-console> | ||
| 698 | (make-linux-console device can-read? can-write? can-unblank? | ||
| 699 | enabled? preferred? primary? printk? braille? | ||
| 700 | safe-when-cpu-offline? major minor virtual?) | ||
| 701 | linux-console? | ||
| 702 | (device linux-console-device) | ||
| 703 | (can-read? linux-console-can-read?) | ||
| 704 | (can-write? linux-console-can-write?) | ||
| 705 | (can-unblank? linux-console-can-unblank?) | ||
| 706 | (enabled? linux-console-enabled?) | ||
| 707 | (preferred? linux-console-preferred?) | ||
| 708 | (primary? linux-console-primary?) | ||
| 709 | (printk? linux-console-printk?) | ||
| 710 | (braille? linux-console-braille?) | ||
| 711 | (safe-when-cpu-offline? linux-console-safe-when-cpu-offline?) | ||
| 712 | (major linux-console-major) | ||
| 713 | (minor linux-console-minor) | ||
| 714 | (virtual? linux-console-virtual?)) | ||
| 715 | |||
| 716 | (define* (read-linux-consoles #:optional (consoles-file "/proc/consoles")) | ||
| 717 | "Parses CONSOLES-FILE and returns a list of <linux-console> records." | ||
| 718 | (if (not (file-exists? consoles-file)) | ||
| 719 | '() | ||
| 720 | (with-input-from-file consoles-file | ||
| 721 | (lambda () | ||
| 722 | (let ((line-regex (make-regexp | ||
| 723 | "^([^ ]+)[ ]+(.+)[ ]+([0-9]+):([0-9]+)$")) | ||
| 724 | (virt-regex (make-regexp "^tty[0-9]+$"))) | ||
| 725 | (let loop ((line (read-line)) | ||
| 726 | (results '())) | ||
| 727 | (cond | ||
| 728 | ((eof-object? line) | ||
| 729 | (reverse results)) | ||
| 730 | ((regexp-exec line-regex line) | ||
| 731 | => (lambda (m) | ||
| 732 | (let* ((dev (match:substring m 1)) | ||
| 733 | (flags (match:substring m 2)) | ||
| 734 | (major (string->number (match:substring m 3))) | ||
| 735 | (minor (string->number (match:substring m 4))) | ||
| 736 | (virtual? (regexp-exec virt-regex dev)) | ||
| 737 | (has? (lambda (c) | ||
| 738 | (string-any (lambda (f) (char=? f c)) flags)))) | ||
| 739 | (loop (read-line) | ||
| 740 | (cons (make-linux-console | ||
| 741 | dev | ||
| 742 | (has? #\R) (has? #\W) (has? #\U) (has? #\E) | ||
| 743 | (has? #\C) (has? #\B) (has? #\p) (has? #\b) | ||
| 744 | (has? #\a) | ||
| 745 | major minor virtual?) | ||
| 746 | results))))) | ||
| 747 | (else (loop (read-line) results))))))))) | ||
| 748 | |||
| 678 | ;;; linux-boot.scm ends here | 749 | ;;; linux-boot.scm ends here |
