[PATCH] gnu: linux: Allow kconfig options to be strings

DoneSubmitted by antlers.
Details
2 participants
  • antlers
  • Ludovic Courtès
Owner
unassigned
Severity
normal
A
A
antlers wrote on 4 Apr 20:26 +0200
(address . guix-patches@gnu.org)(name . antlers)(address . autumnalantlers@gmail.com)
20220404182609.14604-1-autumnalantlers@gmail.com
* gnu/packages/linux.scm (config->string): add a clause handling strings

Allows for the declarative configuration of kconfig options which accept
strings, such as CONFIG_MODULE_SIG_KEY.

I've enclosed the given string in quotes, but don't do any kind of
escaping. See the kernel mailing list for the current state of escaped
strings upstream:


Apologies to those with double-quotes or backslashes in their
CONFIG_SYSTEM_*_KEYS.

Signed-off-by: antlers <autumnalantlers@gmail.com>
---
gnu/packages/linux.scm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Toggle diff (17 lines)
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index ec68f5c57e..9a81fc4a3d 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -767,7 +767,9 @@ (define (config->string options)
                       ((option . #t)
                        (string-append option "=y"))
                       ((option . #f)
-                       (string-append option "=n")))
+                       (string-append option "=n"))
+                      ((option . string)
+                       (string-append option "=\"" string "\"")))
                     options)
                "\n"))
 
-- 
2.34.0
L
L
Ludovic Courtès wrote on 5 Apr 20:18 +0200
(name . antlers)(address . autumnalantlers@gmail.com)(address . 54713-done@debbugs.gnu.org)
87pmlvjsw1.fsf@gnu.org
Hi,

antlers <autumnalantlers@gmail.com> skribis:

Toggle quote (14 lines)
> * gnu/packages/linux.scm (config->string): add a clause handling strings
>
> Allows for the declarative configuration of kconfig options which accept
> strings, such as CONFIG_MODULE_SIG_KEY.
>
> I've enclosed the given string in quotes, but don't do any kind of
> escaping. See the kernel mailing list for the current state of escaped
> strings upstream:
>
> https://patchwork.kernel.org/project/linux-kbuild/patch/1431003982-992-1-git-send-email-sr@denx.de/
>
> Apologies to those with double-quotes or backslashes in their
> CONFIG_SYSTEM_*_KEYS.

Applied.

If needed, a cheap and often “good enough” way to escape strings is
‘object->string’:

(display (object->string "foo\"bar\"baz"))
=> "foo\"bar\"baz"

Would that help here?

Thanks,
Ludo’.
Closed
E
E
Elijah Harding wrote on 6 Apr 23:30 +0200
Fwd: bug#54713: [PATCH] gnu: linux: Allow kconfig options to be strings
(address . 54713-done@debbugs.gnu.org)
CAFxNT+dNYGtNYbWQ8SAwucfuP=gfO44HmKpHTPpPzY8GJ8w7EQ@mail.gmail.com
Without digging into kconfig to see exactly what's going on, I'm
afraid that anyone using risky characters (especially ['`\n#$]) in one
of these fields is on their own.

Single-quoted strings appear to be interpreted as empty regardless of
their content, so that's not an option. Within double-quoted strings,
it doesn't appear to allow you to escape single-quotes, quisi-quotes,
or #comments. While double-quotes and backslashes only need a single
escape (which does line up with object->string), (semi-)colons need
two, and a pipe only works with four ("\\\\\\\\|" in a guile source
file). "$" breaks in ways that I frankly don't understand, and which
no amount of escaping resolves. I'm perfectly content to assume that
people will only use [a-zA-Z0-9/+-_. ], and [[\]!@%^&*()={},<>?] also
happen to work just fine.

Thanks for taking the time to review my patch, and for all the work
you've done, within Guix and the broader Guile ecosystem alike.


On Tue, Apr 5, 2022 at 11:18 AM Ludovic Courtès <ludo@gnu.org> wrote:
Toggle quote (31 lines)
>
> Hi,
>
> antlers <autumnalantlers@gmail.com> skribis:
>
> > * gnu/packages/linux.scm (config->string): add a clause handling strings
> >
> > Allows for the declarative configuration of kconfig options which accept
> > strings, such as CONFIG_MODULE_SIG_KEY.
> >
> > I've enclosed the given string in quotes, but don't do any kind of
> > escaping. See the kernel mailing list for the current state of escaped
> > strings upstream:
> >
> > https://patchwork.kernel.org/project/linux-kbuild/patch/1431003982-992-1-git-send-email-sr@denx.de/
> >
> > Apologies to those with double-quotes or backslashes in their
> > CONFIG_SYSTEM_*_KEYS.
>
> Applied.
>
> If needed, a cheap and often “good enough” way to escape strings is
> ‘object->string’:
>
> (display (object->string "foo\"bar\"baz"))
> => "foo\"bar\"baz"
>
> Would that help here?
>
> Thanks,
> Ludo’.
Closed
E
E
Elijah Harding wrote on 11 Apr 07:08 +0200
Re: [PATCH] gnu: linux: Escape the values of string-type kconfig options
(address . 54713@debbugs.gnu.org)
CAFxNT+fCsn6RPPqGXd3AvStO0bw0CLJkshdEEF03UpWuBoZgPQ@mail.gmail.com
Oh lord, hold off on this one: File paths in CONFIG_SYSTEM_*_KEYS
options are parsed by Make before their file is opened, but
CONFIG_LOCALVERSION strings aren't, nor are (I imagine?)
CONFIG_INITRAMFS_SOURCE's despite also being file paths, so taking
responsibility for escaping means handling several options
individually :/
?
Your comment

This issue is archived.

To comment on this conversation send email to 54713@debbugs.gnu.org