all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pierre Neidhardt <mail@ambrevar.xyz>
To: Efraim Flashner <efraim@flashner.co.il>,
	guix-devel@gnu.org, Ludovic Courts <ludo@gnu.org>,
	Chris Marusich <cmmarusich@gmail.com>
Subject: Re: [BLOG] custom kernel config
Date: Thu, 16 May 2019 13:48:03 +0200	[thread overview]
Message-ID: <87k1eq62oc.fsf@ambrevar.xyz> (raw)
In-Reply-To: <20190515180945.GA7636@macbook41>

[-- Attachment #1: Type: text/plain, Size: 2908 bytes --]

Another thing:

> The next step is to run
>
> ```shell
> make localmodconfig
> ```
>
> and note the output.  Do note that the '.config' file is still empty.
> The output generally contains two types of warnings.  The first start
> with "WARNING" and can actually be ignored in our case.  The second read:
> ```shell
> module pcspkr did not have configs CONFIG_INPUT_PCSPKR
> ```
>
> For each of these lines, copy the CONFIG_XXXX_XXXX portion into the
> '.config' in the directory, and append "=m", so in the end it looks
> like this:
> ```shell
> CONFIG_INPUT_PCSPKR=m
> CONFIG_VIRTIO=m

Since I'm not starting from a blank .config, I wanted to compare the
output of `make localmodconfig' and, even better, automatically enable all
the missing modules.

In my case there was some 150 modules and that would have been a lot of work.

So I wrote those quick and dirty Emacs functions:

--8<---------------cut here---------------start------------->8---
(defun kernel-compare-configs (file1 file2)
  "Go through all CONFIG_* variables in FILE1 and report those in
  file2 which are not set."
  (interactive "f\nf")
  (let ((buffer1 (find-file-noselect file1))
        (buffer2 (find-file-noselect file2))
        result)
    (with-current-buffer buffer1
      (goto-char (point-min))
      (while (search-forward "CONFIG_" nil 'noerror)
        (let ((var (symbol-name (sexp-at-point))))
          (with-current-buffer buffer2
            (goto-char (point-min))
            (when (search-forward var nil 'noerror)
              (forward-char)
              (let ((value (word-at-point)))
                (unless (or (string= value "m")
                            (string= value "y"))
                  (push var result))))))))
    result))

(defun kernel-enable-configs (file variables)
  "Variables must be a list of strings.
Example:
  (\"CONFIG_MODULES\")"
  (let ((buffer (find-file-noselect file)))
    (with-current-buffer buffer
      (dolist (var variables)
        (goto-char (point-min))
        ;; Match exact variable only, e.g. CONFIG_MODULES should not match
        ;; CONFIG_MODULES_TREE_LOOKUP.
        (if (not (re-search-forward (concat var "[= ]") nil 'noerror))
            (warn "Variable %S not found" var)
          (beginning-of-line)
          (let ((kill-whole-line nil))
            (kill-line))
          (insert (format "%s=y" var)))))))

;; Example:
; (kernel-enable-configs
;  "/home/ambrevar/.guix-packages/ambrevar/linux-laptop.conf"
;  (compare-kernel-configs
;   "localmodconfig.config"
;   "/home/ambrevar/.guix-packages/ambrevar/linux-laptop.conf"))
--8<---------------cut here---------------end--------------->8---

The above is not general enough but that's a start.

I wonder if there aren't some dedicated tools out there already.  Anyone?

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  parent reply	other threads:[~2019-05-16 12:02 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 18:04 custom kernel config Efraim Flashner
2019-04-01 18:30 ` Pierre Neidhardt
2019-04-02  5:37   ` Efraim Flashner
2019-04-02  8:04     ` Pierre Neidhardt
2019-04-02 14:49       ` Efraim Flashner
2019-04-01 19:46 ` Ludovic Courtès
2019-04-02 14:50   ` Efraim Flashner
2019-04-03  8:08 ` Chris Marusich
2019-04-03 19:04   ` Efraim Flashner
2019-04-03 19:49     ` Pierre Neidhardt
2019-04-03 20:27       ` Efraim Flashner
2019-04-04  8:44         ` Chris Marusich
2019-04-07 14:36           ` Efraim Flashner
2019-04-07 17:25             ` Pierre Neidhardt
2019-04-08 14:52             ` Ludovic Courtès
2019-04-08 15:03               ` Pierre Neidhardt
2019-05-01  7:54                 ` Pierre Neidhardt
2019-05-06  3:46                   ` Chris Marusich
2019-05-06  8:01                     ` Efraim Flashner
2019-05-06  8:34                       ` Pierre Neidhardt
2019-05-01  9:31               ` Mark H Weaver
2019-05-01 14:15                 ` Ludovic Courtès
2019-05-15 18:09 ` [BLOG] " Efraim Flashner
2019-05-16 11:10   ` Pierre Neidhardt
2019-05-16 19:15     ` Efraim Flashner
2019-05-16 11:48   ` Pierre Neidhardt [this message]
2019-05-16 14:29   ` Marius Bakke
2019-05-16 14:33     ` Pierre Neidhardt
2019-05-16 19:14     ` Efraim Flashner
2019-05-17  0:15     ` Mark H Weaver
2019-05-17  7:50       ` Efraim Flashner
2019-05-20 14:57         ` Ludovic Courtès
2019-05-20 17:38           ` Efraim Flashner
2019-05-21 10:07             ` Ludovic Courtès
2019-05-21 12:46               ` zimoun
2019-05-18  2:04       ` ison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k1eq62oc.fsf@ambrevar.xyz \
    --to=mail@ambrevar.xyz \
    --cc=cmmarusich@gmail.com \
    --cc=efraim@flashner.co.il \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.