Subject: bug#35640: Make USB modems just work on Guix

From: Ludovic Courtès <[email-masked]>
Date: Wed, 15 May 2019 15:01:04 +0200

Hi,

"pelzflorian (Florian Pelz)" <[email-masked]> 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 <[email-masked]>
> 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’.