[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
24/80: installer: Make "interfaces" return an alist.
From: |
John Darrington |
Subject: |
24/80: installer: Make "interfaces" return an alist. |
Date: |
Tue, 3 Jan 2017 15:49:42 +0000 (UTC) |
jmd pushed a commit to branch wip-installer
in repository guix.
commit 3fe5d0b1b78fbf8f50b83c8c7f4e333436cc9d10
Author: John Darrington <address@hidden>
Date: Sat Dec 24 10:04:08 2016 +0100
installer: Make "interfaces" return an alist.
* gnu/system/installer/network.scm (interfaces) : Convert from a procedure
returning a list of strings, to a procedure returning an alist and deal with
the consequences.
---
gnu/system/installer/network.scm | 41 ++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/gnu/system/installer/network.scm b/gnu/system/installer/network.scm
index da8d959..4e3abd6 100644
--- a/gnu/system/installer/network.scm
+++ b/gnu/system/installer/network.scm
@@ -37,14 +37,19 @@
network-page-key-handler))
-(define (interfaces) (delete "lo"
+(define (interfaces)
(slurp "ip -o link"
(lambda (s)
- (match (string-split s #\:)
- ((_ interface-name . _)
- (string-trim-both
- interface-name
- char-set:whitespace)))))))
+ (match (string-split s #\space)
+ ((_ interface-name _ _ _ _ _ _
+ state _ _ _ _ _ _ _ _ _ class . _)
+ `((name .
+ ,(string-trim-right
+ interface-name #\:))
+ (state . ,state)
+ (class . ,class)))))))
+
+
(define my-buttons `((continue ,(N_ "_Continue") #t)
(test ,(N_ "_Test") #t)))
@@ -134,22 +139,24 @@
(getmaxy text-window) 0 #:panel #f))
(menu (make-menu
- (interfaces)
+ (filter (lambda (i) (equal? "link/ether" (assq-ref i 'class)))
+ (interfaces))
#:disp-proc
(lambda (datum row)
- ;; Convert a network device name such as "enp0s25" to
+ ;; Convert a network device name such as "enp0s25" to
;; something more descriptive like
;; "82567LM Gigabit Network Connection"
- (let* ((addr (string-tokenize datum char-set:digit))
- (bus (match addr ((n . _)
- (string->number n 10))))
+ (let* ((name (assq-ref datum 'name))
+ (addr (string-tokenize name char-set:digit))
+ (bus (match addr ((n . _)
+ (string->number n 10))))
- (device (match addr ((_ . (n . _))
- (string->number n 10))))
+ (device (match addr ((_ . (n . _))
+ (string->number n 10))))
- (func (match addr
- ((_ . (_ . (n . _)))
- (string->number n 10)) (_ 0))))
+ (func (match addr
+ ((_ . (_ . (n . _)))
+ (string->number n 10)) (_ 0))))
(car (assoc-ref
(cdr
;; It seems that lspci always prints an initial
@@ -160,7 +167,7 @@
(slurp (format #f "lspci -vm -s~x:~x.~x" bus device
func)
(lambda (x)
(string-split x #\tab))))
- "Device:")))))))
+ "Device:")))))))
(addstr* text-window (format #f
- 02/80: installer: Fix broken keymap change option., (continued)
- 02/80: installer: Fix broken keymap change option., John Darrington, 2017/01/03
- 07/80: installer: Use ice-9 match., John Darrington, 2017/01/03
- 06/80: installer: use ice-9 format everywhere., John Darrington, 2017/01/03
- 08/80: installer: Add IETF contraints for hostname in entry form., John Darrington, 2017/01/03
- 12/80: installer: Add gurses modules., John Darrington, 2017/01/03
- 21/80: gnu: guix: Add dependency: guile-ncurses., John Darrington, 2017/01/03
- 17/80: installer: Add new procedure to get the list of volumes., John Darrington, 2017/01/03
- 19/80: installer: Handle the 'back' action in the filesystems task., John Darrington, 2017/01/03
- 23/80: installer: Fix incorrect host in ping task., John Darrington, 2017/01/03
- 25/80: installer: Use a cleaner way of generating the lspci information., John Darrington, 2017/01/03
- 24/80: installer: Make "interfaces" return an alist.,
John Darrington <=
- 27/80: installer: Connect ethernet interfaces on selection., John Darrington, 2017/01/03
- 28/80: installer: Let the kernel know about (possibly) changed partitions., John Darrington, 2017/01/03
- 49/80: installer: Wrap installer in (catch #t ...), John Darrington, 2017/01/03
- 09/80: installer: Use a record instead of a list to contain tasks., John Darrington, 2017/01/03
- 29/80: installer: Deal with partition tables which are (partially) corrupt., John Darrington, 2017/01/03
- 37/80: installer: Improve dependencies on the final task., John Darrington, 2017/01/03
- 31/80: gnu: Add service to start the installer in installation-os., John Darrington, 2017/01/03
- 36/80: installer: Remove ad-hoc completed predicate and use standard one., John Darrington, 2017/01/03
- 35/80: installer: Make minumum-store-size variable global., John Darrington, 2017/01/03
- 34/80: installer: Add path to mount/umount commands in installer service., John Darrington, 2017/01/03