From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pierre Neidhardt Subject: Re: [BLOG] custom kernel config Date: Thu, 16 May 2019 13:48:03 +0200 Message-ID: <87k1eq62oc.fsf@ambrevar.xyz> References: <20190401180434.GF21029@macbook41> <20190515180945.GA7636@macbook41> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:44901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRF5y-0002ER-L8 for guix-devel@gnu.org; Thu, 16 May 2019 08:02:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRErs-0004Hf-Ok for guix-devel@gnu.org; Thu, 16 May 2019 07:48:13 -0400 In-Reply-To: <20190515180945.GA7636@macbook41> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Efraim Flashner , guix-devel@gnu.org, Ludovic Courts , Chris Marusich --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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 "=3Dm", so in the end it looks > like this: > ```shell > CONFIG_INPUT_PCSPKR=3Dm > CONFIG_VIRTIO=3Dm 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 wor= k. So I wrote those quick and dirty Emacs functions: =2D-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=3D value "m") (string=3D 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 "[=3D ]") nil 'noerror)) (warn "Variable %S not found" var) (beginning-of-line) (let ((kill-whole-line nil)) (kill-line)) (insert (format "%s=3Dy" 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")) =2D-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? =2D-=20 Pierre Neidhardt https://ambrevar.xyz/ --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEUPM+LlsMPZAEJKvom9z0l6S7zH8FAlzdTfMACgkQm9z0l6S7 zH9kRwf/XCQBKjwNFvsjWTyHcm6z3bGYBbqGd3cx78p2mdODhe4QLciOhAtYsnqZ 301MNtWPhgwqEKnK3TTA8c716I8FPFFsa218nrdEzjO/hqVZgBw57FYDYY1pWfYC G8p9WqVt7Mr+geMooKBhcs0xLMmVHH2uiIiZNHQ4N3e6RagqVJ9swgtAdUN0YGHU 28NBU66R/xCrD+UgsWODU4b6SKwJOo5j8cNW4VBMJJ2AbQ4L3ZcE+t/JIrSPuSpr YjdBQ3xUdCxkWDuVFi2nBfKP/dLWQ20g56TrEWnhHOeNe3ylfaKqVJtuG8gLOz+/ NXMNJFBSgWO9sXMTiudF9o0jJUyi5A== =t2UV -----END PGP SIGNATURE----- --=-=-=--