* bug#35640: Make USB modems just work on Guix @ 2019-05-08 18:26 pelzflorian (Florian Pelz) 2019-05-09 5:31 ` pelzflorian (Florian Pelz) 2019-05-09 15:24 ` Ludovic Courtès 0 siblings, 2 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-08 18:26 UTC (permalink / raw) To: 35640 [-- Attachment #1: Type: text/plain, Size: 1971 bytes --] When plugging in a USB modem, i.e. a “surf stick” / internet stick with a SIM card for mobile broadband, setup should be as simple as WiFi. However, a few things are missing in Guix. First, the manual claims: -- Scheme Variable: modem-manager-service-type […] This service is part of ‘%desktop-services’ (*note Desktop Services::). But it is not part of %desktop-services. The first attached patch fixes this oversight. Now I can type this to get an internet connection: sudo nmcli connection add type gsm ifname ttyUSB1 apn internet However, I want to be able to do this setup graphically. I made a second patch to propagate iso-codes (for mobile broadband country selection) and mobile-broadband-provider-selection (for selecting defaults for providers) in nm-connection-editor (network-manager-applet) and gnome-control-center. Propagation is ugly though. Should I try patching network-manager-applet instead? I assume there are other packages doing such patching that I can imitate. Now I can configure the modem as Mobile Broadband in a graphical interface. I cannot do so in nmtui; I believe this modem setup feature is not included in nmtui. However, this is not the whole truth. Before I can configure anything, I have to run sudo ~/usr/sbin/usb_modeswitch -c ~/Downloads/usb-modeswitch-data-20170806/usb_modeswitch.d/12d1:14fe -v 0x12d1 -p 0x14fe because my modem by default presents itself as a CD containing Windows drivers and not as a USB modem. Preferrably, usb-modeswitch and usb-modeswitch-data would be packaged (as a single package). I can try that later this week. Lastly, there are udev rules in usb-modeswitch, I believe, because on Debian I do not need to run any command; mode switching happens automatically when plugging in the USB modem. I suppose that means there should also be a usb-modeswitch-service-type extending udev? Regards, Florian [-- Attachment #2: 0001-services-Include-ModemManager-in-desktop-services.patch --] [-- Type: text/plain, Size: 1078 bytes --] From 5e9b45fe785dee52da2a67fbecbabc4741f85e54 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Tue, 7 May 2019 11:51:43 +0200 Subject: [PATCH 1/2] services: Include ModemManager in %desktop-services. * gnu/services/desktop.scm (%desktop-services): Add modem-manager-service-type. --- gnu/services/desktop.scm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index 5e0bd102a2..c0300c0ddc 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -1062,6 +1062,9 @@ dispatches events from it."))) ;; The D-Bus clique. (service network-manager-service-type) + (service modem-manager-service-type) ;the manual claims this were + ;part of %desktop-services, but + ;it wasn’t (service wpa-supplicant-service-type) ;needed by NetworkManager (service avahi-service-type) (udisks-service) -- 2.21.0 [-- Attachment #3: 0002-gnu-network-manager-applet-Propagate-packages-requir.patch --] [-- Type: text/plain, Size: 1757 bytes --] From d489f805599ea63e2e06727a3201572ee0480a60 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Wed, 8 May 2019 20:02:00 +0200 Subject: [PATCH 2/2] gnu: network-manager-applet: Propagate packages required for USB modem setup. * gnu/packages/gnome.scm (network-manager-applet): Propagate iso-codes and mobile-broadband-provider-info. (gnome-control-center): Ditto. --- gnu/packages/gnome.scm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm index 7c40a39f01..a3765007bf 100644 --- a/gnu/packages/gnome.scm +++ b/gnu/packages/gnome.scm @@ -5511,10 +5511,12 @@ to virtual private networks (VPNs) via OpenVPN.") ;; libnm-gtk.pc refers to all these. `(("dbus-glib" ,dbus-glib) ("gtk+" ,gtk+) + ("iso-codes" ,iso-codes) ;mobile broadband country selection + ("mobile-broadband-provider-info" + ,mobile-broadband-provider-info) ;mobile broadband provider selection ("network-manager" ,network-manager))) (inputs - `(("iso-codes" ,iso-codes) - ("libgudev" ,libgudev) + `(("libgudev" ,libgudev) ("libnotify" ,libnotify) ("libsecret" ,libsecret) ("libselinux" ,libselinux) @@ -5895,6 +5897,10 @@ devices using the GNOME desktop.") ("smbclient" ,samba) ("tzdata" ,tzdata) ("upower" ,upower))) + (propagated-inputs + `(("iso-codes" ,iso-codes) ;mobile broadband country selection + ("mobile-broadband-provider-info" + ,mobile-broadband-provider-info))) ;mobile broadband provider selection (synopsis "Utilities to configure the GNOME desktop") (home-page "https://www.gnome.org/") (description -- 2.21.0 ^ permalink raw reply related [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-08 18:26 bug#35640: Make USB modems just work on Guix pelzflorian (Florian Pelz) @ 2019-05-09 5:31 ` pelzflorian (Florian Pelz) 2019-05-09 12:55 ` Danny Milosavljevic 2019-05-09 15:24 ` Ludovic Courtès 1 sibling, 1 reply; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-09 5:31 UTC (permalink / raw) To: 35640 On Wed, May 08, 2019 at 08:26:07PM +0200, pelzflorian (Florian Pelz) wrote: > However, I want to be able to do this setup graphically. I made a > second patch to propagate iso-codes (for mobile broadband country > selection) and mobile-broadband-provider-selection (for selecting > defaults for providers) in nm-connection-editor > (network-manager-applet) and gnome-control-center. > I meant mobile-broadband-provider-info. > Propagation is ugly though. Should I try patching > network-manager-applet instead? I assume there are other packages > doing such patching that I can imitate. > > There is a branch wip-gnome3.30. Should I base the patch on wip-gnome3.30 or on master? > Preferrably, usb-modeswitch and > usb-modeswitch-data would be packaged (as a single package). There are two source URLs, so these two must be two packages, right? Regards, Florian ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-09 5:31 ` pelzflorian (Florian Pelz) @ 2019-05-09 12:55 ` Danny Milosavljevic 2019-05-09 13:07 ` pelzflorian (Florian Pelz) 0 siblings, 1 reply; 39+ messages in thread From: Danny Milosavljevic @ 2019-05-09 12:55 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 106 bytes --] I think back then we thought it would be too big for the installation medium. How big is it after that? [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-09 12:55 ` Danny Milosavljevic @ 2019-05-09 13:07 ` pelzflorian (Florian Pelz) 2019-05-09 13:43 ` pelzflorian (Florian Pelz) 0 siblings, 1 reply; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-09 13:07 UTC (permalink / raw) To: Danny Milosavljevic; +Cc: 35640 On Thu, May 09, 2019 at 02:55:04PM +0200, Danny Milosavljevic wrote: > I think back then we thought it would be too big for the installation medium. > How big is it after that? The installation medium uses %desktop-services? I will check, but my proposal does not concern the installation medium. Regards, Florian ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-09 13:07 ` pelzflorian (Florian Pelz) @ 2019-05-09 13:43 ` pelzflorian (Florian Pelz) 0 siblings, 0 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-09 13:43 UTC (permalink / raw) To: Danny Milosavljevic; +Cc: 35640 OBOn Thu, May 09, 2019 at 03:07:12PM +0200, pelzflorian (Florian Pelz) wrote: > On Thu, May 09, 2019 at 02:55:04PM +0200, Danny Milosavljevic wrote: > > I think back then we thought it would be too big for the installation medium. > > How big is it after that? > > > The installation medium uses %desktop-services? I will check, but my > proposal does not concern the installation medium. > There is no size difference. The patches only affect installed systems. Regards, Florian ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-08 18:26 bug#35640: Make USB modems just work on Guix pelzflorian (Florian Pelz) 2019-05-09 5:31 ` pelzflorian (Florian Pelz) @ 2019-05-09 15:24 ` Ludovic Courtès 2019-05-13 20:57 ` pelzflorian (Florian Pelz) 2019-05-16 7:50 ` pelzflorian (Florian Pelz) 1 sibling, 2 replies; 39+ messages in thread From: Ludovic Courtès @ 2019-05-09 15:24 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 Hi Florian, "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: >From 5e9b45fe785dee52da2a67fbecbabc4741f85e54 Mon Sep 17 00:00:00 2001 > From: Florian Pelz <pelzflorian@pelzflorian.de> > Date: Tue, 7 May 2019 11:51:43 +0200 > Subject: [PATCH 1/2] services: Include ModemManager in %desktop-services. > > * gnu/services/desktop.scm (%desktop-services): Add modem-manager-service-type. > --- > gnu/services/desktop.scm | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm > index 5e0bd102a2..c0300c0ddc 100644 > --- a/gnu/services/desktop.scm > +++ b/gnu/services/desktop.scm > @@ -1062,6 +1062,9 @@ dispatches events from it."))) > > ;; The D-Bus clique. > (service network-manager-service-type) > + (service modem-manager-service-type) ;the manual claims this were > + ;part of %desktop-services, but > + ;it wasn’t The comment is unnecessary, but otherwise LGTM! I’ve confirmed that there is no size increase: --8<---------------cut here---------------start------------->8--- $ guix size network-manager | tail -1 total: 534.9 MiB $ guix size network-manager modem-manager | tail -1 total: 534.9 MiB --8<---------------cut here---------------end--------------->8--- >From d489f805599ea63e2e06727a3201572ee0480a60 Mon Sep 17 00:00:00 2001 > From: Florian Pelz <pelzflorian@pelzflorian.de> > Date: Wed, 8 May 2019 20:02:00 +0200 > Subject: [PATCH 2/2] gnu: network-manager-applet: Propagate packages required > for USB modem setup. > > * gnu/packages/gnome.scm (network-manager-applet): Propagate iso-codes and > mobile-broadband-provider-info. > (gnome-control-center): Ditto. Would it be an option to avoid propagation by instead substituting references to these two things in the code of network-manager-applet and gnome-control-center? WDYT? Thanks! Ludo’. ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-09 15:24 ` Ludovic Courtès @ 2019-05-13 20:57 ` pelzflorian (Florian Pelz) 2019-05-13 21:04 ` pelzflorian (Florian Pelz) ` (2 more replies) 2019-05-16 7:50 ` pelzflorian (Florian Pelz) 1 sibling, 3 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-13 20:57 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 694 bytes --] On Thu, May 09, 2019 at 05:24:39PM +0200, Ludovic Courtès wrote: > The comment is unnecessary, but otherwise LGTM! > :) I have attached the patch without the command. Also attached is my current work-in-progress package for USB_ModeSwitch. It does *not* work because I cannot figure out how to use tcl in the package’s inputs field. #:use-module gives me errors; only (@ (gnu packages tcl) tcl) appears to work. > Would it be an option to avoid propagation by instead substituting > references to these two things in the code of network-manager-applet and > gnome-control-center? WDYT? > I will try finding and imitating an example for such substitutions tomorrow. Regards, Florian [-- Attachment #2: 0001-services-Include-ModemManager-in-desktop-services.patch --] [-- Type: text/plain, Size: 877 bytes --] From 827d931eb6b72572f547c87e650780cf50e9e20c Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Mon, 13 May 2019 22:51:28 +0200 Subject: [PATCH] services: Include ModemManager in %desktop-services. * gnu/services/desktop.scm (%desktop-services): Add modem-manager-service-type. --- gnu/services/desktop.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index 5e0bd102a2..ac714ca5e0 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -1062,6 +1062,7 @@ dispatches events from it."))) ;; The D-Bus clique. (service network-manager-service-type) + (service modem-manager-service-type) (service wpa-supplicant-service-type) ;needed by NetworkManager (service avahi-service-type) (udisks-service) -- 2.21.0 [-- Attachment #3: 0001-Add-USB_ModeSwitch.patch --] [-- Type: text/plain, Size: 5752 bytes --] From 8861177166d74b84c0ac18bf102802cc1e6cf5d3 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Mon, 13 May 2019 22:35:00 +0200 Subject: [PATCH] Add USB_ModeSwitch. * gnu/packages/libusb.scm (usb-modeswitch-data) Add it. (usb-modeswitch) Add it. --- gnu/packages/libusb.scm | 91 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/gnu/packages/libusb.scm b/gnu/packages/libusb.scm index 5ef62e47fb..00577bb333 100644 --- a/gnu/packages/libusb.scm +++ b/gnu/packages/libusb.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2017 Jonathan Brielmaier <jonathan.brielmaier@web.de> ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org> +;;; Copyright © 2019 Florian Pelz <pelzflorian@pelzflorian.de> ;;; ;;; This file is part of GNU Guix. ;;; @@ -25,6 +26,7 @@ ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (gnu packages libusb) + #:use-module (system repl debug) #:use-module (gnu packages) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) @@ -36,6 +38,7 @@ #:use-module (guix build-system gnu) #:use-module (guix build-system glib-or-gtk) #:use-module (guix build-system python) + #:use-module (guix build-system trivial) #:use-module (gnu packages autotools) #:use-module (gnu packages gnupg) #:use-module (gnu packages gtk) @@ -45,8 +48,12 @@ #:use-module (gnu packages pkg-config) #:use-module (gnu packages python) #:use-module (gnu packages python-xyz) + #:use-module ((gnu packages tcl) #:prefix tcl:) + #:use-module (system foreign) + #:use-module (rnrs bytevectors) #:use-module (gnu packages tls) #:use-module (gnu packages xiph)) +(terminal-width 1000000) (define-public libusb (package @@ -601,3 +608,87 @@ HID-Class devices.") (define-public python2-hidapi (package-with-python2 python-hidapi)) + +(define-public usb-modeswitch-data + (package + (name "usb-modeswitch-data") + (version "20170806") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-data-" version ".tar.bz2")) + (sha256 + (base32 + "0b1wari3aza6qjggqd0hk2zsh93k1q8scgmwh6f8wr0flpr3whff")))) + (build-system trivial-build-system) + (arguments + `(#:modules ((guix build utils)) + #:builder + (begin + (let ((share-dir (string-append %output "/share"))) + (install-file + (string-append (assoc-ref %build-inputs "source") + "/usb_modeswitch.d") + share-dir)) + #t))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Data package for USB_ModeSwitch") + (description "Device data collection and UDEV rules file for +USB_ModeSwitch.") + (license license:gpl2+))) + +(define-public usb-modeswitch + (package + (name "usb-modeswitch") + (version "2.5.2") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-" version ".tar.bz2")) + (sha256 + (base32 + "19ifi80g9ns5dmspchjvfj4ykxssq9yrci8m227dgb3yr04srzxb")))) + (native-inputs + `(("pkg-config" ,pkg-config))) + (inputs `(("libusb" ,libusb) + ("tcl" ,(error tcl:tcl)))) + (propagated-inputs `(("usb-modeswitch-data" ,usb-modeswitch-data))) + (outputs '("out" "dispatcher")) + (build-system gnu-build-system) + (arguments + `(#:tests? #f ; does not support `make check` + #:make-flags (list "CC=gcc") + #:phases + (modify-phases %standard-phases + (delete 'configure) ; no configure script + (replace 'install + (lambda _ ; calling make would use usr as PREFIX + (let* ((source (assoc-ref %build-inputs "source")) + (out (assoc-ref %outputs "out")) + (bin (string-append out "/bin")) + (man1 (string-append out "/share/man/man1")) + (dispatcher-out (assoc-ref %outputs "dispatcher")) + (etc (string-append dispatcher-out "/etc")) + (dispatcher-bin (string-append dispatcher-out "/bin"))) + (begin + (install-file "usb_modeswitch" bin) + (install-file "usb_modeswitch.1" man1) + (install-file "usb_modeswitch.conf" etc) + (rename-file "usb_modeswitch.tcl" "usb_modeswitch_dispatcher") + (substitute* "usb_modeswitch_dispatcher" + (("!/usr/bin/tclsh") + (string-append (assoc-ref %build-inputs "tcl") + "/bin/tclsh"))) + (install-file "usb_modeswitch_dispatcher" + dispatcher-bin)))))))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Mode switching tool for controlling 'multi-mode' USB devices") + (description "USB_ModeSwitch is a mode switching tool for controlling USB +devices with multiple \"modes\". When plugged in for the first time many USB +devices (primarily high-speed WAN modems) act like a flash storage containing +installers for Windows drivers. USB_ModeSwitch replays the sequence the +Windows drivers would send to switch their mode from storage to modem (or +whatever the thing is supposed to do).") + (license license:gpl2+))) -- 2.21.0 ^ permalink raw reply related [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-13 20:57 ` pelzflorian (Florian Pelz) @ 2019-05-13 21:04 ` pelzflorian (Florian Pelz) 2019-05-14 7:22 ` pelzflorian (Florian Pelz) 2019-05-14 8:35 ` Danny Milosavljevic 2019-05-14 20:48 ` Ludovic Courtès 2019-05-15 11:17 ` pelzflorian (Florian Pelz) 2 siblings, 2 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-13 21:04 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 On Mon, May 13, 2019 at 10:57:20PM +0200, pelzflorian (Florian Pelz) wrote: > Also attached is my current work-in-progress package for > USB_ModeSwitch. It does *not* work because I cannot figure out how to > use tcl in the package’s inputs field. > > #:use-module gives me errors; only (@ (gnu packages tcl) tcl) appears > to work. > I uploaded + (inputs `(("libusb" ,libusb) + ("tcl" ,(error tcl:tcl)))) This was a mistake, I mean + (inputs `(("libusb" ,libusb) + ("tcl" tcl:tcl))) It still gives me errors when used: florian@florianmacbook ~/git/guix [env]$ ./pre-inst-env guix install usb-modeswitch:dispatcher usb-modeswitch Backtrace: 18 (apply-smob/1 #<catch-closure 7aa0a0>) In ice-9/boot-9.scm: 705:2 17 (call-with-prompt _ _ #<procedure default-prompt-handler (k proc)>) In ice-9/eval.scm: 619:8 16 (_ #(#(#<directory (guile-user) 893140>))) In guix/ui.scm: 1747:12 15 (run-guix-command _ . _) In ice-9/boot-9.scm: 829:9 14 (catch _ _ #<procedure 7fd151e1a910 at guix/ui.scm:703:2 (key c)> _) 829:9 13 (catch _ _ #<procedure 7fd151e1a928 at guix/ui.scm:826:6 (key proc format-string format-args . rest)> _) In guix/scripts/package.scm: 915:10 12 (_) In guix/status.scm: 768:4 11 (call-with-status-report _ _) In guix/scripts/package.scm: 923:14 10 (_) 882:6 9 (process-actions #<store-connection 256.99 cfeea0> _) In guix/ui.scm: 1096:4 8 (show-manifest-transaction #<store-connection 256.99 cfeea0> _ _ #:dry-run? _) In srfi/srfi-1.scm: 628:19 7 (mapn ("usb-modeswitch" "usb-modeswitch") (("2.5.2" "2.5.2") ("dispatcher" "out") (#<package usb-modeswitch@2.5.2 gnu/packages/libusb.scm:642 174c8f0> #<package usb-modeswitch@2.5.2 gnu/packages/libusb.scm:642 174c8f0>)) 2) In guix/ui.scm: 1101:23 6 (_ "usb-modeswitch" "2.5.2" "dispatcher" #<package usb-modeswitch@2.5.2 gnu/packages/libusb.scm:642 174c8f0>) In guix/packages.scm: 1296:13 5 (package-output #<store-connection 256.99 cfeea0> #<package usb-modeswitch@2.5.2 gnu/packages/libusb.scm:642 174c8f0> _ _) 936:16 4 (cache! #<weak-table 178/223> #<package usb-modeswitch@2.5.2 gnu/packages/libusb.scm:642 174c8f0> ("x86_64-linux" . #t) _) 1254:22 3 (thunk) 936:16 2 (cache! #<weak-table 178/223> #<package usb-modeswitch@2.5.2 gnu/packages/libusb.scm:642 174c8f0> ("x86_64-linux" #f #t) _) 1042:46 1 (thunk) In gnu/packages/libusb.scm: 655:12 0 (inputs _) gnu/packages/libusb.scm:655:12: In procedure inputs: error: tcl:tcl: unbound variable Regards, Florian ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-13 21:04 ` pelzflorian (Florian Pelz) @ 2019-05-14 7:22 ` pelzflorian (Florian Pelz) 2019-05-14 8:35 ` Danny Milosavljevic 1 sibling, 0 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-14 7:22 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 On Mon, May 13, 2019 at 11:04:43PM +0200, pelzflorian (Florian Pelz) wrote: > gnu/packages/libusb.scm:655:12: In procedure inputs: > error: tcl:tcl: unbound variable > This tcl:tcl gets resolved all right elsewhere in the libusb.scm file. There must be something special about <package> definitions or their inputs. Regards, Florian ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-13 21:04 ` pelzflorian (Florian Pelz) 2019-05-14 7:22 ` pelzflorian (Florian Pelz) @ 2019-05-14 8:35 ` Danny Milosavljevic 2019-05-14 20:56 ` pelzflorian (Florian Pelz) 1 sibling, 1 reply; 39+ messages in thread From: Danny Milosavljevic @ 2019-05-14 8:35 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 1059 bytes --] Hi Florian, On Mon, 13 May 2019 23:04:43 +0200 "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> wrote: > On Mon, May 13, 2019 at 10:57:20PM +0200, pelzflorian (Florian Pelz) wrote: > > Also attached is my current work-in-progress package for > > USB_ModeSwitch. It does *not* work because I cannot figure out how to > > use tcl in the package’s inputs field. > > > > #:use-module gives me errors; only (@ (gnu packages tcl) tcl) appears > > to work. The problem is there's a use-modules cycle somewhere. > I uploaded > > + (inputs `(("libusb" ,libusb) > + ("tcl" ,(error tcl:tcl)))) > > This was a mistake, I mean > > + (inputs `(("libusb" ,libusb) > + ("tcl" tcl:tcl))) Should be (inputs `(("libusb" ,libusb) ("tcl" ,tcl:tcl))) But I guess you meant that anyway. The problem is there's a use-modules cycle somewhere. Try putting usb-modeswitch in another module (a new one if necessary). Also, does it really require tcl? Sounds kinda weird to me. [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-14 8:35 ` Danny Milosavljevic @ 2019-05-14 20:56 ` pelzflorian (Florian Pelz) 2019-05-15 13:01 ` Ludovic Courtès 0 siblings, 1 reply; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-14 20:56 UTC (permalink / raw) To: Danny Milosavljevic; +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 1924 bytes --] On Tue, May 14, 2019 at 10:35:55AM +0200, Danny Milosavljevic wrote: > Should be > > (inputs `(("libusb" ,libusb) > ("tcl" ,tcl:tcl))) > Yes I did mean that with comma, sorry. > But I guess you meant that anyway. > > The problem is there's a use-modules cycle somewhere. > Try putting usb-modeswitch in another module (a new one if necessary). > Using a new module helps, thank you! Now I also do not need a prefix tcl: anymore. @Ludo: without that prefix, I got errors because 'zip was redefined or something, I do not remember now. Now only packaging issues remain. When I use trivial-build-system, #:builder (begin (use-modules (guix build utils) (guix packages)) (let ((source (assoc-ref %build-inputs "source")) (tar (assoc-ref %build-inputs "tar")) (bzip2 (assoc-ref %build-inputs "bzip2")) (share-dir (string-append %output "/share"))) (copy-file source "data.tar.bz2") (invoke (string-append bzip2 "/bin/bzip2") "-d" "data.tar.bz2") (invoke (string-append tar "/bin/tar") "xvf" "data.tar") (install-file (string-append "usb-modeswitch-data-" (package-version this-package) "/usb_modeswitch.d") share-dir)) #t))) this package-version call seems not to work (at least not without more adding more modules). Is this the right approach? Also I forgot, do I need this #t at the end? > Also, does it really require tcl? Sounds kinda weird to me. TCL is not needed for command-line mode switching, but there is a TCL script called usb_modeswitch_dispatcher that gets called by the UDEV rule and by the systemd service file shipped with USB_ModeSwitch. This dispatcher automatically modeswitches USB devices that are plugged in, I believe. Regards, Florian [-- Attachment #2: 0001-Add-USB_ModeSwitch.patch --] [-- Type: text/plain, Size: 6265 bytes --] From 3430070606904b6dc6b247a6b8bfb2ce7c4fce0f Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Tue, 14 May 2019 12:36:24 +0200 Subject: [PATCH] Add USB_ModeSwitch. * gnu/packages/usb-modeswitch.scm (usb-modeswitch-data) Add it. (usb-modeswitch) Add it. --- gnu/packages/usb-modeswitch.scm | 122 ++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 gnu/packages/usb-modeswitch.scm diff --git a/gnu/packages/usb-modeswitch.scm b/gnu/packages/usb-modeswitch.scm new file mode 100644 index 0000000000..f3708c44ab --- /dev/null +++ b/gnu/packages/usb-modeswitch.scm @@ -0,0 +1,122 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Florian Pelz <pelzflorian@pelzflorian.de> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (gnu packages libusb) +;; #:use-module (gnu packages) + #:use-module ((guix licenses) #:prefix license:) + ;; #:use-module (guix packages) + #:use-module (guix build-system trivial) + #:use-module (gnu packages base) + #:use-module (gnu packages compression) + #:use-module (gnu packages libusb) + #:use-module (gnu packages tcl)) + +(define-public usb-modeswitch-data + (package + (name "usb-modeswitch-data") + (version "20170806") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-data-" version ".tar.bz2")) + (sha256 + (base32 + "0b1wari3aza6qjggqd0hk2zsh93k1q8scgmwh6f8wr0flpr3whff")))) + (build-system trivial-build-system) + (arguments + `(#:modules ((guix build utils) + (guix packages)) + #:builder + (begin + (use-modules (guix build utils) + (guix packages)) + (let ((source (assoc-ref %build-inputs "source")) + (tar (assoc-ref %build-inputs "tar")) + (bzip2 (assoc-ref %build-inputs "bzip2")) + (share-dir (string-append %output "/share"))) + (copy-file source "data.tar.bz2") + (invoke (string-append bzip2 "/bin/bzip2") "-d" "data.tar.bz2") + (invoke (string-append tar "/bin/tar") "xvf" "data.tar") + (install-file (string-append "usb-modeswitch-data-" + (package-version this-package) + "/usb_modeswitch.d") share-dir)) + #t))) + (native-inputs `(("tar" ,tar) + ("bzip2" ,bzip2))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Data package for USB_ModeSwitch") + (description "Device data collection and UDEV rules file for +USB_ModeSwitch.") + (license license:gpl2+))) + +(define-public usb-modeswitch + (package + (name "usb-modeswitch") + (version "2.5.2") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-" version ".tar.bz2")) + (sha256 + (base32 + "19ifi80g9ns5dmspchjvfj4ykxssq9yrci8m227dgb3yr04srzxb")))) + (native-inputs + `(("pkg-config" ,pkg-config))) + (inputs `(("libusb" ,libusb) + ("tcl" ,tcl))) + (propagated-inputs `(("usb-modeswitch-data" ,usb-modeswitch-data))) + (outputs '("out" "dispatcher")) + (build-system gnu-build-system) + (arguments + `(#:tests? #f ; does not support `make check` + #:make-flags (list "CC=gcc") + #:phases + (modify-phases %standard-phases + (delete 'configure) ; no configure script + (replace 'install + (lambda _ ; calling make would use usr as PREFIX + (let* ((source (assoc-ref %build-inputs "source")) + (out (assoc-ref %outputs "out")) + (bin (string-append out "/bin")) + (man1 (string-append out "/share/man/man1")) + (dispatcher-out (assoc-ref %outputs "dispatcher")) + (etc (string-append dispatcher-out "/etc")) + (dispatcher-bin (string-append dispatcher-out "/bin"))) + (begin +;; (use-modules (guix build utils)) + (install-file "usb_modeswitch" bin) + (install-file "usb_modeswitch.1" man1) + (install-file "usb_modeswitch.conf" etc) + (rename-file "usb_modeswitch.tcl" "usb_modeswitch_dispatcher") + (substitute* "usb_modeswitch_dispatcher" + (("!/usr/bin/tclsh") + (string-append (assoc-ref %build-inputs "tcl") + "/bin/tclsh"))) + (install-file "usb_modeswitch_dispatcher" + dispatcher-bin)))))))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Mode switching tool for controlling 'multi-mode' USB devices") + (description "USB_ModeSwitch is a mode switching tool for controlling USB +devices with multiple \"modes\". When plugged in for the first time many USB +devices (primarily high-speed WAN modems) act like a flash storage containing +installers for Windows drivers. USB_ModeSwitch replays the sequence the +Windows drivers would send to switch their mode from storage to modem (or +whatever the thing is supposed to do).") + (license license:gpl2+))) -- 2.21.0 ^ permalink raw reply related [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-14 20:56 ` pelzflorian (Florian Pelz) @ 2019-05-15 13:01 ` Ludovic Courtès 2019-05-15 14:40 ` pelzflorian (Florian Pelz) 2019-05-22 16:29 ` pelzflorian (Florian Pelz) 0 siblings, 2 replies; 39+ messages in thread From: Ludovic Courtès @ 2019-05-15 13:01 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 Hi, "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > On Tue, May 14, 2019 at 10:35:55AM +0200, Danny Milosavljevic wrote: [...] >> The problem is there's a use-modules cycle somewhere. >> Try putting usb-modeswitch in another module (a new one if necessary). >> > > Using a new module helps, thank you! Now I also do not need a prefix > tcl: anymore. @Ludo: without that prefix, I got errors because 'zip > was redefined or something, I do not remember now. That could be a collision with ‘zip’ from (srfi srfi-1) or with ‘zlib’ from (guix licenses), which can both be worked around by doing something along these lines: #:use-module ((srfi srfi-1) #:hide (zip)) > Now only packaging issues remain. When I use trivial-build-system, > > #:builder > (begin > (use-modules (guix build utils) > (guix packages)) > (let ((source (assoc-ref %build-inputs "source")) > (tar (assoc-ref %build-inputs "tar")) > (bzip2 (assoc-ref %build-inputs "bzip2")) > (share-dir (string-append %output "/share"))) > (copy-file source "data.tar.bz2") > (invoke (string-append bzip2 "/bin/bzip2") "-d" "data.tar.bz2") > (invoke (string-append tar "/bin/tar") "xvf" "data.tar") > (install-file (string-append "usb-modeswitch-data-" > (package-version this-package) ^ You’re missing a comma (“unquote”) so that ‘package-version’ is called on the host side; it doesn’t exist on the build side. > "/usb_modeswitch.d") share-dir)) > #t))) #t is unnecessary here. > From 3430070606904b6dc6b247a6b8bfb2ce7c4fce0f Mon Sep 17 00:00:00 2001 > From: Florian Pelz <pelzflorian@pelzflorian.de> > Date: Tue, 14 May 2019 12:36:24 +0200 > Subject: [PATCH] Add USB_ModeSwitch. > > * gnu/packages/usb-modeswitch.scm (usb-modeswitch-data) Add it. > (usb-modeswitch) Add it. Just “New file”. Make sure to add the file to gnu/local.mk please. > +(define-module (gnu packages libusb) Please adjust the module name: it should be ‘usb-modeswitch’. > + (synopsis "Data package for USB_ModeSwitch") > + (description "Device data collection and UDEV rules file for > +USB_ModeSwitch.") Please make it a full sentence, and ideally expound a bit (info "(guix) Synopses and Descriptions"). > +;; (use-modules (guix build utils)) Make sure to remove any leftovers like this comment before sending the next version. :-) > + (replace 'install > + (lambda _ ; calling make would use usr as PREFIX > + (let* ((source (assoc-ref %build-inputs "source")) > + (out (assoc-ref %outputs "out")) > + (bin (string-append out "/bin")) Please don’t refer to global variables ‘%outputs’ and ‘%build-inputs’. Instead, take them from the phase’s arguments: (lambda* (#:key source outputs inputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out"))) …)) > + (install-file "usb_modeswitch_dispatcher" > + dispatcher-bin)))))))) The phase must return #t. > + (synopsis "Mode switching tool for controlling 'multi-mode' USB devices") Probably `multi-mode', as expected in Texinfo. > + (description "USB_ModeSwitch is a mode switching tool for controlling USB > +devices with multiple \"modes\". When plugged in for the first time many USB … and @dfn{modes} Could you send an updated patch? Is USB_ModeSwitch needed for proper use of ModemManager? I’d say “no” but I’m unsure. Thanks for working on it! Ludo’. ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-15 13:01 ` Ludovic Courtès @ 2019-05-15 14:40 ` pelzflorian (Florian Pelz) 2019-05-22 16:29 ` pelzflorian (Florian Pelz) 1 sibling, 0 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-15 14:40 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 On Wed, May 15, 2019 at 03:01:04PM +0200, Ludovic Courtès wrote: > Could you send an updated patch? > Thank you very much! Will do later, today or tomorrow. > Is USB_ModeSwitch needed for proper use of ModemManager? I’d say “no” > but I’m unsure. > Only on some modems. > Thanks for working on it! > > Ludo’. :) Regards, Florian ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-15 13:01 ` Ludovic Courtès 2019-05-15 14:40 ` pelzflorian (Florian Pelz) @ 2019-05-22 16:29 ` pelzflorian (Florian Pelz) 2019-05-22 17:58 ` pelzflorian (Florian Pelz) 2019-05-24 15:37 ` Ludovic Courtès 1 sibling, 2 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-22 16:29 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 4441 bytes --] Thank you for your thorough review. Find attached a new version of the patch. I can now modeswitch my USB modem by doing ./pre-inst-env guix install usb-modeswitch:dispatcher sudo usb_modeswitch -c ~/.guix-profile/share/usb_modeswitch.d/12d1\:14fe -v 0x12d1 -p 0x14fe Tring to put the packages in gnu/packages/libusb.scm and not in their own file gnu/packages/usb-modeswitch.scm again resulted in [ 11%] LOAD guix/scripts/search.scm [ 11%] LOAD guix/scripts/gc.scm [ 11%] LOAD guix/scripts/hash.scm [ 11%] LOAD guix/scripts/pack.scm Backtrace: In ice-9/boot-9.scm: 222:29 19 (map1 (((guix utils)) ((guix store)) ((guix #) # (#)) …)) 222:29 18 (map1 (((guix store)) ((guix status) #:select (#)) (#) …)) 222:29 17 (map1 (((guix status) #:select (#)) ((guix grafts)) # …)) 222:29 16 (map1 (((guix grafts)) ((guix monads)) ((guix #)) (#) …)) 222:29 15 (map1 (((guix monads)) ((guix modules)) ((guix #)) (#) …)) 222:29 14 (map1 (((guix modules)) ((guix packages)) ((guix #)) # …)) 222:29 13 (map1 (((guix packages)) ((guix profiles)) ((guix #)) …)) 222:29 12 (map1 (((guix profiles)) ((guix describe)) ((guix #)) …)) 222:29 11 (map1 (((guix describe)) ((guix derivations)) ((# #)) …)) 222:29 10 (map1 (((guix derivations)) ((guix search-paths)) (#) …)) 222:29 9 (map1 (((guix search-paths)) ((guix build-system #)) # …)) 222:29 8 (map1 (((guix build-system gnu)) ((guix scripts #)) # …)) 222:29 7 (map1 (((guix scripts build)) ((guix self) #:select …) …)) 222:29 6 (map1 (((guix self) #:select (make-config.scm)) ((…)) …)) 222:29 5 (map1 (((gnu packages)) ((gnu packages bootstrap)) (…) …)) 222:29 4 (map1 (((gnu packages bootstrap)) ((gnu packages …) …) …)) 222:17 3 (map1 (((gnu packages compression) #:hide (zip)) ((…)) …)) 2830:10 2 (resolve-interface (gnu packages compression) #:select _ …) 260:13 1 (for-each #<procedure 52470e0 at ice-9/boot-9.scm:2830…> …) In unknown file: 0 (scm-error misc-error #f "~A" ("no binding `zip' to h…") …) ERROR: In procedure scm-error: no binding `zip' to hide in module (gnu packages compression) when running make. Then I rebuilt and commented and uncommented and moved some code and putting the code in gnu/packages/libusb.scm worked again in ./pre-inst-env. Later it failed again. Danny speculated the reason was a use-module cycle. I would like confirmation that this is what a use-module cycle looks like and that I should stop trying to put usb-modeswitch back in gnu/packages/libusb.scm. As for the packaging, I hope it is correct to still refer to %outputs in the trivial-build-system for usb-modeswitch-data. Should I also make the usb-modeswitch-data package install the license file of usb-modeswitch-data? Or should I use gnu-build-system instead of trivial-build-system? trivial works now though. The file dispatcher.c of usb-modeswitch is licensed bsd-2 and not gpl2+. Should I list both licenses or just gpl2+? I have checked the license of the files of usb-modeswitch-data and usb-modeswitch by going through each of them with the `less` program and reading its header while assuming that no license header means the file has the license described in the README file, by diff’ing the license files with a license downloaded from gnu.org, and that nothing looked like a program blob (there only are very small hex strings for the messages USB_ModeSwitch sends like MessageContent="55534243123456782400000080000612000024000000000000000000000000" that seem harmless). Is this the usual procedure? Currently I also install the UDEV rule shipped with usb-modeswitch-data; I hope this is correct. Currently I install the usb_modeswitch_dispatcher that is needed by the udev rule in a separate output called “dispatcher”. I am unsure if this usb_modeswitch_dispatcher would need the usb_modeswitch program from the “out” output. Is it OK when one output only works when the “out” output is installed too? What is still missing is adding a service type for usb-modeswitch that extends the udev service type by the rules file and that calls the usb-modeswitch dispatcher once every reboot. I can try making one, but I am not sure if this is the right approach. I am also unsure if this service should be part of %desktop-services; many modems need it though and modem-manager-service-type. Regards, Florian [-- Attachment #2: 0001-gnu-Add-USB_ModeSwitch.patch --] [-- Type: text/plain, Size: 7368 bytes --] From af86ed879ecfc6ef5970ceff638a9303af497b14 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Wed, 22 May 2019 18:16:26 +0200 Subject: [PATCH] gnu: Add USB_ModeSwitch. * gnu/packages/usb-modeswitch.scm: New file. --- gnu/local.mk | 1 + gnu/packages/usb-modeswitch.scm | 133 ++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 gnu/packages/usb-modeswitch.scm diff --git a/gnu/local.mk b/gnu/local.mk index cfc16c5ac8..7f834c374f 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -466,6 +466,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/uml.scm \ %D%/packages/unrtf.scm \ %D%/packages/upnp.scm \ + %D%/packages/usb-modeswitch.scm \ %D%/packages/uucp.scm \ %D%/packages/valgrind.scm \ %D%/packages/version-control.scm \ diff --git a/gnu/packages/usb-modeswitch.scm b/gnu/packages/usb-modeswitch.scm new file mode 100644 index 0000000000..c43f7c46bd --- /dev/null +++ b/gnu/packages/usb-modeswitch.scm @@ -0,0 +1,133 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Florian Pelz <pelzflorian@pelzflorian.de> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (gnu packages usb-modeswitch) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix build-system gnu) + #:use-module (guix build-system trivial) + #:use-module (gnu packages base) + #:use-module (gnu packages compression) + #:use-module (gnu packages embedded) + #:use-module (gnu packages libusb) + #:use-module (gnu packages pkg-config)) + +(define-public usb-modeswitch-data + (package + (name "usb-modeswitch-data") + (version "20170806") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-data-" version ".tar.bz2")) + (sha256 + (base32 + "0b1wari3aza6qjggqd0hk2zsh93k1q8scgmwh6f8wr0flpr3whff")))) + (build-system trivial-build-system) + (native-inputs `(("tar" ,tar) + ("bzip2" ,bzip2))) + (arguments + `(#:modules ((guix build utils)) + #:builder + (begin + (use-modules (guix build utils)) + (let ((source (assoc-ref %build-inputs "source")) + (tar (assoc-ref %build-inputs "tar")) + (bzip2 (assoc-ref %build-inputs "bzip2")) + (files (string-append "usb-modeswitch-data-" + ,(package-version this-package))) + (share-dir (string-append %output "/share")) + (udev-dir (string-append %output "/udev"))) + (copy-file source "data.tar.bz2") + (invoke (string-append bzip2 "/bin/bzip2") "-d" "data.tar.bz2") + (invoke (string-append tar "/bin/tar") "xvf" "data.tar") + (copy-recursively (string-append files "/usb_modeswitch.d") + (string-append share-dir "/usb_modeswitch.d")) + (install-file (string-append files "/40-usb_modeswitch.rules") + udev-dir))))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Data package for USB_ModeSwitch") + (description "This packages contains data about devices and a UDEV rules +file for use with USB_ModeSwitch.") + (license license:gpl2+))) + +(define-public usb-modeswitch + (package + (name "usb-modeswitch") + (version "2.5.2") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-" version ".tar.bz2")) + (sha256 + (base32 + "19ifi80g9ns5dmspchjvfj4ykxssq9yrci8m227dgb3yr04srzxb")) + (modules '((guix build utils))) + (snippet + ;; Remove bundled jimtcl. + '(begin + (delete-file-recursively "jim") + #t)))) + (native-inputs `(("pkg-config" ,pkg-config))) + (inputs `(("libusb" ,libusb) + ("jimtcl" ,jimtcl))) + (propagated-inputs `(("usb-modeswitch-data" ,usb-modeswitch-data))) + (outputs '("out" "dispatcher")) + (build-system gnu-build-system) + (arguments + `(#:tests? #f ; does not support `make check` + #:make-flags (list "CC=gcc") + #:phases + (modify-phases %standard-phases + (delete 'configure) ; no configure script + (replace 'install ; calling make would use usr as PREFIX + (lambda* (#:key source outputs inputs #:allow-other-keys) + (let* ((source (assoc-ref inputs "source")) + (jimtcl (assoc-ref inputs "jimtcl")) + (out (assoc-ref outputs "out")) + (bin (string-append out "/bin")) + (man1 (string-append out "/share/man/man1")) + (dispatcher-out (assoc-ref outputs "dispatcher")) + (etc (string-append dispatcher-out "/etc")) + (dispatcher-bin (string-append dispatcher-out "/bin")) + (dispatcher-man1 (string-append dispatcher-out + "/share/man/man1"))) + (begin + (install-file "usb_modeswitch" bin) + (install-file "usb_modeswitch.conf" etc) + (install-file "usb_modeswitch.1" man1) + (install-file "usb_modeswitch_dispatcher.1" dispatcher-man1) + (rename-file "usb_modeswitch.tcl" "usb_modeswitch_dispatcher") + (substitute* "usb_modeswitch_dispatcher" + (("!/usr/bin/tclsh") + (string-append "!" jimtcl "/bin/jimsh"))) + (install-file "usb_modeswitch_dispatcher" + dispatcher-bin) + #t))))))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Mode switching tool for controlling `multi-mode' USB devices") + (description "USB_ModeSwitch is a mode switching tool for controlling USB +devices with multiple @dfn{modes}. When plugged in for the first time many +USB devices (primarily high-speed WAN modems) act like a flash storage +containing installers for Windows drivers. USB_ModeSwitch replays the +sequence the Windows drivers would send to switch their mode from storage to +modem (or whatever the thing is supposed to do).") + (license license:gpl2+))) -- 2.21.0 ^ permalink raw reply related [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-22 16:29 ` pelzflorian (Florian Pelz) @ 2019-05-22 17:58 ` pelzflorian (Florian Pelz) 2019-05-24 15:37 ` Ludovic Courtès 1 sibling, 0 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-22 17:58 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 119 bytes --] I forgot to mention gnu/local.mk in the commit message. Please use this patch attached here instead. Regards, Florian [-- Attachment #2: 0001-gnu-Add-USB_ModeSwitch.patch --] [-- Type: text/plain, Size: 7413 bytes --] From 854198efebbe91feea2fbb3ab2a94c26014f1699 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Wed, 22 May 2019 19:53:58 +0200 Subject: [PATCH] gnu: Add USB_ModeSwitch. * gnu/packages/usb-modeswitch.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. --- gnu/local.mk | 1 + gnu/packages/usb-modeswitch.scm | 133 ++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 gnu/packages/usb-modeswitch.scm diff --git a/gnu/local.mk b/gnu/local.mk index cfc16c5ac8..7f834c374f 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -466,6 +466,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/uml.scm \ %D%/packages/unrtf.scm \ %D%/packages/upnp.scm \ + %D%/packages/usb-modeswitch.scm \ %D%/packages/uucp.scm \ %D%/packages/valgrind.scm \ %D%/packages/version-control.scm \ diff --git a/gnu/packages/usb-modeswitch.scm b/gnu/packages/usb-modeswitch.scm new file mode 100644 index 0000000000..c43f7c46bd --- /dev/null +++ b/gnu/packages/usb-modeswitch.scm @@ -0,0 +1,133 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Florian Pelz <pelzflorian@pelzflorian.de> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (gnu packages usb-modeswitch) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix build-system gnu) + #:use-module (guix build-system trivial) + #:use-module (gnu packages base) + #:use-module (gnu packages compression) + #:use-module (gnu packages embedded) + #:use-module (gnu packages libusb) + #:use-module (gnu packages pkg-config)) + +(define-public usb-modeswitch-data + (package + (name "usb-modeswitch-data") + (version "20170806") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-data-" version ".tar.bz2")) + (sha256 + (base32 + "0b1wari3aza6qjggqd0hk2zsh93k1q8scgmwh6f8wr0flpr3whff")))) + (build-system trivial-build-system) + (native-inputs `(("tar" ,tar) + ("bzip2" ,bzip2))) + (arguments + `(#:modules ((guix build utils)) + #:builder + (begin + (use-modules (guix build utils)) + (let ((source (assoc-ref %build-inputs "source")) + (tar (assoc-ref %build-inputs "tar")) + (bzip2 (assoc-ref %build-inputs "bzip2")) + (files (string-append "usb-modeswitch-data-" + ,(package-version this-package))) + (share-dir (string-append %output "/share")) + (udev-dir (string-append %output "/udev"))) + (copy-file source "data.tar.bz2") + (invoke (string-append bzip2 "/bin/bzip2") "-d" "data.tar.bz2") + (invoke (string-append tar "/bin/tar") "xvf" "data.tar") + (copy-recursively (string-append files "/usb_modeswitch.d") + (string-append share-dir "/usb_modeswitch.d")) + (install-file (string-append files "/40-usb_modeswitch.rules") + udev-dir))))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Data package for USB_ModeSwitch") + (description "This packages contains data about devices and a UDEV rules +file for use with USB_ModeSwitch.") + (license license:gpl2+))) + +(define-public usb-modeswitch + (package + (name "usb-modeswitch") + (version "2.5.2") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-" version ".tar.bz2")) + (sha256 + (base32 + "19ifi80g9ns5dmspchjvfj4ykxssq9yrci8m227dgb3yr04srzxb")) + (modules '((guix build utils))) + (snippet + ;; Remove bundled jimtcl. + '(begin + (delete-file-recursively "jim") + #t)))) + (native-inputs `(("pkg-config" ,pkg-config))) + (inputs `(("libusb" ,libusb) + ("jimtcl" ,jimtcl))) + (propagated-inputs `(("usb-modeswitch-data" ,usb-modeswitch-data))) + (outputs '("out" "dispatcher")) + (build-system gnu-build-system) + (arguments + `(#:tests? #f ; does not support `make check` + #:make-flags (list "CC=gcc") + #:phases + (modify-phases %standard-phases + (delete 'configure) ; no configure script + (replace 'install ; calling make would use usr as PREFIX + (lambda* (#:key source outputs inputs #:allow-other-keys) + (let* ((source (assoc-ref inputs "source")) + (jimtcl (assoc-ref inputs "jimtcl")) + (out (assoc-ref outputs "out")) + (bin (string-append out "/bin")) + (man1 (string-append out "/share/man/man1")) + (dispatcher-out (assoc-ref outputs "dispatcher")) + (etc (string-append dispatcher-out "/etc")) + (dispatcher-bin (string-append dispatcher-out "/bin")) + (dispatcher-man1 (string-append dispatcher-out + "/share/man/man1"))) + (begin + (install-file "usb_modeswitch" bin) + (install-file "usb_modeswitch.conf" etc) + (install-file "usb_modeswitch.1" man1) + (install-file "usb_modeswitch_dispatcher.1" dispatcher-man1) + (rename-file "usb_modeswitch.tcl" "usb_modeswitch_dispatcher") + (substitute* "usb_modeswitch_dispatcher" + (("!/usr/bin/tclsh") + (string-append "!" jimtcl "/bin/jimsh"))) + (install-file "usb_modeswitch_dispatcher" + dispatcher-bin) + #t))))))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Mode switching tool for controlling `multi-mode' USB devices") + (description "USB_ModeSwitch is a mode switching tool for controlling USB +devices with multiple @dfn{modes}. When plugged in for the first time many +USB devices (primarily high-speed WAN modems) act like a flash storage +containing installers for Windows drivers. USB_ModeSwitch replays the +sequence the Windows drivers would send to switch their mode from storage to +modem (or whatever the thing is supposed to do).") + (license license:gpl2+))) -- 2.21.0 ^ permalink raw reply related [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-22 16:29 ` pelzflorian (Florian Pelz) 2019-05-22 17:58 ` pelzflorian (Florian Pelz) @ 2019-05-24 15:37 ` Ludovic Courtès 2019-05-24 20:12 ` pelzflorian (Florian Pelz) 1 sibling, 1 reply; 39+ messages in thread From: Ludovic Courtès @ 2019-05-24 15:37 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 Hello, "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > Tring to put the packages in gnu/packages/libusb.scm and not in their > own file gnu/packages/usb-modeswitch.scm again resulted in > > [ 11%] LOAD guix/scripts/search.scm > [ 11%] LOAD guix/scripts/gc.scm > [ 11%] LOAD guix/scripts/hash.scm > [ 11%] LOAD guix/scripts/pack.scm > Backtrace: > In ice-9/boot-9.scm: > 222:29 19 (map1 (((guix utils)) ((guix store)) ((guix #) # (#)) …)) > 222:29 18 (map1 (((guix store)) ((guix status) #:select (#)) (#) …)) > 222:29 17 (map1 (((guix status) #:select (#)) ((guix grafts)) # …)) > 222:29 16 (map1 (((guix grafts)) ((guix monads)) ((guix #)) (#) …)) > 222:29 15 (map1 (((guix monads)) ((guix modules)) ((guix #)) (#) …)) > 222:29 14 (map1 (((guix modules)) ((guix packages)) ((guix #)) # …)) > 222:29 13 (map1 (((guix packages)) ((guix profiles)) ((guix #)) …)) > 222:29 12 (map1 (((guix profiles)) ((guix describe)) ((guix #)) …)) > 222:29 11 (map1 (((guix describe)) ((guix derivations)) ((# #)) …)) > 222:29 10 (map1 (((guix derivations)) ((guix search-paths)) (#) …)) > 222:29 9 (map1 (((guix search-paths)) ((guix build-system #)) # …)) > 222:29 8 (map1 (((guix build-system gnu)) ((guix scripts #)) # …)) > 222:29 7 (map1 (((guix scripts build)) ((guix self) #:select …) …)) > 222:29 6 (map1 (((guix self) #:select (make-config.scm)) ((…)) …)) > 222:29 5 (map1 (((gnu packages)) ((gnu packages bootstrap)) (…) …)) > 222:29 4 (map1 (((gnu packages bootstrap)) ((gnu packages …) …) …)) > 222:17 3 (map1 (((gnu packages compression) #:hide (zip)) ((…)) …)) > 2830:10 2 (resolve-interface (gnu packages compression) #:select _ …) > 260:13 1 (for-each #<procedure 52470e0 at ice-9/boot-9.scm:2830…> …) > In unknown file: > 0 (scm-error misc-error #f "~A" ("no binding `zip' to h…") …) > > ERROR: In procedure scm-error: > no binding `zip' to hide in module (gnu packages compression) You cannot use #:hide on (gnu packages …) modules, for unfortunate and obscure reasons. The trick would be to hide the other ‘zip’ binding, the one from (srfi srfi-1). > As for the packaging, I hope it is correct to still refer to %outputs > in the trivial-build-system for usb-modeswitch-data. Yes. > Should I also make the usb-modeswitch-data package install the license > file of usb-modeswitch-data? > > Or should I use gnu-build-system instead of trivial-build-system? > trivial works now though. In general we should install license files. If ‘trivial’ works for you, that’s OK; an additional line to install the license would be welcome, but not blocking. > The file dispatcher.c of usb-modeswitch is licensed bsd-2 and not > gpl2+. Should I list both licenses or just gpl2+? I think it’s enough to mark it as ‘gpl2+’ because, IIUC, the combination of all this is GPLv2+. If you think that needs clarification, you can just add a comment about the ‘license’ field. > I have checked the license of the files of usb-modeswitch-data and > usb-modeswitch by going through each of them with the `less` program > and reading its header while assuming that no license header means the > file has the license described in the README file, by diff’ing the > license files with a license downloaded from gnu.org, and that nothing > looked like a program blob (there only are very small hex strings for > the messages USB_ModeSwitch sends like > > MessageContent="55534243123456782400000080000612000024000000000000000000000000" > > that seem harmless). Is this the usual procedure? Yes. I often just scan a few source file headers, not necessarily all of them, but of course doing an exhaustive search is even better! > Currently I also install the UDEV rule shipped with > usb-modeswitch-data; I hope this is correct. Yep. > Currently I install the usb_modeswitch_dispatcher that is needed by > the udev rule in a separate output called “dispatcher”. I am unsure > if this usb_modeswitch_dispatcher would need the usb_modeswitch > program from the “out” output. Is it OK when one output only works > when the “out” output is installed too? I’d say no. :-) In general, we want “guix install foo:bar” to provide something that Just Works. > What is still missing is adding a service type for usb-modeswitch that > extends the udev service type by the rules file and that calls the > usb-modeswitch dispatcher once every reboot. I can try making one, > but I am not sure if this is the right approach. I am also unsure if > this service should be part of %desktop-services; many modems need it > though and modem-manager-service-type. We’ll see that later. :-) Let me know if you want to send an updated patch if you we should proceed with the one you sent. Thanks! Ludo’. ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-24 15:37 ` Ludovic Courtès @ 2019-05-24 20:12 ` pelzflorian (Florian Pelz) 2019-05-25 11:18 ` pelzflorian (Florian Pelz) 0 siblings, 1 reply; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-24 20:12 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 Thank you for your feedback! On Fri, May 24, 2019 at 05:37:01PM +0200, Ludovic Courtès wrote: > > Tring to put the packages in gnu/packages/libusb.scm and not in their > > own file gnu/packages/usb-modeswitch.scm again resulted in > > > > [ 11%] LOAD guix/scripts/search.scm > > [ 11%] LOAD guix/scripts/gc.scm > > [ 11%] LOAD guix/scripts/hash.scm > > [ 11%] LOAD guix/scripts/pack.scm > > Backtrace: > > In ice-9/boot-9.scm: > > 222:29 19 (map1 (((guix utils)) ((guix store)) ((guix #) # (#)) …)) > > 222:29 18 (map1 (((guix store)) ((guix status) #:select (#)) (#) …)) > > 222:29 17 (map1 (((guix status) #:select (#)) ((guix grafts)) # …)) > > 222:29 16 (map1 (((guix grafts)) ((guix monads)) ((guix #)) (#) …)) > > 222:29 15 (map1 (((guix monads)) ((guix modules)) ((guix #)) (#) …)) > > 222:29 14 (map1 (((guix modules)) ((guix packages)) ((guix #)) # …)) > > 222:29 13 (map1 (((guix packages)) ((guix profiles)) ((guix #)) …)) > > 222:29 12 (map1 (((guix profiles)) ((guix describe)) ((guix #)) …)) > > 222:29 11 (map1 (((guix describe)) ((guix derivations)) ((# #)) …)) > > 222:29 10 (map1 (((guix derivations)) ((guix search-paths)) (#) …)) > > 222:29 9 (map1 (((guix search-paths)) ((guix build-system #)) # …)) > > 222:29 8 (map1 (((guix build-system gnu)) ((guix scripts #)) # …)) > > 222:29 7 (map1 (((guix scripts build)) ((guix self) #:select …) …)) > > 222:29 6 (map1 (((guix self) #:select (make-config.scm)) ((…)) …)) > > 222:29 5 (map1 (((gnu packages)) ((gnu packages bootstrap)) (…) …)) > > 222:29 4 (map1 (((gnu packages bootstrap)) ((gnu packages …) …) …)) > > 222:17 3 (map1 (((gnu packages compression) #:hide (zip)) ((…)) …)) > > 2830:10 2 (resolve-interface (gnu packages compression) #:select _ …) > > 260:13 1 (for-each #<procedure 52470e0 at ice-9/boot-9.scm:2830…> …) > > In unknown file: > > 0 (scm-error misc-error #f "~A" ("no binding `zip' to h…") …) > > > > ERROR: In procedure scm-error: > > no binding `zip' to hide in module (gnu packages compression) > > You cannot use #:hide on (gnu packages …) modules, for unfortunate and > obscure reasons. The trick would be to hide the other ‘zip’ binding, > the one from (srfi srfi-1). > I did not #:hide anything. The error is reported when (or after?) a call to “make” loads guix/scripts/pack.scm (which I have not changed) after putting the packages and required modules into libusb.scm instead of usb-modeswitch.scm. > > Should I also make the usb-modeswitch-data package install the license > > file of usb-modeswitch-data? > > > > Or should I use gnu-build-system instead of trivial-build-system? > > trivial works now though. > > In general we should install license files. If ‘trivial’ works for you, > that’s OK; an additional line to install the license would be welcome, > but not blocking. > I add the license file. > > The file dispatcher.c of usb-modeswitch is licensed bsd-2 and not > > gpl2+. Should I list both licenses or just gpl2+? > > I think it’s enough to mark it as ‘gpl2+’ because, IIUC, the combination > of all this is GPLv2+. If you think that needs clarification, you can > just add a comment about the ‘license’ field. > Since nobody is likely to use the USB_ModeSwitch dispatcher.c without USB_ModeSwitch, I tend to leave it at gpl2+. > > Currently I install the usb_modeswitch_dispatcher that is needed by > > the udev rule in a separate output called “dispatcher”. I am unsure > > if this usb_modeswitch_dispatcher would need the usb_modeswitch > > program from the “out” output. Is it OK when one output only works > > when the “out” output is installed too? > > I’d say no. :-) In general, we want “guix install foo:bar” to provide > something that Just Works. > I will try substitute*ing the dispatcher script to use /gnu/store until it just works. > Let me know if you want to send an updated patch if you we should > proceed with the one you sent. > I will send an updated patch tomorrow with a working ”dispatcher“ output. Regards, Florian ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-24 20:12 ` pelzflorian (Florian Pelz) @ 2019-05-25 11:18 ` pelzflorian (Florian Pelz) 2019-05-25 12:43 ` pelzflorian (Florian Pelz) 2019-05-25 17:44 ` Ludovic Courtès 0 siblings, 2 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-25 11:18 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 1386 bytes --] On Fri, May 24, 2019 at 10:12:10PM +0200, pelzflorian (Florian Pelz) wrote: > I will send an updated patch tomorrow with a working ”dispatcher“ > output. > Please find attached a patch that no longer propagates usb-modeswitch-data from usb-modeswitch. I can now modeswitch my USB modem by running $ ./pre-inst-env guix install usb-modeswitch:dispatcher $ lsmod -v #find bus name and device name of modem […] Bus 001 Device 007: ID 12d1:14fe Huawei Technologies Co., Ltd. Modem (Mass Storage Mode) $ for d in /sys/bus/usb/devices/*/; do echo $d; cat $d/busnum; cat $d/devnum; done […] /sys/bus/usb/devices/1-1/ 1 7 […] $ sudo usb_modeswitch_dispatcher --switch-mode 1-1 --config-file ~/.guix-profile/etc/usb_modeswitch.conf I added the --config-file option since by default usb_modeswitch_dispatcher loads its optional config file from /etc and a future Guix service type for USB_ModeSwitch should be able to pass a config file. The udev rules file in usb-modeswitch-data has lines like: ATTR{idVendor}=="03f0", ATTR{idProduct}=="002a", RUN+="usb_modeswitch '/%k'" Maybe I should substitute these by RUN+="/gnu/store/…-usb-modeswich-2.5.2/usb_modeswitch '/%k'" but this would introduce a cyclic dependency between usb-modeswitch and usb-modeswitch-data. Therefore this rules file should rather be fixed in a future USB_ModeSwitch service type. Regards, Florian [-- Attachment #2: 0001-gnu-Add-USB_ModeSwitch.patch --] [-- Type: text/plain, Size: 8309 bytes --] From de53b666160d82ffe4d16c77601e742e55d7f435 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Sat, 25 May 2019 13:14:02 +0200 Subject: [PATCH] gnu: Add USB_ModeSwitch. * gnu/packages/usb-modeswitch.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. --- gnu/local.mk | 1 + gnu/packages/usb-modeswitch.scm | 150 ++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 gnu/packages/usb-modeswitch.scm diff --git a/gnu/local.mk b/gnu/local.mk index cfc16c5ac8..7f834c374f 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -466,6 +466,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/uml.scm \ %D%/packages/unrtf.scm \ %D%/packages/upnp.scm \ + %D%/packages/usb-modeswitch.scm \ %D%/packages/uucp.scm \ %D%/packages/valgrind.scm \ %D%/packages/version-control.scm \ diff --git a/gnu/packages/usb-modeswitch.scm b/gnu/packages/usb-modeswitch.scm new file mode 100644 index 0000000000..f77b23d7d9 --- /dev/null +++ b/gnu/packages/usb-modeswitch.scm @@ -0,0 +1,150 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Florian Pelz <pelzflorian@pelzflorian.de> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (gnu packages usb-modeswitch) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix build-system gnu) + #:use-module (guix build-system trivial) + #:use-module (gnu packages base) + #:use-module (gnu packages compression) + #:use-module (gnu packages embedded) + #:use-module (gnu packages libusb) + #:use-module (gnu packages pkg-config)) + +(define-public usb-modeswitch-data + (package + (name "usb-modeswitch-data") + (version "20170806") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-data-" version ".tar.bz2")) + (sha256 + (base32 + "0b1wari3aza6qjggqd0hk2zsh93k1q8scgmwh6f8wr0flpr3whff")))) + (build-system trivial-build-system) + (native-inputs `(("tar" ,tar) + ("bzip2" ,bzip2))) + (arguments + `(#:modules ((guix build utils)) + #:builder + (begin + (use-modules (guix build utils)) + (let* ((source (assoc-ref %build-inputs "source")) + (tar (assoc-ref %build-inputs "tar")) + (bzip2 (assoc-ref %build-inputs "bzip2")) + (files (string-append "usb-modeswitch-data-" + ,(package-version this-package))) + (share-dir (string-append %output "/share")) + (doc-dir (string-append share-dir "/doc/")) + (license-dir (string-append doc-dir + (strip-store-file-name %output))) + (udev-dir (string-append %output "/udev"))) + (copy-file source "data.tar.bz2") + (invoke (string-append bzip2 "/bin/bzip2") "-d" "data.tar.bz2") + (invoke (string-append tar "/bin/tar") "xvf" "data.tar") + (copy-recursively (string-append files "/usb_modeswitch.d") + (string-append share-dir "/usb_modeswitch.d")) + (install-file (string-append files "/40-usb_modeswitch.rules") + udev-dir) + (install-file (string-append files "/COPYING") license-dir))))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Data package for USB_ModeSwitch") + (description "This packages contains data about devices and a UDEV rules +file for use with USB_ModeSwitch.") + (license license:gpl2+))) + +(define-public usb-modeswitch + (package + (name "usb-modeswitch") + (version "2.5.2") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-" version ".tar.bz2")) + (sha256 + (base32 + "19ifi80g9ns5dmspchjvfj4ykxssq9yrci8m227dgb3yr04srzxb")) + (modules '((guix build utils))) + (snippet + ;; Remove bundled jimtcl. + '(begin + (delete-file-recursively "jim") + #t)))) + (native-inputs `(("pkg-config" ,pkg-config))) + (inputs `(("libusb" ,libusb) + ("jimtcl" ,jimtcl) + ("usb-modeswitch-data" ,usb-modeswitch-data))) + (outputs '("out" "dispatcher")) + (build-system gnu-build-system) + (arguments + `(#:tests? #f ; does not support `make check` + #:make-flags (list "CC=gcc") + #:phases + (modify-phases %standard-phases + (delete 'configure) ; no configure script + (replace 'install ; calling make would use usr as PREFIX + (lambda* (#:key source outputs inputs #:allow-other-keys) + (let* ((source (assoc-ref inputs "source")) + (jimtcl (assoc-ref inputs "jimtcl")) + (data (assoc-ref inputs "usb-modeswitch-data")) + (out (assoc-ref outputs "out")) + (bin (string-append out "/bin")) + (man1 (string-append out "/share/man/man1")) + (dispatcher-out (assoc-ref outputs "dispatcher")) + (etc (string-append dispatcher-out "/etc")) + (dispatcher-bin (string-append dispatcher-out "/bin")) + (dispatcher-man1 (string-append dispatcher-out + "/share/man/man1"))) + (begin + (install-file "usb_modeswitch" bin) + (install-file "usb_modeswitch.conf" etc) + (install-file "usb_modeswitch.1" man1) + (install-file "usb_modeswitch_dispatcher.1" dispatcher-man1) + (rename-file "usb_modeswitch.tcl" "usb_modeswitch_dispatcher") + (substitute* "usb_modeswitch_dispatcher" + (("!/usr/bin/tclsh") + (string-append "!" jimtcl "/bin/jimsh")) + (("/usr/sbin") bin) + (("/usr/share/usb_modeswitch") + (string-append data "/share/usb_modeswitch.d")) + (("\\[ParseGlobalConfig\\]") ;use config in command line + "[ParseGlobalConfig $argv]") + (("proc \\{ParseGlobalConfig\\} \\{\\}") + "proc {ParseGlobalConfig} {argv}") + (("set configFile \\\"\\\"") + " +if {[lindex $argv 2] == \"--config-file\"} { + set configFile [lindex $argv 3] +}")) + (install-file "usb_modeswitch_dispatcher" + dispatcher-bin) + #t))))))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Mode switching tool for controlling `multi-mode' USB devices") + (description "USB_ModeSwitch is a mode switching tool for controlling USB +devices with multiple @dfn{modes}. When plugged in for the first time many +USB devices (primarily high-speed WAN modems) act like a flash storage +containing installers for Windows drivers. USB_ModeSwitch replays the +sequence the Windows drivers would send to switch their mode from storage to +modem (or whatever the thing is supposed to do).") + (license license:gpl2+))) -- 2.21.0 ^ permalink raw reply related [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-25 11:18 ` pelzflorian (Florian Pelz) @ 2019-05-25 12:43 ` pelzflorian (Florian Pelz) 2019-05-25 17:44 ` Ludovic Courtès 1 sibling, 0 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-25 12:43 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 On Sat, May 25, 2019 at 01:18:56PM +0200, pelzflorian (Florian Pelz) wrote: > I added the --config-file option since by default > usb_modeswitch_dispatcher loads its optional config file from /etc and > a future Guix service type for USB_ModeSwitch should be able to pass a > config file. > […] > + (substitute* "usb_modeswitch_dispatcher" > + (("!/usr/bin/tclsh") > + (string-append "!" jimtcl "/bin/jimsh")) > + (("/usr/sbin") bin) > + (("/usr/share/usb_modeswitch") > + (string-append data "/share/usb_modeswitch.d")) > + (("\\[ParseGlobalConfig\\]") ;use config in command line > + "[ParseGlobalConfig $argv]") > + (("proc \\{ParseGlobalConfig\\} \\{\\}") > + "proc {ParseGlobalConfig} {argv}") > + (("set configFile \\\"\\\"") > + " > +if {[lindex $argv 2] == \"--config-file\"} { > + set configFile [lindex $argv 3] > +}")) Or should I rather use a patch file instead of substitute*? ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-25 11:18 ` pelzflorian (Florian Pelz) 2019-05-25 12:43 ` pelzflorian (Florian Pelz) @ 2019-05-25 17:44 ` Ludovic Courtès 2019-05-25 19:42 ` pelzflorian (Florian Pelz) 2019-06-12 12:13 ` pelzflorian (Florian Pelz) 1 sibling, 2 replies; 39+ messages in thread From: Ludovic Courtès @ 2019-05-25 17:44 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 Hello, "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > Please find attached a patch that no longer propagates > usb-modeswitch-data from usb-modeswitch. I can now modeswitch my USB > modem by running Yay! > The udev rules file in usb-modeswitch-data has lines like: > > ATTR{idVendor}=="03f0", ATTR{idProduct}=="002a", RUN+="usb_modeswitch '/%k'" > > Maybe I should substitute these by > > RUN+="/gnu/store/…-usb-modeswich-2.5.2/usb_modeswitch '/%k'" > > but this would introduce a cyclic dependency between usb-modeswitch > and usb-modeswitch-data. Therefore this rules file should rather be > fixed in a future USB_ModeSwitch service type. Sounds good. Another option would be to install the udev rule as part of the ‘usb-modeswitch’ package, which makes more sense and would solve the problem. But anyway, don’t lose your hair over it. >> + (substitute* "usb_modeswitch_dispatcher" >> + (("!/usr/bin/tclsh") >> + (string-append "!" jimtcl "/bin/jimsh")) I don’t think it’s needed, is it? >> + (("/usr/sbin") bin) >> + (("/usr/share/usb_modeswitch") >> + (string-append data "/share/usb_modeswitch.d")) >> + (("\\[ParseGlobalConfig\\]") ;use config in command line >> + "[ParseGlobalConfig $argv]") >> + (("proc \\{ParseGlobalConfig\\} \\{\\}") >> + "proc {ParseGlobalConfig} {argv}") >> + (("set configFile \\\"\\\"") >> + " >> +if {[lindex $argv 2] == \"--config-file\"} { >> + set configFile [lindex $argv 3] >> +}")) > > > Or should I rather use a patch file instead of substitute*? I think it’s OK like this. It does mean Guix’s ‘usb_modeswitch_dispatcher’ has an option that upstream doesn’t provide. It would be worth proposing it upstream. Thanks! Ludo’. ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-25 17:44 ` Ludovic Courtès @ 2019-05-25 19:42 ` pelzflorian (Florian Pelz) 2019-06-12 10:36 ` pelzflorian (Florian Pelz) 2019-06-12 12:13 ` pelzflorian (Florian Pelz) 1 sibling, 1 reply; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-25 19:42 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 On Sat, May 25, 2019 at 07:44:37PM +0200, Ludovic Courtès wrote: > "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > > The udev rules file in usb-modeswitch-data has lines like: > > > > ATTR{idVendor}=="03f0", ATTR{idProduct}=="002a", RUN+="usb_modeswitch '/%k'" > > > > Maybe I should substitute these by > > > > RUN+="/gnu/store/…-usb-modeswich-2.5.2/usb_modeswitch '/%k'" > > > > but this would introduce a cyclic dependency between usb-modeswitch > > and usb-modeswitch-data. Therefore this rules file should rather be > > fixed in a future USB_ModeSwitch service type. > > Sounds good. Another option would be to install the udev rule as part > of the ‘usb-modeswitch’ package, which makes more sense and would solve > the problem. But anyway, don’t lose your hair over it. > The udev rules file is shipped with usb-modeswitch-data, so I need to install it from usb-modeswitch-data. > >> + (substitute* "usb_modeswitch_dispatcher" > >> + (("!/usr/bin/tclsh") > >> + (string-append "!" jimtcl "/bin/jimsh")) > > I don’t think it’s needed, is it? > Frankly, I am not actually sure if usb_modeswitch_dispatcher is really needed for the USB_ModeSwitch service type. In much earlier (2010) versions of USB_ModeSwitch (<https://web.archive.org/web/20100921062014/http://draisberghof.de/usb_modeswitch/usb-modeswitch-data-20100826.tar.bz2>) the UDEV rules file referred to usb_modeswitch_dispatcher. It does not do so anymore, instead it apparently uses usb_modeswitch directly. I will ask in the USB_ModeSwitch forums tomorrow if the dispatcher is needed. I will also ask about an option for specifying the config file. usb_modeswitch has one, usb_modeswitch_dispatcher does not have the option. Regards, Florian ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-25 19:42 ` pelzflorian (Florian Pelz) @ 2019-06-12 10:36 ` pelzflorian (Florian Pelz) 2019-06-12 10:41 ` pelzflorian (Florian Pelz) 2019-06-12 21:11 ` Ludovic Courtès 0 siblings, 2 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-06-12 10:36 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 1801 bytes --] Find attached patches that make USB modems just work, fixing this bug. I have confirmed that at least on x86_64-linux (service usb-modeswitch-service-type) works with the default config and that (service usb-modeswitch-service-type (usb-modeswitch-configuration (config-file #f))) works, passing no config file, leading to different defaults. Manual use as described in a comment of the usb-modeswitch package works as well. I hope using putenv before wrap-program is OK. I tried using computed-file #:options instead, but could not get it to work. 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 ‘%desktop-services’ (*note Desktop Services::). On Sat, May 25, 2019 at 09:42:15PM +0200, pelzflorian (Florian Pelz) wrote: > Frankly, I am not actually sure if usb_modeswitch_dispatcher is really > needed for the USB_ModeSwitch service type. I am sure, it is needed. > In much earlier (2010) > versions of USB_ModeSwitch > (<https://web.archive.org/web/20100921062014/http://draisberghof.de/usb_modeswitch/usb-modeswitch-data-20100826.tar.bz2>) > the UDEV rules file referred to usb_modeswitch_dispatcher. It does > not do so anymore, instead it apparently uses usb_modeswitch directly. > There are two different executable files called usb_modeswitch. The one used by the UDEV rule runs the dispatcher. > I will ask in the USB_ModeSwitch forums tomorrow if the dispatcher is > needed. I will also ask about an option for specifying the config > file. usb_modeswitch has one, usb_modeswitch_dispatcher does not have > the option. > I have not asked. I will propose the patch after this is commited at Guix. Regards, Florian [-- Attachment #2: 0001-gnu-Add-USB_ModeSwitch.patch --] [-- Type: text/plain, Size: 11336 bytes --] From 7af598d980a43d426c4341b1c581add06fd6ae72 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Wed, 12 Jun 2019 10:24:05 +0200 Subject: [PATCH 1/3] gnu: Add USB_ModeSwitch. * gnu/packages/usb-modeswitch.scm: New file. * gnu/packages/patches/usb-modeswitch-accept-config-arg.patch: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add package. (dist_patch_DATA): Add patch. --- gnu/local.mk | 2 + .../usb-modeswitch-accept-config-arg.patch | 42 +++++ gnu/packages/usb-modeswitch.scm | 166 ++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 gnu/packages/patches/usb-modeswitch-accept-config-arg.patch create mode 100644 gnu/packages/usb-modeswitch.scm diff --git a/gnu/local.mk b/gnu/local.mk index 907641ff3e..7a90b279f6 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -468,6 +468,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/uml.scm \ %D%/packages/unrtf.scm \ %D%/packages/upnp.scm \ + %D%/packages/usb-modeswitch.scm \ %D%/packages/uucp.scm \ %D%/packages/valgrind.scm \ %D%/packages/version-control.scm \ @@ -1332,6 +1333,7 @@ dist_patch_DATA = \ %D%/packages/patches/util-linux-tests.patch \ %D%/packages/patches/upower-builddir.patch \ %D%/packages/patches/upx-fix-CVE-2017-15056.patch \ + %D%/packages/patches/usb-modeswitch-accept-config-arg.patch \ %D%/packages/patches/valgrind-enable-arm.patch \ %D%/packages/patches/vboot-utils-fix-format-load-address.patch \ %D%/packages/patches/vboot-utils-fix-tests-show-contents.patch \ diff --git a/gnu/packages/patches/usb-modeswitch-accept-config-arg.patch b/gnu/packages/patches/usb-modeswitch-accept-config-arg.patch new file mode 100644 index 0000000000..9c050f7ee6 --- /dev/null +++ b/gnu/packages/patches/usb-modeswitch-accept-config-arg.patch @@ -0,0 +1,42 @@ +--- old/usb_modeswitch.tcl 1970-01-01 01:00:00.000000000 +0100 ++++ usb_modeswitch.tcl 2019-06-12 08:39:42.140000000 +0200 +@@ -41,7 +41,7 @@ + global scsi usb config match device flags setup devdir loginit + + set flags(config) "" +-Log "[ParseGlobalConfig]" ++Log "[ParseGlobalConfig $argv]" + + if {$flags(stordelay) > 0} { + SetStorageDelay $flags(stordelay) +@@ -496,9 +496,21 @@ + # end of proc {MatchDevice} + + +-proc {ParseGlobalConfig} {} { ++proc {ParseGlobalConfig} {argv} { + + global flags ++ ++set configFileParam "" ++for {set i 0} {$i < [llength $argv]} {incr i} { ++ switch -glob -- [set v [lindex $argv $i]] { ++ --config-file=* { ++ set configFileParam $v ++ } ++ } ++} ++if {$configFileParam != ""} { ++ set configFile [string range $configFileParam [string length "--config-file="] end] ++} else { + set configFile "" + set places [list /etc/usb_modeswitch.conf /etc/sysconfig/usb_modeswitch /etc/default/usb_modeswitch] + foreach cfg $places { +@@ -507,6 +519,7 @@ + break + } + } ++} + if {$configFile == ""} {return} + + set rc [open $configFile r] diff --git a/gnu/packages/usb-modeswitch.scm b/gnu/packages/usb-modeswitch.scm new file mode 100644 index 0000000000..533b6988ed --- /dev/null +++ b/gnu/packages/usb-modeswitch.scm @@ -0,0 +1,166 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright ? 2019 Florian Pelz <pelzflorian@pelzflorian.de> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (gnu packages usb-modeswitch) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix build-system gnu) + #:use-module (guix build-system trivial) + #:use-module (gnu packages) + #:use-module (gnu packages base) + #:use-module (gnu packages compression) + #:use-module (gnu packages embedded) + #:use-module (gnu packages libusb) + #:use-module (gnu packages pkg-config)) + +(define-public usb-modeswitch-data + (package + (name "usb-modeswitch-data") + (version "20170806") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-data-" version ".tar.bz2")) + (sha256 + (base32 + "0b1wari3aza6qjggqd0hk2zsh93k1q8scgmwh6f8wr0flpr3whff")))) + (build-system trivial-build-system) + (native-inputs `(("tar" ,tar) + ("bzip2" ,bzip2))) + (arguments + `(#:modules ((guix build utils)) + #:builder + (begin + (use-modules (guix build utils)) + (let* ((source (assoc-ref %build-inputs "source")) + (tar (assoc-ref %build-inputs "tar")) + (bzip2 (assoc-ref %build-inputs "bzip2")) + (files (string-append "usb-modeswitch-data-" + ,(package-version this-package))) + (share-dir (string-append %output "/share")) + (doc-dir (string-append share-dir "/doc/")) + (license-dir (string-append doc-dir + (strip-store-file-name %output))) + (udev-dir (string-append %output "/udev"))) + (copy-file source "data.tar.bz2") + (invoke (string-append bzip2 "/bin/bzip2") "-d" "data.tar.bz2") + (invoke (string-append tar "/bin/tar") "xvf" "data.tar") + (copy-recursively (string-append files "/usb_modeswitch.d") + (string-append share-dir "/usb_modeswitch.d")) + (install-file (string-append files "/40-usb_modeswitch.rules") + udev-dir) + (install-file (string-append files "/COPYING") license-dir))))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Data package for USB_ModeSwitch") + (description "This packages contains data about devices and a UDEV rules +file for use with USB_ModeSwitch.") + (license license:gpl2+))) + +(define-public usb-modeswitch + (package + (name "usb-modeswitch") + (version "2.5.2") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-" version ".tar.bz2")) + (sha256 + (base32 + "19ifi80g9ns5dmspchjvfj4ykxssq9yrci8m227dgb3yr04srzxb")) + (modules '((guix build utils))) + (snippet + ;; Remove bundled jimtcl. + '(begin + (delete-file-recursively "jim") + #t)) + (patches + (search-patches "usb-modeswitch-accept-config-arg.patch")))) + (native-inputs `(("pkg-config" ,pkg-config))) + (inputs `(("libusb" ,libusb) + ("jimtcl" ,jimtcl) + ("usb-modeswitch-data" ,usb-modeswitch-data))) + (outputs '("out" "dispatcher")) + (build-system gnu-build-system) + (arguments + `(#:tests? #f ; does not support `make check` + #:make-flags (list "CC=gcc") + #:phases + (modify-phases %standard-phases + (delete 'configure) ; no configure script + (replace 'install + (lambda* (#:key source outputs inputs #:allow-other-keys) + (let* ((source (assoc-ref inputs "source")) + (jimtcl (assoc-ref inputs "jimtcl")) + (data (assoc-ref inputs "usb-modeswitch-data")) + (out (assoc-ref outputs "out")) + (bin (string-append out "/bin")) + (man1 (string-append out "/share/man/man1")) + (dispatcher-out (assoc-ref outputs "dispatcher")) + (udev (string-append dispatcher-out "/lib/udev")) + (etc (string-append dispatcher-out "/etc")) + (dispatcher-bin (string-append dispatcher-out "/bin")) + (dispatcher-man1 (string-append dispatcher-out + "/share/man/man1"))) + (begin + ;; Users can install the default output and + ;; usb-modeswitch-data and then modeswitch their USB device + ;; by running e.g.: + ;; + ;; sudo usb_modeswitch -c \ + ;; ~/.guix-profile/share/usb_modeswitch.d/12d1\:14fe \ + ;; -v 0x12d1 -p 0x14fe + ;; + ;; But it is simpler to use the usb-modeswitch-service-type + ;; that installs a UDEV rules file which invokes a shell + ;; script in lib/udev (also called `usb_modeswitch' like the + ;; main binary) which, in turn, invokes the program + ;; `usb_modeswitch_dispatcher'. Normal users should not + ;; invoke this dispatcher directly, so it is a separate output. + (install-file "usb_modeswitch" bin) + (install-file "usb_modeswitch.conf" etc) + (install-file "usb_modeswitch.1" man1) + (install-file "usb_modeswitch_dispatcher.1" dispatcher-man1) + + (substitute* "usb_modeswitch.sh" + (("PATH=") "PATH=$PATH:") ; we do not want hardcoded FHS path + (("init_path=") "init_path=/does/not/exist")) ; no /sbin/init + (rename-file "usb_modeswitch.sh" "usb_modeswitch") + (install-file "usb_modeswitch" udev) + + (rename-file "usb_modeswitch.tcl" "usb_modeswitch_dispatcher") + (substitute* "usb_modeswitch_dispatcher" + (("!/usr/bin/tclsh") + (string-append "!" jimtcl "/bin/jimsh")) + (("/usr/sbin") bin) + (("/usr/share/usb_modeswitch") + (string-append data "/share/usb_modeswitch.d"))) + (install-file "usb_modeswitch_dispatcher" + dispatcher-bin) + #t))))))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Mode switching tool for controlling `multi-mode' USB devices") + (description "USB_ModeSwitch is a mode switching tool for controlling USB +devices with multiple @dfn{modes}. When plugged in for the first time many +USB devices (primarily high-speed WAN modems) act like a flash storage +containing installers for Windows drivers. USB_ModeSwitch replays the +sequence the Windows drivers would send to switch their mode from storage to +modem (or whatever the thing is supposed to do).") + (license license:gpl2+))) -- 2.21.0 [-- Attachment #3: 0002-Add-usb-modeswitch-service-type.patch --] [-- Type: text/plain, Size: 8198 bytes --] From db6e3a937f89811017abf06c7dffc494b71b9127 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> 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. --- doc/guix.texi | 35 +++++++++++++ gnu/services/networking.scm | 99 +++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index bd0f3e8fd5..28e752a335 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12655,6 +12655,41 @@ The ModemManager package to use. @end table @end deftp +@cindex USB_ModeSwitch +@cindex Modeswitching + +@defvr {Scheme Variable} usb-modeswitch-service-type +This is the service type for the +@uref{http://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch} service. The +value for this service type is a @code{usb-modeswitch-configuration} record. + +When plugged in, some USB modems (and other USB devices) initially present +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 type +installs UDEV rules to automatically modeswitch these devices when they are +plugged in. +@end defvr + +@deftp {Data Type} usb-modeswitch-configuration +Data type representing the configuration of USB_ModeSwitch. + +@table @asis +@item @code{usb-modeswitch} (default: @code{usb-modeswitch}) +The USB_ModeSwitch package providing the binaries for modeswitching. + +@item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data}) +The package providing the device data and UDEV rules file used by +USB_ModeSwitch. + +@item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")}) +Which config file to use for the USB_ModeSwitch dispatcher. By default the +config file shipped with USB_ModeSwitch is used which disables logging to +@file{/var/log} among other default settings. If set to @code{#f}, no config +file is used. + +@end table +@end deftp + @cindex NetworkManager @defvr {Scheme Variable} network-manager-service-type diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 082a85f63d..fda589ab28 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2018 Chris Marusich <cmmarusich@gmail.com> ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2019 Florian Pelz <pelzflorian@pelzflorian.de> ;;; ;;; This file is part of GNU Guix. ;;; @@ -33,10 +34,13 @@ #:use-module (gnu system shadow) #:use-module (gnu system pam) #:use-module (gnu packages admin) + #:use-module (gnu packages base) + #:use-module (gnu packages bash) #:use-module (gnu packages connman) #:use-module (gnu packages freedesktop) #:use-module (gnu packages linux) #:use-module (gnu packages tor) + #:use-module (gnu packages usb-modeswitch) #:use-module (gnu packages messaging) #:use-module (gnu packages networking) #:use-module (gnu packages ntp) @@ -104,6 +108,12 @@ modem-manager-configuration? modem-manager-service-type + usb-modeswitch-configuration + usb-modeswitch-configuration? + usb-modeswitch-configuration-usb-modeswitch + usb-modeswitch-configuration-usb-modeswitch-data + usb-modeswitch-service-type + <wpa-supplicant-configuration> wpa-supplicant-configuration wpa-supplicant-configuration? @@ -1042,6 +1052,95 @@ ModemManager}, a modem management daemon that aims to simplify dialup networking.")))) \f +;;; +;;; USB_ModeSwitch +;;; + +(define-record-type* <usb-modeswitch-configuration> + usb-modeswitch-configuration make-usb-modeswitch-configuration + usb-modeswitch-configuration? + (usb-modeswitch usb-modeswitch-configuration-usb-modeswitch + (default usb-modeswitch)) + (usb-modeswitch-data usb-modeswitch-configuration-usb-modeswitch-data + (default usb-modeswitch-data)) + (config-file usb-modeswitch-configuration-config-file + (default #~(string-append #$usb-modeswitch:dispatcher + "/etc/usb_modeswitch.conf")))) + +(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 from the +usb-modeswitch package, modified to pass the right config file." + (define usb-modeswitch-sh + (match-lambda + (($ <usb-modeswitch-configuration> usb-modeswitch data config-file) + (let ((orig #~(string-append #$usb-modeswitch:dispatcher + "/lib/udev/usb_modeswitch"))) + (computed-file + "usb_modeswitch-sh" + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (let ((cfg-param + (case #$config-file + ((#f) "") + (else + (string-append " --config-file=" #$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 right) + (string-append left cfg-param right))) + + ;; wrap-program needs bash in PATH: + (putenv (string-append "PATH=" #$bash "/bin")) + (wrap-program (string-append #$output "/usb_modeswitch") + `("PATH" ":" = (,(string-append #$coreutils "/bin") + ,(string-append + #$usb-modeswitch:dispatcher + "/bin")))))))))))) + (match config + (($ <usb-modeswitch-configuration> usb-modeswitch data config-file) + (computed-file + "usb_modeswitch.rules" + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (let ((in (string-append #$data "/udev/40-usb_modeswitch.rules")) + (out (string-append #$output "/lib/udev/rules.d"))) + (mkdir-p out) + (chdir out) + (install-file in out) + (substitute* "40-usb_modeswitch.rules" + (("PROGRAM=\"usb_modeswitch") + (string-append "PROGRAM=\"" #$(usb-modeswitch-sh config) + "/usb_modeswitch")) + (("RUN\\+=\"usb_modeswitch") + (string-append "RUN+=\"" #$(usb-modeswitch-sh config) + "/usb_modeswitch")))))))))) + +(define usb-modeswitch-service-type + (service-type + (name 'usb-modeswitch) + (extensions + (list + (service-extension + udev-service-type + (lambda (config) + (let ((rules (usb-modeswitch-configuration->udev-rules config))) + (list rules)))))) + (default-value (usb-modeswitch-configuration)) + (description "Run @uref{http://www.draisberghof.de/usb_modeswitch/, +USB_ModeSwitch}, a mode switching tool for controlling USB devices with +multiple @dfn{modes}. When plugged in for the first time many USB +devices (primarily high-speed WAN modems) act like a flash storage containing +installers for Windows drivers. USB_ModeSwitch replays the sequence the +Windows drivers would send to switch their mode from storage to modem (or +whatever the thing is supposed to do)."))) + +\f ;;; ;;; WPA supplicant ;;; -- 2.21.0 [-- Attachment #4: 0003-services-Include-USB_ModeSwitch-in-desktop-services.patch --] [-- Type: text/plain, Size: 1540 bytes --] From dc50f979f77d9298e8c81e6943076c612e5f459a Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Wed, 12 Jun 2019 11:16:57 +0200 Subject: [PATCH 3/3] services: Include USB_ModeSwitch in %desktop-services. Fixes <https://bugs.gnu.org/35640>. * gnu/services/desktop.scm (%desktop-services): Add usb-modeswitch-service-type. * doc/guix.texi (Networking Services): Document it. --- doc/guix.texi | 3 +++ gnu/services/desktop.scm | 1 + 2 files changed, 4 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 28e752a335..5c36abeb71 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12668,6 +12668,9 @@ 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 type installs UDEV rules to automatically modeswitch these devices when they are plugged in. + +This service is part of @code{%desktop-services} (@pxref{Desktop +Services}). @end defvr @deftp {Data Type} usb-modeswitch-configuration diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index 652f7b1b02..343d507c14 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -1067,6 +1067,7 @@ dispatches events from it."))) profile-service-type (list network-manager-applet)) (service modem-manager-service-type) + (service usb-modeswitch-service-type) ;; The D-Bus clique. (service avahi-service-type) -- 2.21.0 ^ permalink raw reply related [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-06-12 10:36 ` pelzflorian (Florian Pelz) @ 2019-06-12 10:41 ` pelzflorian (Florian Pelz) 2019-06-12 21:00 ` Ludovic Courtès 2019-06-12 21:11 ` Ludovic Courtès 1 sibling, 1 reply; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-06-12 10:41 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 On Wed, Jun 12, 2019 at 12:36:47PM +0200, pelzflorian (Florian Pelz) wrote: > Find attached patches that make USB modems just work, fixing this bug. > I forgot to ask: The USB_ModeSwitch website says: If you are a system integrator (package maintainer) you can use this XML file to check for new releases: usb-modeswitch-versions.xml <http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-versions.xml>. Is it possible to add a hash of this URL to the usb-modeswitch and usb-modeswitch-data packages so that guix refresh notifies us of new releases? ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-06-12 10:41 ` pelzflorian (Florian Pelz) @ 2019-06-12 21:00 ` Ludovic Courtès 0 siblings, 0 replies; 39+ messages in thread From: Ludovic Courtès @ 2019-06-12 21:00 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > On Wed, Jun 12, 2019 at 12:36:47PM +0200, pelzflorian (Florian Pelz) wrote: >> Find attached patches that make USB modems just work, fixing this bug. >> > > I forgot to ask: The USB_ModeSwitch website says: > > If you are a system integrator (package maintainer) you can use this > XML file to check for new releases: usb-modeswitch-versions.xml > <http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-versions.xml>. > > Is it possible to add a hash of this URL to the usb-modeswitch and > usb-modeswitch-data packages so that guix refresh notifies us of new > releases? No, it’s not that simple. You could write an “updater” (see (guix upstream)) that specifically reads this file and reports the new version specified in this file, but maybe it’s overkill to do that for a single package. Thanks, Ludo’. ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-06-12 10:36 ` pelzflorian (Florian Pelz) 2019-06-12 10:41 ` pelzflorian (Florian Pelz) @ 2019-06-12 21:11 ` Ludovic Courtès 2019-06-13 18:04 ` pelzflorian (Florian Pelz) 1 sibling, 1 reply; 39+ messages in thread From: Ludovic Courtès @ 2019-06-12 21:11 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> 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 ‘%desktop-services’ (*note Desktop > Services::). I think it’s OK. Looks like we’re almost there! A couple of comments and suggestions: >From db6e3a937f89811017abf06c7dffc494b71b9127 Mon Sep 17 00:00:00 2001 > From: Florian Pelz <pelzflorian@pelzflorian.de> > 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 present > +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 type > +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 from the > +usb-modeswitch package, modified to pass the right config file." > + (define usb-modeswitch-sh > + (match-lambda > + (($ <usb-modeswitch-configuration> usb-modeswitch data config-file) > + (let ((orig #~(string-append #$usb-modeswitch:dispatcher > + "/lib/udev/usb_modeswitch"))) > + (computed-file > + "usb_modeswitch-sh" (computed-file …) 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=" #$config-file))))) Instead of (case …), maybe this would be slightly clearer: #$(if config-file #~(string-append … #$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 right) > + (string-append left cfg-param right))) Perhaps add comments to explain what’s happening here. > + ;; wrap-program needs bash in PATH: > + (putenv (string-append "PATH=" #$bash "/bin")) Why do you think so? ‘wrap-program’ does not read $PATH, AFAICS. >From dc50f979f77d9298e8c81e6943076c612e5f459a Mon Sep 17 00:00:00 2001 > From: Florian Pelz <pelzflorian@pelzflorian.de> > Date: Wed, 12 Jun 2019 11:16:57 +0200 > Subject: [PATCH 3/3] services: Include USB_ModeSwitch in %desktop-services. > > Fixes <https://bugs.gnu.org/35640>. > > * gnu/services/desktop.scm (%desktop-services): Add usb-modeswitch-service-type. > * doc/guix.texi (Networking Services): Document it. OK! Thank you! Ludo’. ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-06-12 21:11 ` Ludovic Courtès @ 2019-06-13 18:04 ` pelzflorian (Florian Pelz) 2019-06-13 18:05 ` pelzflorian (Florian Pelz) 0 siblings, 1 reply; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-06-13 18:04 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 Find attached patches taking into account your suggestions. (The second patch is unchanged.) On Wed, Jun 12, 2019 at 11:11:16PM +0200, Ludovic Courtès wrote: > > + ;; wrap-program needs bash in PATH: > > + (putenv (string-append "PATH=" #$bash "/bin")) > > Why do you think so? ‘wrap-program’ does not read $PATH, AFAICS. > wrap-program uses (which "bash"). Without bash in the path, it generates a wrong shebang “#!#f”. Regards, Florian ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-06-13 18:04 ` pelzflorian (Florian Pelz) @ 2019-06-13 18:05 ` pelzflorian (Florian Pelz) 2019-06-15 16:39 ` Ludovic Courtès 0 siblings, 1 reply; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-06-13 18:05 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 205 bytes --] On Thu, Jun 13, 2019 at 08:04:52PM +0200, pelzflorian (Florian Pelz) wrote: > Find attached patches taking into account your suggestions. (The > second patch is unchanged.) > Forgot attachment. Sorry. [-- Attachment #2: 0001-Add-usb-modeswitch-service-type.patch --] [-- Type: text/plain, Size: 8368 bytes --] From 27aff97683537407c178ea2b664069def0cf141a Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Thu, 13 Jun 2019 19:17:05 +0200 Subject: [PATCH 1/2] Add usb-modeswitch-service-type. * gnu/services/networking.scm (usb-modeswitch-service-type): New variable. (usb-modeswitch-configuration): New variable. (usb-modeswitch-sh): New procedure. (usb-modeswitch-configuration->udev-rules): New procedure. * doc/guix.texi (Networking Services): Document it. --- doc/guix.texi | 35 ++++++++++++ gnu/services/networking.scm | 104 ++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 9dc1d2a9ca..c407d6257f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12668,6 +12668,41 @@ The ModemManager package to use. @end table @end deftp +@cindex USB_ModeSwitch +@cindex Modeswitching + +@defvr {Scheme Variable} usb-modeswitch-service-type +This is the service type for the +@uref{http://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch} service. The +value for this service type is a @code{usb-modeswitch-configuration} record. + +When plugged in, some USB modems (and other USB devices) initially present +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 type +installs udev rules to automatically modeswitch these devices when they are +plugged in. +@end defvr + +@deftp {Data Type} usb-modeswitch-configuration +Data type representing the configuration of USB_ModeSwitch. + +@table @asis +@item @code{usb-modeswitch} (default: @code{usb-modeswitch}) +The USB_ModeSwitch package providing the binaries for modeswitching. + +@item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data}) +The package providing the device data and udev rules file used by +USB_ModeSwitch. + +@item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")}) +Which config file to use for the USB_ModeSwitch dispatcher. By default the +config file shipped with USB_ModeSwitch is used which disables logging to +@file{/var/log} among other default settings. If set to @code{#f}, no config +file is used. + +@end table +@end deftp + @cindex NetworkManager @defvr {Scheme Variable} network-manager-service-type diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 082a85f63d..73acb3b17f 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2018 Chris Marusich <cmmarusich@gmail.com> ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net> +;;; Copyright © 2019 Florian Pelz <pelzflorian@pelzflorian.de> ;;; ;;; This file is part of GNU Guix. ;;; @@ -33,10 +34,13 @@ #:use-module (gnu system shadow) #:use-module (gnu system pam) #:use-module (gnu packages admin) + #:use-module (gnu packages base) + #:use-module (gnu packages bash) #:use-module (gnu packages connman) #:use-module (gnu packages freedesktop) #:use-module (gnu packages linux) #:use-module (gnu packages tor) + #:use-module (gnu packages usb-modeswitch) #:use-module (gnu packages messaging) #:use-module (gnu packages networking) #:use-module (gnu packages ntp) @@ -104,6 +108,12 @@ modem-manager-configuration? modem-manager-service-type + usb-modeswitch-configuration + usb-modeswitch-configuration? + usb-modeswitch-configuration-usb-modeswitch + usb-modeswitch-configuration-usb-modeswitch-data + usb-modeswitch-service-type + <wpa-supplicant-configuration> wpa-supplicant-configuration wpa-supplicant-configuration? @@ -1042,6 +1052,100 @@ ModemManager}, a modem management daemon that aims to simplify dialup networking.")))) \f +;;; +;;; USB_ModeSwitch +;;; + +(define-record-type* <usb-modeswitch-configuration> + usb-modeswitch-configuration make-usb-modeswitch-configuration + usb-modeswitch-configuration? + (usb-modeswitch usb-modeswitch-configuration-usb-modeswitch + (default usb-modeswitch)) + (usb-modeswitch-data usb-modeswitch-configuration-usb-modeswitch-data + (default usb-modeswitch-data)) + (config-file usb-modeswitch-configuration-config-file + (default #~(string-append #$usb-modeswitch:dispatcher + "/etc/usb_modeswitch.conf")))) + +(define (usb-modeswitch-sh usb-modeswitch config-file) + "Build a copy of usb_modeswitch.sh located in package USB-MODESWITCH, +modified to pass the CONFIG-FILE in its calls to usb_modeswitch_dispatcher, +and wrap it to actually find the dispatcher in USB-MODESWITCH. The script +will be run by USB_ModeSwitch’s udev rules file when a modeswitchable USB +device is detected." + (computed-file + "usb_modeswitch-sh" + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (let ((cfg-param + #$(if config-file + #~(string-append " --config-file=" #$config-file) + ""))) + (mkdir #$output) + (install-file (string-append #$usb-modeswitch:dispatcher + "/lib/udev/usb_modeswitch") + #$output) + + ;; insert CFG-PARAM into usb_modeswitch_dispatcher command-lines + (substitute* (string-append #$output "/usb_modeswitch") + (("(exec usb_modeswitch_dispatcher .*)( 2>>)" _ left right) + (string-append left cfg-param right)) + (("(exec usb_modeswitch_dispatcher .*)( &)" _ left right) + (string-append left cfg-param right))) + + ;; wrap-program needs bash in PATH: + (putenv (string-append "PATH=" #$bash "/bin")) + (wrap-program (string-append #$output "/usb_modeswitch") + `("PATH" ":" = (,(string-append #$coreutils "/bin") + ,(string-append + #$usb-modeswitch:dispatcher + "/bin"))))))))) + +(define (usb-modeswitch-configuration->udev-rules config) + "Build a rules file for extending udev-service-type from the rules in the +usb-modeswitch package specified in CONFIG. The rules file will invoke +usb_modeswitch.sh from the usb-modeswitch package, modified to pass the right +config file." + (match config + (($ <usb-modeswitch-configuration> usb-modeswitch data config-file) + (computed-file + "usb_modeswitch.rules" + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (let ((in (string-append #$data "/udev/40-usb_modeswitch.rules")) + (out (string-append #$output "/lib/udev/rules.d")) + (script #$(usb-modeswitch-sh usb-modeswitch config-file))) + (mkdir-p out) + (chdir out) + (install-file in out) + (substitute* "40-usb_modeswitch.rules" + (("PROGRAM=\"usb_modeswitch") + (string-append "PROGRAM=\"" script "/usb_modeswitch")) + (("RUN\\+=\"usb_modeswitch") + (string-append "RUN+=\"" script "/usb_modeswitch")))))))))) + +(define usb-modeswitch-service-type + (service-type + (name 'usb-modeswitch) + (extensions + (list + (service-extension + udev-service-type + (lambda (config) + (let ((rules (usb-modeswitch-configuration->udev-rules config))) + (list rules)))))) + (default-value (usb-modeswitch-configuration)) + (description "Run @uref{http://www.draisberghof.de/usb_modeswitch/, +USB_ModeSwitch}, a mode switching tool for controlling USB devices with +multiple @dfn{modes}. When plugged in for the first time many USB +devices (primarily high-speed WAN modems) act like a flash storage containing +installers for Windows drivers. USB_ModeSwitch replays the sequence the +Windows drivers would send to switch their mode from storage to modem (or +whatever the thing is supposed to do)."))) + +\f ;;; ;;; WPA supplicant ;;; -- 2.21.0 [-- Attachment #3: 0002-services-Include-USB_ModeSwitch-in-desktop-services.patch --] [-- Type: text/plain, Size: 1540 bytes --] From f4a5103b365f8bc5d2c514dad2e40f3c9981cfc2 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Wed, 12 Jun 2019 11:16:57 +0200 Subject: [PATCH 2/2] services: Include USB_ModeSwitch in %desktop-services. Fixes <https://bugs.gnu.org/35640>. * gnu/services/desktop.scm (%desktop-services): Add usb-modeswitch-service-type. * doc/guix.texi (Networking Services): Document it. --- doc/guix.texi | 3 +++ gnu/services/desktop.scm | 1 + 2 files changed, 4 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index c407d6257f..8b07693445 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12681,6 +12681,9 @@ 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 type installs udev rules to automatically modeswitch these devices when they are plugged in. + +This service is part of @code{%desktop-services} (@pxref{Desktop +Services}). @end defvr @deftp {Data Type} usb-modeswitch-configuration diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index 652f7b1b02..343d507c14 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -1067,6 +1067,7 @@ dispatches events from it."))) profile-service-type (list network-manager-applet)) (service modem-manager-service-type) + (service usb-modeswitch-service-type) ;; The D-Bus clique. (service avahi-service-type) -- 2.21.0 ^ permalink raw reply related [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-06-13 18:05 ` pelzflorian (Florian Pelz) @ 2019-06-15 16:39 ` Ludovic Courtès 0 siblings, 0 replies; 39+ messages in thread From: Ludovic Courtès @ 2019-06-15 16:39 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640-done Hello! "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > From 27aff97683537407c178ea2b664069def0cf141a Mon Sep 17 00:00:00 2001 > From: Florian Pelz <pelzflorian@pelzflorian.de> > Date: Thu, 13 Jun 2019 19:17:05 +0200 > Subject: [PATCH 1/2] Add usb-modeswitch-service-type. > > * gnu/services/networking.scm (usb-modeswitch-service-type): New variable. > (usb-modeswitch-configuration): New variable. > (usb-modeswitch-sh): New procedure. > (usb-modeswitch-configuration->udev-rules): New procedure. > * doc/guix.texi (Networking Services): Document it. [...] > From f4a5103b365f8bc5d2c514dad2e40f3c9981cfc2 Mon Sep 17 00:00:00 2001 > From: Florian Pelz <pelzflorian@pelzflorian.de> > Date: Wed, 12 Jun 2019 11:16:57 +0200 > Subject: [PATCH 2/2] services: Include USB_ModeSwitch in %desktop-services. > > Fixes <https://bugs.gnu.org/35640>. > > * gnu/services/desktop.scm (%desktop-services): Add usb-modeswitch-service-type. > * doc/guix.texi (Networking Services): Document it. Pushed, thank you! Ludo’. ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-25 17:44 ` Ludovic Courtès 2019-05-25 19:42 ` pelzflorian (Florian Pelz) @ 2019-06-12 12:13 ` pelzflorian (Florian Pelz) 2019-06-12 12:21 ` Ludovic Courtès 2019-06-12 20:58 ` Ludovic Courtès 1 sibling, 2 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-06-12 12:13 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 430 bytes --] On Sat, May 25, 2019 at 07:44:37PM +0200, Ludovic Courtès wrote: > >> + (substitute* "usb_modeswitch_dispatcher" > >> + (("!/usr/bin/tclsh") > >> + (string-append "!" jimtcl "/bin/jimsh")) > > I don’t think it’s needed, is it? > I see now, you mean the exclamation mark? It is not needed. Sorry. Attached is the same patch without exclamation mark. Regards, Florian [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-gnu-Add-USB_ModeSwitch.patch --] [-- Type: text/plain; charset=utf-8, Size: 11331 bytes --] From 2a790dacdb818387325f7a2a895adde6bacabf8b Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Wed, 12 Jun 2019 14:05:44 +0200 Subject: [PATCH 1/3] gnu: Add USB_ModeSwitch. * gnu/packages/usb-modeswitch.scm: New file. * gnu/packages/patches/usb-modeswitch-accept-config-arg.patch: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add package. (dist_patch_DATA): Add patch. --- gnu/local.mk | 2 + .../usb-modeswitch-accept-config-arg.patch | 42 +++++ gnu/packages/usb-modeswitch.scm | 166 ++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 gnu/packages/patches/usb-modeswitch-accept-config-arg.patch create mode 100644 gnu/packages/usb-modeswitch.scm diff --git a/gnu/local.mk b/gnu/local.mk index 907641ff3e..7a90b279f6 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -468,6 +468,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/uml.scm \ %D%/packages/unrtf.scm \ %D%/packages/upnp.scm \ + %D%/packages/usb-modeswitch.scm \ %D%/packages/uucp.scm \ %D%/packages/valgrind.scm \ %D%/packages/version-control.scm \ @@ -1332,6 +1333,7 @@ dist_patch_DATA = \ %D%/packages/patches/util-linux-tests.patch \ %D%/packages/patches/upower-builddir.patch \ %D%/packages/patches/upx-fix-CVE-2017-15056.patch \ + %D%/packages/patches/usb-modeswitch-accept-config-arg.patch \ %D%/packages/patches/valgrind-enable-arm.patch \ %D%/packages/patches/vboot-utils-fix-format-load-address.patch \ %D%/packages/patches/vboot-utils-fix-tests-show-contents.patch \ diff --git a/gnu/packages/patches/usb-modeswitch-accept-config-arg.patch b/gnu/packages/patches/usb-modeswitch-accept-config-arg.patch new file mode 100644 index 0000000000..9c050f7ee6 --- /dev/null +++ b/gnu/packages/patches/usb-modeswitch-accept-config-arg.patch @@ -0,0 +1,42 @@ +--- old/usb_modeswitch.tcl 1970-01-01 01:00:00.000000000 +0100 ++++ usb_modeswitch.tcl 2019-06-12 08:39:42.140000000 +0200 +@@ -41,7 +41,7 @@ + global scsi usb config match device flags setup devdir loginit + + set flags(config) "" +-Log "[ParseGlobalConfig]" ++Log "[ParseGlobalConfig $argv]" + + if {$flags(stordelay) > 0} { + SetStorageDelay $flags(stordelay) +@@ -496,9 +496,21 @@ + # end of proc {MatchDevice} + + +-proc {ParseGlobalConfig} {} { ++proc {ParseGlobalConfig} {argv} { + + global flags ++ ++set configFileParam "" ++for {set i 0} {$i < [llength $argv]} {incr i} { ++ switch -glob -- [set v [lindex $argv $i]] { ++ --config-file=* { ++ set configFileParam $v ++ } ++ } ++} ++if {$configFileParam != ""} { ++ set configFile [string range $configFileParam [string length "--config-file="] end] ++} else { + set configFile "" + set places [list /etc/usb_modeswitch.conf /etc/sysconfig/usb_modeswitch /etc/default/usb_modeswitch] + foreach cfg $places { +@@ -507,6 +519,7 @@ + break + } + } ++} + if {$configFile == ""} {return} + + set rc [open $configFile r] diff --git a/gnu/packages/usb-modeswitch.scm b/gnu/packages/usb-modeswitch.scm new file mode 100644 index 0000000000..8f1cf9df60 --- /dev/null +++ b/gnu/packages/usb-modeswitch.scm @@ -0,0 +1,166 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Florian Pelz <pelzflorian@pelzflorian.de> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (gnu packages usb-modeswitch) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix build-system gnu) + #:use-module (guix build-system trivial) + #:use-module (gnu packages) + #:use-module (gnu packages base) + #:use-module (gnu packages compression) + #:use-module (gnu packages embedded) + #:use-module (gnu packages libusb) + #:use-module (gnu packages pkg-config)) + +(define-public usb-modeswitch-data + (package + (name "usb-modeswitch-data") + (version "20170806") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-data-" version ".tar.bz2")) + (sha256 + (base32 + "0b1wari3aza6qjggqd0hk2zsh93k1q8scgmwh6f8wr0flpr3whff")))) + (build-system trivial-build-system) + (native-inputs `(("tar" ,tar) + ("bzip2" ,bzip2))) + (arguments + `(#:modules ((guix build utils)) + #:builder + (begin + (use-modules (guix build utils)) + (let* ((source (assoc-ref %build-inputs "source")) + (tar (assoc-ref %build-inputs "tar")) + (bzip2 (assoc-ref %build-inputs "bzip2")) + (files (string-append "usb-modeswitch-data-" + ,(package-version this-package))) + (share-dir (string-append %output "/share")) + (doc-dir (string-append share-dir "/doc/")) + (license-dir (string-append doc-dir + (strip-store-file-name %output))) + (udev-dir (string-append %output "/udev"))) + (copy-file source "data.tar.bz2") + (invoke (string-append bzip2 "/bin/bzip2") "-d" "data.tar.bz2") + (invoke (string-append tar "/bin/tar") "xvf" "data.tar") + (copy-recursively (string-append files "/usb_modeswitch.d") + (string-append share-dir "/usb_modeswitch.d")) + (install-file (string-append files "/40-usb_modeswitch.rules") + udev-dir) + (install-file (string-append files "/COPYING") license-dir))))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Data package for USB_ModeSwitch") + (description "This packages contains data about devices and a UDEV rules +file for use with USB_ModeSwitch.") + (license license:gpl2+))) + +(define-public usb-modeswitch + (package + (name "usb-modeswitch") + (version "2.5.2") + (source (origin + (method url-fetch) + (uri (string-append + "http://www.draisberghof.de/usb_modeswitch/" + "usb-modeswitch-" version ".tar.bz2")) + (sha256 + (base32 + "19ifi80g9ns5dmspchjvfj4ykxssq9yrci8m227dgb3yr04srzxb")) + (modules '((guix build utils))) + (snippet + ;; Remove bundled jimtcl. + '(begin + (delete-file-recursively "jim") + #t)) + (patches + (search-patches "usb-modeswitch-accept-config-arg.patch")))) + (native-inputs `(("pkg-config" ,pkg-config))) + (inputs `(("libusb" ,libusb) + ("jimtcl" ,jimtcl) + ("usb-modeswitch-data" ,usb-modeswitch-data))) + (outputs '("out" "dispatcher")) + (build-system gnu-build-system) + (arguments + `(#:tests? #f ; does not support `make check` + #:make-flags (list "CC=gcc") + #:phases + (modify-phases %standard-phases + (delete 'configure) ; no configure script + (replace 'install + (lambda* (#:key source outputs inputs #:allow-other-keys) + (let* ((source (assoc-ref inputs "source")) + (jimtcl (assoc-ref inputs "jimtcl")) + (data (assoc-ref inputs "usb-modeswitch-data")) + (out (assoc-ref outputs "out")) + (bin (string-append out "/bin")) + (man1 (string-append out "/share/man/man1")) + (dispatcher-out (assoc-ref outputs "dispatcher")) + (udev (string-append dispatcher-out "/lib/udev")) + (etc (string-append dispatcher-out "/etc")) + (dispatcher-bin (string-append dispatcher-out "/bin")) + (dispatcher-man1 (string-append dispatcher-out + "/share/man/man1"))) + (begin + ;; Users can install the default output and + ;; usb-modeswitch-data and then modeswitch their USB device + ;; by running e.g.: + ;; + ;; sudo usb_modeswitch -c \ + ;; ~/.guix-profile/share/usb_modeswitch.d/12d1\:14fe \ + ;; -v 0x12d1 -p 0x14fe + ;; + ;; But it is simpler to use the usb-modeswitch-service-type + ;; that installs a UDEV rules file which invokes a shell + ;; script in lib/udev (also called `usb_modeswitch' like the + ;; main binary) which, in turn, invokes the program + ;; `usb_modeswitch_dispatcher'. Normal users should not + ;; invoke this dispatcher directly, so it is a separate output. + (install-file "usb_modeswitch" bin) + (install-file "usb_modeswitch.conf" etc) + (install-file "usb_modeswitch.1" man1) + (install-file "usb_modeswitch_dispatcher.1" dispatcher-man1) + + (substitute* "usb_modeswitch.sh" + (("PATH=") "PATH=$PATH:") ; we do not want hardcoded FHS path + (("init_path=") "init_path=/does/not/exist")) ; no /sbin/init + (rename-file "usb_modeswitch.sh" "usb_modeswitch") + (install-file "usb_modeswitch" udev) + + (rename-file "usb_modeswitch.tcl" "usb_modeswitch_dispatcher") + (substitute* "usb_modeswitch_dispatcher" + (("/usr/bin/tclsh") + (string-append jimtcl "/bin/jimsh")) + (("/usr/sbin") bin) + (("/usr/share/usb_modeswitch") + (string-append data "/share/usb_modeswitch.d"))) + (install-file "usb_modeswitch_dispatcher" + dispatcher-bin) + #t))))))) + (home-page "http://www.draisberghof.de/usb_modeswitch/") + (synopsis "Mode switching tool for controlling `multi-mode' USB devices") + (description "USB_ModeSwitch is a mode switching tool for controlling USB +devices with multiple @dfn{modes}. When plugged in for the first time many +USB devices (primarily high-speed WAN modems) act like a flash storage +containing installers for Windows drivers. USB_ModeSwitch replays the +sequence the Windows drivers would send to switch their mode from storage to +modem (or whatever the thing is supposed to do).") + (license license:gpl2+))) -- 2.21.0 ^ permalink raw reply related [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-06-12 12:13 ` pelzflorian (Florian Pelz) @ 2019-06-12 12:21 ` Ludovic Courtès 2019-06-12 19:51 ` pelzflorian (Florian Pelz) 2019-06-12 20:58 ` Ludovic Courtès 1 sibling, 1 reply; 39+ messages in thread From: Ludovic Courtès @ 2019-06-12 12:21 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > On Sat, May 25, 2019 at 07:44:37PM +0200, Ludovic Courtès wrote: >> >> + (substitute* "usb_modeswitch_dispatcher" >> >> + (("!/usr/bin/tclsh") >> >> + (string-append "!" jimtcl "/bin/jimsh")) >> >> I don’t think it’s needed, is it? >> > > I see now, you mean the exclamation mark? It is not needed. Sorry. I meant that the ‘patch-shebangs’ phase should take care of this, so you can remove this substitution and save two lines. Ludo’. ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-06-12 12:21 ` Ludovic Courtès @ 2019-06-12 19:51 ` pelzflorian (Florian Pelz) 2019-06-12 20:42 ` Ludovic Courtès 0 siblings, 1 reply; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-06-12 19:51 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 On Wed, Jun 12, 2019 at 02:21:05PM +0200, Ludovic Courtès wrote: > "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > > On Sat, May 25, 2019 at 07:44:37PM +0200, Ludovic Courtès wrote: > >> >> + (substitute* "usb_modeswitch_dispatcher" > >> >> + (("!/usr/bin/tclsh") > >> >> + (string-append "!" jimtcl "/bin/jimsh")) > […] > I meant that the ‘patch-shebangs’ phase should take care of this, so you > can remove this substitution and save two lines. > > Ludo’. It is needed. Upstream USB_Modeswitch bundles jimtcl. Its Makefile uses jimsh0 from the bundled jimtcl, if possible, and replaces the shebang using sed. Therefore it seems right to use jimsh for Guix’ USB_ModeSwitch as well. patch-shebang fails because the basename of #!/usr/bin/tclsh is not jimsh. patch-shebang: /gnu/store/24yzny7szv1fnmq6ci1x2ndyy7dzyigk-usb-modeswitch-2.5.2-dispatcher/bin/usb_modeswitch_dispatcher: warning: no binary for interpreter `tclsh' found in $PATH Regards, Florian ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-06-12 19:51 ` pelzflorian (Florian Pelz) @ 2019-06-12 20:42 ` Ludovic Courtès 0 siblings, 0 replies; 39+ messages in thread From: Ludovic Courtès @ 2019-06-12 20:42 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > On Wed, Jun 12, 2019 at 02:21:05PM +0200, Ludovic Courtès wrote: >> "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: >> > On Sat, May 25, 2019 at 07:44:37PM +0200, Ludovic Courtès wrote: >> >> >> + (substitute* "usb_modeswitch_dispatcher" >> >> >> + (("!/usr/bin/tclsh") >> >> >> + (string-append "!" jimtcl "/bin/jimsh")) >> […] >> I meant that the ‘patch-shebangs’ phase should take care of this, so you >> can remove this substitution and save two lines. >> >> Ludo’. > > It is needed. Upstream USB_Modeswitch bundles jimtcl. Its Makefile > uses jimsh0 from the bundled jimtcl, if possible, and replaces the > shebang using sed. Therefore it seems right to use jimsh for Guix’ > USB_ModeSwitch as well. > > patch-shebang fails because the basename of #!/usr/bin/tclsh is not > jimsh. > > patch-shebang: /gnu/store/24yzny7szv1fnmq6ci1x2ndyy7dzyigk-usb-modeswitch-2.5.2-dispatcher/bin/usb_modeswitch_dispatcher: warning: no binary for interpreter `tclsh' found in $PATH Oh got it, thanks for explaining. Ludo’. ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-06-12 12:13 ` pelzflorian (Florian Pelz) 2019-06-12 12:21 ` Ludovic Courtès @ 2019-06-12 20:58 ` Ludovic Courtès 1 sibling, 0 replies; 39+ messages in thread From: Ludovic Courtès @ 2019-06-12 20:58 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: >From 2a790dacdb818387325f7a2a895adde6bacabf8b Mon Sep 17 00:00:00 2001 > From: Florian Pelz <pelzflorian@pelzflorian.de> > Date: Wed, 12 Jun 2019 14:05:44 +0200 > Subject: [PATCH 1/3] gnu: Add USB_ModeSwitch. > > * gnu/packages/usb-modeswitch.scm: New file. > * gnu/packages/patches/usb-modeswitch-accept-config-arg.patch: New file. > * gnu/local.mk (GNU_SYSTEM_MODULES): Add package. > (dist_patch_DATA): Add patch. Applied, thanks! Ludo'. ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-13 20:57 ` pelzflorian (Florian Pelz) 2019-05-13 21:04 ` pelzflorian (Florian Pelz) @ 2019-05-14 20:48 ` Ludovic Courtès 2019-05-15 11:17 ` pelzflorian (Florian Pelz) 2 siblings, 0 replies; 39+ messages in thread From: Ludovic Courtès @ 2019-05-14 20:48 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > + #:use-module ((gnu packages tcl) #:prefix tcl:) In short, you cannot do that for (gnu packages …) modules. But if you remove that #:prefix, it’s hopefully fine? Thanks, Ludo’. ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-13 20:57 ` pelzflorian (Florian Pelz) 2019-05-13 21:04 ` pelzflorian (Florian Pelz) 2019-05-14 20:48 ` Ludovic Courtès @ 2019-05-15 11:17 ` pelzflorian (Florian Pelz) 2019-05-15 12:51 ` Ludovic Courtès 2 siblings, 1 reply; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-15 11:17 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 549 bytes --] On Mon, May 13, 2019 at 10:57:20PM +0200, pelzflorian (Florian Pelz) wrote: > On Thu, May 09, 2019 at 05:24:39PM +0200, Ludovic Courtès wrote: > > The comment is unnecessary, but otherwise LGTM! > > > > :) I have attached the patch without the command. > I have attached the patch again without the comment and with mentioning modem support in the Desktop services section in the doc/guix.texi manual. Previously it was only said in the Network services section that modem-manager-service-type were part of %desktop-services. Regards, Florian [-- Attachment #2: 0001-services-Include-ModemManager-in-desktop-services.patch --] [-- Type: text/plain, Size: 2907 bytes --] From 061c976e38b8b332602e84ac74717384aab57d56 Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Mon, 13 May 2019 22:51:28 +0200 Subject: [PATCH] services: Include ModemManager in %desktop-services. * gnu/services/desktop.scm (%desktop-services): Add modem-manager-service-type. * doc/guix.texi (Desktop services): Mention it here. --- doc/guix.texi | 17 +++++++++-------- gnu/services/desktop.scm | 1 + 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 3f50bf77fe..aa08832fae 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -59,7 +59,7 @@ Copyright @copyright{} 2018 Oleg Pykhalov@* Copyright @copyright{} 2018 Mike Gerwitz@* Copyright @copyright{} 2018 Pierre-Antoine Rouby@* Copyright @copyright{} 2018 Gábor Boskovits@* -Copyright @copyright{} 2018 Florian Pelz@* +Copyright @copyright{} 2018, 2019 Florian Pelz@* Copyright @copyright{} 2018 Laura Lazzati@* Copyright @copyright{} 2018 Alex Vong@* Copyright @copyright{} 2019 Josh Holland@* @@ -14620,13 +14620,14 @@ adds or adjusts services for a typical ``desktop'' setup. In particular, it adds a graphical login manager (@pxref{X Window, @code{gdm-service-type}}), screen lockers, a network management tool -(@pxref{Networking Services, @code{network-manager-service-type}}), energy and color -management services, the @code{elogind} login and seat manager, the -Polkit privilege service, the GeoClue location service, the -AccountsService daemon that allows authorized users change system -passwords, an NTP client (@pxref{Networking Services}), the Avahi -daemon, and has the name service switch service configured to be able to -use @code{nss-mdns} (@pxref{Name Service Switch, mDNS}). +(@pxref{Networking Services, @code{network-manager-service-type}}) with modem +support (@pxref{Networking Services, @code{modem-manager-service-type}}), +energy and color management services, the @code{elogind} login and seat +manager, the Polkit privilege service, the GeoClue location service, the +AccountsService daemon that allows authorized users change system passwords, +an NTP client (@pxref{Networking Services}), the Avahi daemon, and has the +name service switch service configured to be able to use @code{nss-mdns} +(@pxref{Name Service Switch, mDNS}). @end defvr The @var{%desktop-services} variable can be used as the @code{services} diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm index 5e0bd102a2..ac714ca5e0 100644 --- a/gnu/services/desktop.scm +++ b/gnu/services/desktop.scm @@ -1062,6 +1062,7 @@ dispatches events from it."))) ;; The D-Bus clique. (service network-manager-service-type) + (service modem-manager-service-type) (service wpa-supplicant-service-type) ;needed by NetworkManager (service avahi-service-type) (udisks-service) -- 2.21.0 ^ permalink raw reply related [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-15 11:17 ` pelzflorian (Florian Pelz) @ 2019-05-15 12:51 ` Ludovic Courtès 0 siblings, 0 replies; 39+ messages in thread From: Ludovic Courtès @ 2019-05-15 12:51 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > From 061c976e38b8b332602e84ac74717384aab57d56 Mon Sep 17 00:00:00 2001 > From: Florian Pelz <pelzflorian@pelzflorian.de> > Date: Mon, 13 May 2019 22:51:28 +0200 > Subject: [PATCH] services: Include ModemManager in %desktop-services. > > * gnu/services/desktop.scm (%desktop-services): Add modem-manager-service-type. > * doc/guix.texi (Desktop services): Mention it here. Applied. I had applied the desktop.scm yesterday, so I’ve taken just the texi part here. Thanks! Ludo’. ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-09 15:24 ` Ludovic Courtès 2019-05-13 20:57 ` pelzflorian (Florian Pelz) @ 2019-05-16 7:50 ` pelzflorian (Florian Pelz) 2019-05-16 8:34 ` pelzflorian (Florian Pelz) 2019-05-16 11:30 ` Ludovic Courtès 1 sibling, 2 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-16 7:50 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 1128 bytes --] On Thu, May 09, 2019 at 05:24:39PM +0200, Ludovic Courtès wrote: > >>From d489f805599ea63e2e06727a3201572ee0480a60 Mon Sep 17 00:00:00 2001 > > From: Florian Pelz <pelzflorian@pelzflorian.de> > > Date: Wed, 8 May 2019 20:02:00 +0200 > > Subject: [PATCH 2/2] gnu: network-manager-applet: Propagate packages required > > for USB modem setup. > > > > * gnu/packages/gnome.scm (network-manager-applet): Propagate iso-codes and > > mobile-broadband-provider-info. > > (gnome-control-center): Ditto. > > Would it be an option to avoid propagation by instead substituting > references to these two things in the code of network-manager-applet and > gnome-control-center? WDYT? > I have confirmed that the patch attached to this e-mail makes network-manager-applet’s libnma library load its data from the store and not the profile. This fixes nm-connection-editor from network-manager-applet as well as gnome-control-center which previously required modem-broadband-provider-info and iso-codes to be installed in the profile. I am still working on packaging USB_ModeSwitch which some USB modems require. Regards, Florian [-- Attachment #2: 0001-gnu-network-manager-applet-Patch-libnma-for-modem-su.patch --] [-- Type: text/plain, Size: 2941 bytes --] From 627e41c4741acd5b91771131a1646bb89b8c270b Mon Sep 17 00:00:00 2001 From: Florian Pelz <pelzflorian@pelzflorian.de> Date: Wed, 15 May 2019 23:41:44 +0200 Subject: [PATCH] gnu: network-manager-applet: Patch libnma for modem support. * gnu/packages/gnome.scm (network-manager-applet): Patch libnma to load iso-codes and mobile-broadband-provider-info from the store and not require them in the profile. --- gnu/packages/gnome.scm | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm index 09984717cc..fc024ebf72 100644 --- a/gnu/packages/gnome.scm +++ b/gnu/packages/gnome.scm @@ -35,6 +35,7 @@ ;;; Copyright © 2018, 2019 Timothy Sample <samplet@ngyro.com> ;;; Copyright © 2019 Danny Milosavljevic <dannym@scratchpost.org> ;;; Copyright © 2019 Marius Bakke <mbakke@fastmail.com> +;;; Copyright © 2019 Florian Pelz <pelzflorian@pelzflorian.de> ;;; ;;; This file is part of GNU Guix. ;;; @@ -5502,7 +5503,23 @@ to virtual private networks (VPNs) via OpenVPN.") (base32 "1js0i2kwfklahsn77qgxzdscy33drrlym3mrj1qhlw0zf8ri56ya")))) (build-system glib-or-gtk-build-system) - (arguments '(#:configure-flags '("--disable-migration"))) + (arguments '(#:configure-flags '("--disable-migration") + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'patch-source + (lambda* (#:key inputs #:allow-other-keys) + (let ((mbpi (assoc-ref inputs + "mobile-broadband-provider-info")) + (iso-codes (assoc-ref inputs "iso-codes"))) + (substitute* "src/libnma/nma-mobile-providers.c" + (("(g_build_filename \\()dirs\\[i\\].*, \ +(MOBILE_BROADBAND_PROVIDER_INFO.*)" all start end) + (string-append start "\"" mbpi "/share\", " end))) + (substitute* "src/libnma/nma-mobile-providers.c" + (("(g_build_filename \\()dirs\\[i\\].*, \ +(ISO_3166_COUNTRY_CODES.*)" all start end) + (string-append start "\"" iso-codes + "/share\", " end))))))))) (native-inputs `(("intltool" ,intltool) ("gobject-introspection" ,gobject-introspection) @@ -5519,7 +5536,8 @@ to virtual private networks (VPNs) via OpenVPN.") ("libsecret" ,libsecret) ("libselinux" ,libselinux) ("jansson" ,jansson) ; for team support - ("modem-manager" ,modem-manager))) + ("modem-manager" ,modem-manager) + ("mobile-broadband-provider-info" ,mobile-broadband-provider-info))) (synopsis "Applet for managing network connections") (home-page "https://www.gnome.org/projects/NetworkManager/") (description -- 2.21.0 ^ permalink raw reply related [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-16 7:50 ` pelzflorian (Florian Pelz) @ 2019-05-16 8:34 ` pelzflorian (Florian Pelz) 2019-05-16 11:30 ` Ludovic Courtès 1 sibling, 0 replies; 39+ messages in thread From: pelzflorian (Florian Pelz) @ 2019-05-16 8:34 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 35640 On Thu, May 16, 2019 at 09:50:18AM +0200, pelzflorian (Florian Pelz) wrote: > From 627e41c4741acd5b91771131a1646bb89b8c270b Mon Sep 17 00:00:00 2001 > From: Florian Pelz <pelzflorian@pelzflorian.de> > Date: Wed, 15 May 2019 23:41:44 +0200 > Subject: [PATCH] gnu: network-manager-applet: Patch libnma for modem support. > > * gnu/packages/gnome.scm (network-manager-applet): Patch libnma to load > iso-codes and mobile-broadband-provider-info from the store and not require > them in the profile. I hope it would not have been required to increase a revision number. Regards, Florian ^ permalink raw reply [flat|nested] 39+ messages in thread
* bug#35640: Make USB modems just work on Guix 2019-05-16 7:50 ` pelzflorian (Florian Pelz) 2019-05-16 8:34 ` pelzflorian (Florian Pelz) @ 2019-05-16 11:30 ` Ludovic Courtès 1 sibling, 0 replies; 39+ messages in thread From: Ludovic Courtès @ 2019-05-16 11:30 UTC (permalink / raw) To: pelzflorian (Florian Pelz); +Cc: 35640 [-- Attachment #1: Type: text/plain, Size: 682 bytes --] "pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> skribis: > From 627e41c4741acd5b91771131a1646bb89b8c270b Mon Sep 17 00:00:00 2001 > From: Florian Pelz <pelzflorian@pelzflorian.de> > Date: Wed, 15 May 2019 23:41:44 +0200 > Subject: [PATCH] gnu: network-manager-applet: Patch libnma for modem support. > > * gnu/packages/gnome.scm (network-manager-applet): Patch libnma to load > iso-codes and mobile-broadband-provider-info from the store and not require > them in the profile. Great. Applied with the changes below; the spacing change is to please Emacs (C-M-a & co. get confused by opening parentheses at the beginning of a line.) Thanks, Ludo’. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: Type: text/x-patch, Size: 1429 bytes --] diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm index fc024ebf72..9070673cf6 100644 --- a/gnu/packages/gnome.scm +++ b/gnu/packages/gnome.scm @@ -5512,14 +5512,15 @@ to virtual private networks (VPNs) via OpenVPN.") "mobile-broadband-provider-info")) (iso-codes (assoc-ref inputs "iso-codes"))) (substitute* "src/libnma/nma-mobile-providers.c" - (("(g_build_filename \\()dirs\\[i\\].*, \ -(MOBILE_BROADBAND_PROVIDER_INFO.*)" all start end) + (("(g_build_filename \\()dirs\\[i\\].*,\ + (MOBILE_BROADBAND_PROVIDER_INFO.*)" all start end) (string-append start "\"" mbpi "/share\", " end))) (substitute* "src/libnma/nma-mobile-providers.c" - (("(g_build_filename \\()dirs\\[i\\].*, \ -(ISO_3166_COUNTRY_CODES.*)" all start end) + (("(g_build_filename \\()dirs\\[i\\].*,\ + (ISO_3166_COUNTRY_CODES.*)" all start end) (string-append start "\"" iso-codes - "/share\", " end))))))))) + "/share\", " end))) + #t)))))) (native-inputs `(("intltool" ,intltool) ("gobject-introspection" ,gobject-introspection) ^ permalink raw reply related [flat|nested] 39+ messages in thread
end of thread, other threads:[~2019-06-15 16:40 UTC | newest] Thread overview: 39+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-05-08 18:26 bug#35640: Make USB modems just work on Guix pelzflorian (Florian Pelz) 2019-05-09 5:31 ` pelzflorian (Florian Pelz) 2019-05-09 12:55 ` Danny Milosavljevic 2019-05-09 13:07 ` pelzflorian (Florian Pelz) 2019-05-09 13:43 ` pelzflorian (Florian Pelz) 2019-05-09 15:24 ` Ludovic Courtès 2019-05-13 20:57 ` pelzflorian (Florian Pelz) 2019-05-13 21:04 ` pelzflorian (Florian Pelz) 2019-05-14 7:22 ` pelzflorian (Florian Pelz) 2019-05-14 8:35 ` Danny Milosavljevic 2019-05-14 20:56 ` pelzflorian (Florian Pelz) 2019-05-15 13:01 ` Ludovic Courtès 2019-05-15 14:40 ` pelzflorian (Florian Pelz) 2019-05-22 16:29 ` pelzflorian (Florian Pelz) 2019-05-22 17:58 ` pelzflorian (Florian Pelz) 2019-05-24 15:37 ` Ludovic Courtès 2019-05-24 20:12 ` pelzflorian (Florian Pelz) 2019-05-25 11:18 ` pelzflorian (Florian Pelz) 2019-05-25 12:43 ` pelzflorian (Florian Pelz) 2019-05-25 17:44 ` Ludovic Courtès 2019-05-25 19:42 ` pelzflorian (Florian Pelz) 2019-06-12 10:36 ` pelzflorian (Florian Pelz) 2019-06-12 10:41 ` pelzflorian (Florian Pelz) 2019-06-12 21:00 ` Ludovic Courtès 2019-06-12 21:11 ` Ludovic Courtès 2019-06-13 18:04 ` pelzflorian (Florian Pelz) 2019-06-13 18:05 ` pelzflorian (Florian Pelz) 2019-06-15 16:39 ` Ludovic Courtès 2019-06-12 12:13 ` pelzflorian (Florian Pelz) 2019-06-12 12:21 ` Ludovic Courtès 2019-06-12 19:51 ` pelzflorian (Florian Pelz) 2019-06-12 20:42 ` Ludovic Courtès 2019-06-12 20:58 ` Ludovic Courtès 2019-05-14 20:48 ` Ludovic Courtès 2019-05-15 11:17 ` pelzflorian (Florian Pelz) 2019-05-15 12:51 ` Ludovic Courtès 2019-05-16 7:50 ` pelzflorian (Florian Pelz) 2019-05-16 8:34 ` pelzflorian (Florian Pelz) 2019-05-16 11:30 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/guix.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).