GNU bug report logs - #57537
[PATCH] gnu: Add ec

Previous Next

Package: guix-patches;

Reported by: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>

Date: Fri, 2 Sep 2022 02:03:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 57537 in the body.
You can then email your comments to 57537 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#57537; Package guix-patches. (Fri, 02 Sep 2022 02:03:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 02 Sep 2022 02:03:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
To: guix-patches <at> gnu.org
Cc: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
Subject: [PATCH] gnu: Add ec
Date: Fri,  2 Sep 2022 04:00:49 +0200
* gnu/packages/linux.scm (ec): New variable.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
---
 gnu/packages/linux.scm | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 5254b20dc4..bf71dad722 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1375,6 +1375,44 @@ (define-public librem-ec-acpi-linux-module
 and the notification, WiFi, and Bluetooth LED.")
     (license license:gpl2)))
 
+(define-public ec
+  (package
+    (name "ec")
+    (version (package-version linux-libre))
+    (source (package-source linux-libre))
+    (build-system gnu-build-system)
+    (native-inputs (list coreutils))
+    (arguments
+     '(#:make-flags (list (string-append "DESTDIR="
+                                         (assoc-ref %outputs "out")))
+       #:phases (modify-phases %standard-phases
+                  (delete 'configure) ;no configure script
+                  (add-after 'unpack 'patch-Makefile
+                    (lambda _
+                      (substitute* "tools/power/acpi/Makefile.config"
+                        (("/bin/true")
+                         (which "true")))
+                      (substitute* "tools/power/acpi/Makefile.config"
+                        (("/usr/bin/install")
+                         (which "install"))) #t))
+                  (add-after 'patch-Makefile 'enter-subdirectory
+                    (lambda _
+                      (chdir "tools/power/acpi/tools/ec") #t)))
+       #:tests? #f)) ;no tests
+    (home-page (package-home-page linux-libre))
+    (synopsis
+     "Low level utility for reading or writing Embedded Controller registers")
+    (description
+     "This utility can read or write specific registers or all the
+available registers of the Embedded Controllers supported by the Linux
+kernel.  To work it needs to run as root, to have the ec_sys driver
+loaded, and to have the debugfs filesystem mounted at
+/sys/kernel/debug/.  To make write support work, the ec_sys module
+needs to be loaded with the write_support=1 parameter.  Write support
+can also be enabled after loading the module with
+the 'echo 1 > /sys/module/ec_sys/parameters/write_support' command.")
+    (license license:gpl2)))
+
 (define-public lkrg
   (package
     (name "lkrg")

base-commit: 4d361a6b5147e3f91573e9d3c8c540a233e7e142
-- 
2.37.2





Information forwarded to guix-patches <at> gnu.org:
bug#57537; Package guix-patches. (Fri, 02 Sep 2022 02:15:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
To: guix-patches <at> gnu.org
Subject: Re: [PATCH] gnu: Add ec
Date: Fri, 2 Sep 2022 04:14:18 +0200
[Message part 1 (text/plain, inline)]
Hi,

On Fri,  2 Sep 2022 04:00:49 +0200
Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org> wrote:
> +     '(#:make-flags (list (string-append "DESTDIR="
> +                                         (assoc-ref %outputs "out")))
This installs the 'ec' binary in DESTDIR/usr/sbin which is wrong.

I'll fix it and send a v2.

Denis.
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#57537; Package guix-patches. (Fri, 02 Sep 2022 02:33:02 GMT) Full text and rfc822 format available.

Message #11 received at 57537 <at> debbugs.gnu.org (full text, mbox):

From: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
To: 57537 <at> debbugs.gnu.org
Cc: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
Subject: [PATCH v2] gnu: Add ec
Date: Fri,  2 Sep 2022 04:32:39 +0200
* gnu/packages/linux.scm (ec): New variable.
---
 gnu/packages/linux.scm | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 5254b20dc4..dd91ca60fc 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1375,6 +1375,45 @@ (define-public librem-ec-acpi-linux-module
 and the notification, WiFi, and Bluetooth LED.")
     (license license:gpl2)))
 
+(define-public ec
+  (package
+    (name "ec")
+    (version (package-version linux-libre))
+    (source (package-source linux-libre))
+    (build-system gnu-build-system)
+    (native-inputs (list coreutils))
+    (arguments
+     '(#:make-flags (list (string-append "DESTDIR="
+                                         (assoc-ref %outputs "out"))
+                          "sbindir=/sbin")
+       #:phases (modify-phases %standard-phases
+                  (delete 'configure) ;no configure script
+                  (add-after 'unpack 'patch-Makefile
+                    (lambda _
+                      (substitute* "tools/power/acpi/Makefile.config"
+                        (("/bin/true")
+                         (which "true")))
+                      (substitute* "tools/power/acpi/Makefile.config"
+                        (("/usr/bin/install")
+                         (which "install"))) #t))
+                  (add-after 'patch-Makefile 'enter-subdirectory
+                    (lambda _
+                      (chdir "tools/power/acpi/tools/ec") #t)))
+       #:tests? #f)) ;no tests
+    (home-page (package-home-page linux-libre))
+    (synopsis
+     "Low level utility for reading or writing Embedded Controller registers")
+    (description
+     "This utility can read or write specific registers or all the
+available registers of the Embedded Controllers supported by the Linux
+kernel.  To work it needs to run as root, to have the ec_sys driver
+loaded, and to have the debugfs filesystem mounted at
+/sys/kernel/debug/.  To make write support work, the ec_sys module
+needs to be loaded with the write_support=1 parameter.  Write support
+can also be enabled after loading the module with
+the 'echo 1 > /sys/module/ec_sys/parameters/write_support' command.")
+    (license license:gpl2)))
+
 (define-public lkrg
   (package
     (name "lkrg")

base-commit: 4d361a6b5147e3f91573e9d3c8c540a233e7e142
-- 
2.37.2





Information forwarded to guix-patches <at> gnu.org:
bug#57537; Package guix-patches. (Fri, 02 Sep 2022 04:48:01 GMT) Full text and rfc822 format available.

Message #14 received at 57537 <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
Cc: 57537 <at> debbugs.gnu.org
Subject: Re: [bug#57537] [PATCH v2] gnu: Add ec
Date: Fri, 02 Sep 2022 06:47:39 +0200
Hi Denis,

This tool has come in handy a few times.  (But did I package it?  Nope…) 
 Thank you for doing so!

Don't forget to add a copyright line for yourself at the top of the 
file.

Denis 'GNUtoo' Carikli 写道:
> This installs the 'ec' binary in DESTDIR/usr/sbin which is wrong.

Indeed, using ‘DESTDIR’ is almost always a mistake.

There are a handful of occurrences in Guix, as a hack to get a buggy 
Makefile to work, but those are (thankfully) rare.

Your v2 still has the ‘DESTDIR’ in it, though.  Missed when committing?

> gnu: Add ec

We ♥ full stops, even here.

> +(define-public ec
> +  (package
> +    (name "ec")
> +    (version (package-version linux-libre))
> +    (source (package-source linux-libre))
> +    (build-system gnu-build-system)
> +    (native-inputs (list coreutils))

I doubt this has any effect?

> +    (arguments
> +     '(#:make-flags (list (string-append "DESTDIR="
> +                                         (assoc-ref %outputs "out"))

The magical %output{s,} is fragile and almost never necessary in new 
code.  Make the arguments a list of keywords/gexps and use #$output 
instead.

> +                          "sbindir=/sbin")
> +       #:phases (modify-phases %standard-phases
> +                  (delete 'configure) ;no configure script

It makes no difference to Guix, but for the sake of humans: manipulate 
phases in their original order when there's no reason not to.

Here, 'configure runs after 'unpack.

> +                  (add-after 'unpack 'patch-Makefile
> +                    (lambda _
> +                      (substitute* "tools/power/acpi/Makefile.config"
> +                        (("/bin/true")
> +                         (which "true")))
> +                      (substitute* "tools/power/acpi/Makefile.config"
> +                        (("/usr/bin/install")
> +                         (which "install"))) #t))

Aside: no need to call substitute* twice on the exact same (list of) 
file(s).
Nor is it necessary to look up binaries in PATH ‘by hand’.  Most tools 
do that already.

                      (substitute* "Makefile.config"
                        (("/bin/true") "true")
                        (("/usr/bin/install") "install"))

However, substitution is overkill as that Makefile doesn't hard-code 
either name.

Instead, let's just use the make-flags upstream provides:

  λ grep '= /.*bin' Makefile*
  Makefile.config:INSTALL = /usr/bin/install -c
  Makefile.config:      STRIPCMD = /bin/true -Since_we_are_debugging

> +                  (add-after 'patch-Makefile 'enter-subdirectory
> +                    (lambda _
> +                      (chdir "tools/power/acpi/tools/ec") #t)))

I'm happy to be the one to inform you that trailing #ts are 
long-obsolete.

Feel free to remove them whenever you encounter them.  It is very 
satisfying.

> +       #:tests? #f)) ;no tests
> +    (home-page (package-home-page linux-libre))
> +    (synopsis
> +     "Low level utility for reading or writing Embedded Controller 
> registers")
> +    (description
> +     "This utility can read or write specific registers or all the
> +available registers of the Embedded Controllers supported by the Linux

The ‘ec’ description should probably mention the word ‘EC’ *somewhere*… 
;-)

  → ‘@acronym{EC, Embedded Controller}’

> +kernel.  To work it needs to run as root, to have the ec_sys driver
> +loaded, and to have the debugfs filesystem mounted at
> +/sys/kernel/debug/.

‘@code{ec_sys} module loaded’, ‘@code{debugfs} file system’,
‘@file{/sys/kernel/debug}’.

>                       To make write support work, the ec_sys module
> +needs to be loaded with the write_support=1 parameter.  Write support
> +can also be enabled after loading the module with
> +the 'echo 1 > /sys/module/ec_sys/parameters/write_support' command.")

Using @code{}/@file{}/@samp{}… also applies here, but do you know if 
there's *any* documentation we could install?  This kind of 
highly-specific how-to isn't a great package description.

I wanted to send back a proper patch but this (below) is all I have time 
for.  I can't push yet anyway, so no rush.

Thanks again,

T G-R

(define-public ec
  (package
    (name "ec")
    (version (package-version linux-libre))
    (source (package-source linux-libre))
    (build-system gnu-build-system)
    (arguments
     (list
      #:tests? #f                      ; no tests
      #:make-flags
      #~(list (string-append "sbindir=" #$output "/sbin")
              "INSTALL=install" "STRIPCMD=true")
      #:phases
      #~(modify-phases %standard-phases
          (add-after 'unpack 'enter-subdirectory
            (lambda _
              (chdir "tools/power/acpi/tools/ec")))
          (delete 'configure))))       ; no configure script
    (home-page (package-home-page linux-libre))
    (synopsis "Low level utility to read or write Embedded Controller 
registers")
    (description
     "…")
    (license license:gpl2)))




Information forwarded to guix-patches <at> gnu.org:
bug#57537; Package guix-patches. (Sat, 03 Sep 2022 20:34:02 GMT) Full text and rfc822 format available.

Message #17 received at 57537 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>,
 Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
Cc: 57537 <at> debbugs.gnu.org
Subject: Re: [bug#57537] [PATCH v2] gnu: Add ec
Date: Sat, 3 Sep 2022 22:32:54 +0200
[Message part 1 (text/plain, inline)]
On 02-09-2022 06:47, Tobias Geerinckx-Rice via Guix-patches via wrote:
> #~(list (string-append "sbindir=" #$output "/sbin")
>               "INSTALL=install" "STRIPCMD=true") 

For cross-compilation, you probably need to add (string-append "CC=" 
#$(cc-for-target)) as well, assuming it's the same system as for 'tmon'.

Greetings,
Maxime.

[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

Information forwarded to guix-patches <at> gnu.org:
bug#57537; Package guix-patches. (Tue, 06 Sep 2022 12:05:02 GMT) Full text and rfc822 format available.

Message #20 received at 57537 <at> debbugs.gnu.org (full text, mbox):

From: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>
Cc: 57537 <at> debbugs.gnu.org
Subject: Re: [bug#57537] [PATCH v2] gnu: Add ec
Date: Tue, 6 Sep 2022 06:29:07 +0200
[Message part 1 (text/plain, inline)]
On Fri, 02 Sep 2022 06:47:39 +0200
Tobias Geerinckx-Rice <me <at> tobias.gr> wrote:

> Hi Denis,
Hi,

> This tool has come in handy a few times.  (But did I package it?
> Nope…) Thank you for doing so!
Thanks for the review and sorry to have left so many issues in the
patch.

> Don't forget to add a copyright line for yourself at the top of the 
> file.
I thought I already had it but apparently I forgot to add it in the
commit f16e6b505d5d2630b786a0477ec73b42e77b04e4 ("gnu: Add
usbip-utils"). So I'll add it in the v3 of this ec patch.

> > gnu: Add ec
> 
> We ♥ full stops, even here.
Fixed.

> > +(define-public ec
> > +  (package
> > +    (name "ec")
> > +    (version (package-version linux-libre))
> > +    (source (package-source linux-libre))
> > +    (build-system gnu-build-system)
> > +    (native-inputs (list coreutils))
> 
> I doubt this has any effect?
It indeed still works without it. I added it because it didn't find
true, and then I added the substitute after that. And I forgot to test
without (native-inputs (list coreutils)).

> > +    (arguments
> > +     '(#:make-flags (list (string-append "DESTDIR="
> > +                                         (assoc-ref %outputs
> > "out"))
> 
> The magical %output{s,} is fragile and almost never necessary in new 
> code.  Make the arguments a list of keywords/gexps and use #$output 
> instead.
Thanks I've now fixed it.

> 
> > +                          "sbindir=/sbin")
> > +       #:phases (modify-phases %standard-phases
> > +                  (delete 'configure) ;no configure script
> 
> It makes no difference to Guix, but for the sake of humans:
> manipulate phases in their original order when there's no reason not
> to.
Thanks, I've also fixed that.

> > +                  (add-after 'unpack 'patch-Makefile
> > +                    (lambda _
> > +                      (substitute*
> > "tools/power/acpi/Makefile.config"
> > +                        (("/bin/true")
> > +                         (which "true")))
> > +                      (substitute*
> > "tools/power/acpi/Makefile.config"
> > +                        (("/usr/bin/install")
> > +                         (which "install"))) #t))
> 
> Aside: no need to call substitute* twice on the exact same (list of) 
> file(s).
Thanks. Here I forgot to try to do something like that.

> Nor is it necessary to look up binaries in PATH ‘by hand’.  Most
> tools do that already.
> 
>                        (substitute* "Makefile.config"
>                          (("/bin/true") "true")
>                          (("/usr/bin/install") "install"))
Thanks for the tip, that's indeed way better.

> However, substitution is overkill as that Makefile doesn't hard-code 
> either name.
Right, it works if I do STRIPCMD=true and INSTALL=install. I should
re-read the GNU make manual on variables assignments (I assumed '=' was
like ':=').

> > +                  (add-after 'patch-Makefile 'enter-subdirectory
> > +                    (lambda _
> > +                      (chdir "tools/power/acpi/tools/ec") #t)))
> 
> I'm happy to be the one to inform you that trailing #ts are 
> long-obsolete.
Nice!

> > +       #:tests? #f)) ;no tests
> > +    (home-page (package-home-page linux-libre))
> > +    (synopsis
> > +     "Low level utility for reading or writing Embedded Controller 
> > registers")
> > +    (description
> > +     "This utility can read or write specific registers or all the
> > +available registers of the Embedded Controllers supported by the
> > Linux
> 
> The ‘ec’ description should probably mention the word ‘EC’
> *somewhere*… ;-)
> 
>    → ‘@acronym{EC, Embedded Controller}’
> > +kernel.  To work it needs to run as root, to have the ec_sys driver
> > +loaded, and to have the debugfs filesystem mounted at
> > +/sys/kernel/debug/.
> 
> ‘@code{ec_sys} module loaded’, ‘@code{debugfs} file system’,
> ‘@file{/sys/kernel/debug}’.
>
> >                       To make write support work, the ec_sys module
> > +needs to be loaded with the write_support=1 parameter.  Write
> > support +can also be enabled after loading the module with
> > +the 'echo 1 > /sys/module/ec_sys/parameters/write_support'
> > command.")
> 
> Using @code{}/@file{}/@samp{}… also applies here
Thanks I've now fixed that.

> do you know if 
> there's *any* documentation we could install?
There is Documentation/ABI/testing/debugfs-ec, that mention the ec
program, but it doesn't really tell how to use it. Though it has a very
useful warnings.

I also wonder if it's that useful to have a complete HOWTO as this tool
is only useful for advanced users that know what they are doing or for
reuse in other programs/scripts that do the necessary checks.

In my case I use it in a userspace program to force the detection of the
Thinkpad X200 dock in userspace and also for leds (though here I could
also upstream better Linux support for that, but that requires time).

> This kind of highly-specific how-to isn't a great package
> description.
The issue here is that I've been trying to make two different thing fit
inside the package description.

Since Guix also has experimental support for HURD and that it can also
cross compile binaries for Windows through mingw, I think it's a good
idea to at least mention the dependencies of that utility.

If I use the word "driver" instead of module, to make sure that people
do understand that the ec_sys is not an out of tree module, and that I
remove the HOWTO part I can shrink it to that:
> This utility can read or write specific registers or all the available
> registers of the @acronym{EC, Embedded Controller} supported by the
> @code{ec_sys} Linux driver.")

Denis.
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#57537; Package guix-patches. (Sat, 24 Sep 2022 13:29:02 GMT) Full text and rfc822 format available.

Message #23 received at 57537 <at> debbugs.gnu.org (full text, mbox):

From: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
To: 57537 <at> debbugs.gnu.org
Cc: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
Subject: [PATCH v2] gnu: Add ec.
Date: Sat, 24 Sep 2022 15:28:15 +0200
* gnu/packages/linux.scm (ec): New variable.
---
 gnu/packages/linux.scm | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 306c18e398..0b38bc03f8 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -64,6 +64,7 @@
 ;;; Copyright © 2022 Artyom V. Poptsov <poptsov.artyom <at> gmail.com>
 ;;; Copyright © 2022 Rene Saavedra <nanuui <at> protonmail.com>
 ;;; Copyright © 2022 muradm <mail <at> muradm.net>
+;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
 
 ;;;
 ;;; This file is part of GNU Guix.
@@ -1342,6 +1343,31 @@ (define-public librem-ec-acpi-linux-module
 and the notification, WiFi, and Bluetooth LED.")
     (license license:gpl2)))
 
+(define-public ec
+  (package
+    (name "ec")
+    (version (package-version linux-libre))
+    (source (package-source linux-libre))
+    (build-system gnu-build-system)
+    (arguments
+     (list #:make-flags #~(list (string-append "sbindir="
+                                               #$output "/sbin")
+                                "INSTALL=install" "STRIPCMD=true")
+           #:phases #~(modify-phases %standard-phases
+                        (add-after 'unpack 'enter-subdirectory
+                          (lambda _
+                            (chdir "tools/power/acpi/tools/ec")))
+                        (delete 'configure)) ;no configure script
+           #:tests? #f)) ;no tests
+    (home-page (package-home-page linux-libre))
+    (synopsis
+     "Low level utility for reading or writing @acronym{EC, Embedded Controller} registers")
+    (description
+     "This utility can read or write specific registers or all the available
+registers of the @acronym{EC, Embedded Controller} supported by the
+@code{ec_sys} Linux driver")
+    (license license:gpl2)))
+
 (define-public lkrg
   (package
     (name "lkrg")

base-commit: dc7191302e6d099a26673e08b78eb5f4b2a2b17b
-- 
2.37.3





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Mon, 26 Sep 2022 20:43:01 GMT) Full text and rfc822 format available.

Notification sent to Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>:
bug acknowledged by developer. (Mon, 26 Sep 2022 20:43:01 GMT) Full text and rfc822 format available.

Message #28 received at 57537-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
Cc: 57537-done <at> debbugs.gnu.org
Subject: Re: bug#57537: [PATCH] gnu: Add ec
Date: Mon, 26 Sep 2022 22:42:05 +0200
Hi Denis,

Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org> skribis:

> * gnu/packages/linux.scm (ec): New variable.

Applied with minor tweaks, thanks!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 25 Oct 2022 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 176 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.