From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Subject: bug#35640: Make USB modems just work on Guix Date: Wed, 12 Jun 2019 23:11:16 +0200 Message-ID: <87zhmmqzkb.fsf@gnu.org> References: <20190513210443.y2xs7fsvxwng3zjz@pelzflorian.localdomain> <20190514103555.1b2a6316@scratchpost.org> <20190514205648.nl4s4lwvc4t67gho@pelzflorian.localdomain> <87ef4zvpm7.fsf@gnu.org> <20190522162909.tds5wz7lj6npkgy4@pelzflorian.localdomain> <87ef4nx3s2.fsf@gnu.org> <20190524201210.bzeyua7lv2mamf52@pelzflorian.localdomain> <20190525111856.jfu5ly2p6ynn3rdk@pelzflorian.localdomain> <87lfyupgxm.fsf@gnu.org> <20190525194215.egiyrax3f3k7nojp@pelzflorian.localdomain> <20190612103646.yem2wtmw6w2vw7an@pelzflorian.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:59739) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbAXM-0006qR-6k for bug-guix@gnu.org; Wed, 12 Jun 2019 17:12:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbAXK-00026H-QK for bug-guix@gnu.org; Wed, 12 Jun 2019 17:12:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48879) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbAXK-00025z-MT for bug-guix@gnu.org; Wed, 12 Jun 2019 17:12:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hbAXK-0001v2-Eh for bug-guix@gnu.org; Wed, 12 Jun 2019 17:12:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <20190612103646.yem2wtmw6w2vw7an@pelzflorian.localdomain> (pelzflorian@pelzflorian.de's message of "Wed, 12 Jun 2019 12:36:47 +0200") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: "pelzflorian (Florian Pelz)" Cc: 35640@debbugs.gnu.org "pelzflorian (Florian Pelz)" skribis: > I am uncertain if having paragraphs like this in > modem-manager-service-type and usb-modeswitch-service-type is a good > idea: > > This service is part of =E2=80=98%desktop-services=E2=80=99 (*note D= esktop > Services::). I think it=E2=80=99s OK. Looks like we=E2=80=99re almost there! A couple of comments and suggestion= s: >>From db6e3a937f89811017abf06c7dffc494b71b9127 Mon Sep 17 00:00:00 2001 > From: Florian Pelz > Date: Tue, 11 Jun 2019 16:56:46 +0200 > Subject: [PATCH 2/3] Add usb-modeswitch-service-type. > > * gnu/services/networking.scm (usb-modeswitch-service-type): New variable. > (usb-modeswitch-configuration): New variable. > (usb-modeswitch-configuration->udev-rules): New procedure. > * doc/guix.texi (Networking Services): Document it. [...] > +When plugged in, some USB modems (and other USB devices) initially prese= nt > +themselves as a read-only storage medium and not as a modem. They need = to be > +@dfn{modeswitched} before they are usable. The USB_ModeSwitch service t= ype > +installs UDEV rules to automatically modeswitch these devices when they = are s/UDEV/udev/ (here and elsewhere). > +(define (usb-modeswitch-configuration->udev-rules config) > + "Build a rules file for extending udev-service-type from the rules in = the > +usb-modeswitch package. The rules file will invoke usb_modeswitch.sh fr= om the > +usb-modeswitch package, modified to pass the right config file." > + (define usb-modeswitch-sh > + (match-lambda > + (($ usb-modeswitch data config-file) > + (let ((orig #~(string-append #$usb-modeswitch:dispatcher > + "/lib/udev/usb_modeswitch"))) > + (computed-file > + "usb_modeswitch-sh" (computed-file =E2=80=A6) should probably be moved to a separate procedure,= to keep the main procedure concise. > + (with-imported-modules '((guix build utils)) > + #~(begin > + (use-modules (guix build utils)) > + (let ((cfg-param > + (case #$config-file > + ((#f) "") > + (else > + (string-append " --config-file=3D" #$config-fi= le))))) Instead of (case =E2=80=A6), maybe this would be slightly clearer: #$(if config-file #~(string-append =E2=80=A6 #$config-file) "") > + (mkdir #$output) > + (install-file #$orig #$output) > + (substitute* (string-append #$output "/usb_modeswitch") > + (("(exec usb_modeswitch_dispatcher .*)( 2>>)" _ left= right) > + (string-append left cfg-param right)) > + (("(exec usb_modeswitch_dispatcher .*)( &)" _ left r= ight) > + (string-append left cfg-param right))) Perhaps add comments to explain what=E2=80=99s happening here. > + ;; wrap-program needs bash in PATH: > + (putenv (string-append "PATH=3D" #$bash "/bin")) Why do you think so? =E2=80=98wrap-program=E2=80=99 does not read $PATH, A= FAICS. >>From dc50f979f77d9298e8c81e6943076c612e5f459a Mon Sep 17 00:00:00 2001 > From: Florian Pelz > Date: Wed, 12 Jun 2019 11:16:57 +0200 > Subject: [PATCH 3/3] services: Include USB_ModeSwitch in %desktop-service= s. > > Fixes . > > * gnu/services/desktop.scm (%desktop-services): Add usb-modeswitch-servic= e-type. > * doc/guix.texi (Networking Services): Document it. OK! Thank you! Ludo=E2=80=99.