guix-commits
[Top][All Lists]
Advanced

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

03/22: installer: Make "interfaces" return an alist.


From: John Darrington
Subject: 03/22: installer: Make "interfaces" return an alist.
Date: Tue, 27 Dec 2016 06:02:08 +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



reply via email to

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