[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
89/197: installer: Make the network menu more reliable.
From: |
Danny Milosavljevic |
Subject: |
89/197: installer: Make the network menu more reliable. |
Date: |
Mon, 3 Jul 2017 20:37:05 -0400 (EDT) |
dannym pushed a commit to branch wip-installer-2
in repository guix.
commit bd5e477a24159984892023dfd988b93b8f279585
Author: John Darrington <address@hidden>
Date: Wed Jan 11 14:03:34 2017 +0100
installer: Make the network menu more reliable.
* gnu/system/installer/network.scm (name->description): New procedure,a
and use it in network-page init.
---
gnu/system/installer/network.scm | 68 +++++++++++++++++++++++-----------------
1 file changed, 39 insertions(+), 29 deletions(-)
diff --git a/gnu/system/installer/network.scm b/gnu/system/installer/network.scm
index 04861cf..15cdb8b 100644
--- a/gnu/system/installer/network.scm
+++ b/gnu/system/installer/network.scm
@@ -24,6 +24,7 @@
#:use-module (gnu system installer wireless)
#:use-module (guix build syscalls)
#:use-module (ice-9 format)
+ #:use-module (ice-9 regex)
#:use-module (ice-9 match)
#:use-module (gurses menu)
#:use-module (gurses buttons)
@@ -48,6 +49,36 @@
(else 'ethernet)))))
(all-network-interface-names)))
+(define (match->elem m match-number)
+ (let ((elem (match:substring m match-number)))
+ (if elem
+ (string->number (string-drop elem 1))
+ 0)))
+
+;; Convert a network device name such as "enp0s25" to
+;; something more descriptive like
+;; "82567LM Gigabit Network Connection"
+(define (name->description name)
+ (if (string=? name "lo")
+ "Loop back interface"
+ (let ((m (string-match
"^..(P[[:digit:]]+)?(p[[:digit:]]+)(s[[:digit:]]+)(f[[:digit:]]+)?" name)))
+ (if (not m)
+ name
+ (let ((domain (match->elem m 1))
+ (bus (match->elem m 2))
+ (slot (match->elem m 3))
+ (func (match->elem m 4)))
+ (assoc-ref
+ (slurp
+ (format #f "lspci -v -mm -s~x:~x:~x.~x"
+ domain bus slot func)
+ (lambda (x)
+ (let ((idx (string-index x #\:)))
+ (cons (substring x 0 idx)
+ (string-trim
+ (substring x (1+ idx)))))))
+ "Device"))))))
+
(define my-buttons `((continue ,(N_ "_Continue") #t)
(test ,(N_ "_Test") #t)))
@@ -153,35 +184,14 @@
(interfaces))
#:disp-proc
(lambda (datum row)
- (match (string-split
- (car (slurp
- (string-append "ip -o link show "
- (assq-ref datum 'name))
- #f)) #\space)
- ((_ _ flags _ _ _ _ _ state . _)
-
- ;; Convert a network device name such as "enp0s25" to
- ;; something more descriptive like
- ;; "82567LM Gigabit Network Connection"
- (let* ((name (assq-ref datum 'name))
- (addr (string-tokenize name char-set:digit)))
- (match addr
- ((bus device . func)
- (format #f "~50a ~6a ~a"
- (assoc-ref
- (slurp
- (format #f "lspci -v -mm -s~x:~x.~x"
- (string->number bus 10)
- (string->number device 10)
- (if (null? func) 0
- (string->number func 10)))
- (lambda (x)
- (let ((idx (string-index x #\:)))
- (cons (substring x 0 idx)
- (string-trim
- (substring x (1+ idx)))))))
- "Device")
- state flags))))))))))
+ (format #f "~55a ~a"
+ (name->description (assq-ref datum 'name))
+ (if (zero? (logand IFF_RUNNING
+ (network-interface-flags
+ (socket SOCK_STREAM AF_INET 0)
+ (assq-ref datum 'name))))
+ (gettext "Down")
+ (gettext "Running")))))))
(addstr* text-window (format #f
(gettext
- 66/197: installer: Add option to final page to reboot the system., (continued)
- 66/197: installer: Add option to final page to reboot the system., Danny Milosavljevic, 2017/07/03
- 71/197: installer: Add confidence indicator., Danny Milosavljevic, 2017/07/03
- 67/197: installer: Add predicate for the network task., Danny Milosavljevic, 2017/07/03
- 74/197: installer: Remove explicit calls to curs-set from pages., Danny Milosavljevic, 2017/07/03
- 64/197: installer: Make setting up of the network a prerequisite., Danny Milosavljevic, 2017/07/03
- 80/197: installer: Ignore case in button accelerators., Danny Milosavljevic, 2017/07/03
- 86/197: installer: slurp: Ignore blank lines in output., Danny Milosavljevic, 2017/07/03
- 76/197: installer: New procedure "page-leave"., Danny Milosavljevic, 2017/07/03
- 84/197: installer: Use guix build syscalls module for network interrogation., Danny Milosavljevic, 2017/07/03
- 94/197: installer: Add the notion of uuids to prospective filesystems., Danny Milosavljevic, 2017/07/03
- 89/197: installer: Make the network menu more reliable.,
Danny Milosavljevic <=
- 90/197: installer: Enable direct scrolling to top or bottom of menus., Danny Milosavljevic, 2017/07/03
- 78/197: installer: Ensure that the cursor visibility is updated on each page., Danny Milosavljevic, 2017/07/03
- 107/197: installer: Do not allow the creation of invalid file-system specificaitons., Danny Milosavljevic, 2017/07/03
- 57/197: installer: Add a console-keymap service., Danny Milosavljevic, 2017/07/03
- 69/197: installer: Remove "continue" button from host name page., Danny Milosavljevic, 2017/07/03
- 58/197: installer: Add flags to indicate network interface status., Danny Milosavljevic, 2017/07/03
- 72/197: installer: Use --fallback when installing., Danny Milosavljevic, 2017/07/03
- 73/197: installer: Correct behaviour of push-cursor and pop-cursor procedures., Danny Milosavljevic, 2017/07/03
- 77/197: installer: New procedure: page-enter., Danny Milosavljevic, 2017/07/03
- 82/197: installer: Rename 'file-browser.scm' to 'key-map.scm'., Danny Milosavljevic, 2017/07/03