From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id c6SWOnZ17F7wUgAA0tVLHw (envelope-from ) for ; Fri, 19 Jun 2020 08:21:10 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id eJzsNXZ17F5BJAAA1q6Kng (envelope-from ) for ; Fri, 19 Jun 2020 08:21:10 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 340A59401CB for ; Fri, 19 Jun 2020 08:21:10 +0000 (UTC) Received: from localhost ([::1]:42756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmCGq-0004bG-Le for larch@yhetil.org; Fri, 19 Jun 2020 04:21:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmCGk-0004b5-1g for guix-patches@gnu.org; Fri, 19 Jun 2020 04:21:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:43524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmCGj-0002MR-PA for guix-patches@gnu.org; Fri, 19 Jun 2020 04:21:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jmCGj-00054p-KX for guix-patches@gnu.org; Fri, 19 Jun 2020 04:21:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41924] [PATCH] profiles: Make linux-module-database skip inappropriate inputs Resent-From: Ivan Kozlov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 19 Jun 2020 08:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41924 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Danny Milosavljevic Cc: "41924@debbugs.gnu.org" <41924@debbugs.gnu.org> Received: via spool by 41924-submit@debbugs.gnu.org id=B41924.159255484919489 (code B ref 41924); Fri, 19 Jun 2020 08:21:01 +0000 Received: (at 41924) by debbugs.gnu.org; 19 Jun 2020 08:20:49 +0000 Received: from localhost ([127.0.0.1]:55070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jmCGW-00054G-R4 for submit@debbugs.gnu.org; Fri, 19 Jun 2020 04:20:49 -0400 Received: from forward501p.mail.yandex.net ([77.88.28.111]:34747) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jmCGS-00053w-Dv for 41924@debbugs.gnu.org; Fri, 19 Jun 2020 04:20:47 -0400 Received: from mxback19j.mail.yandex.net (mxback19j.mail.yandex.net [IPv6:2a02:6b8:0:1619::95]) by forward501p.mail.yandex.net (Yandex) with ESMTP id C22A23500733; Fri, 19 Jun 2020 11:20:37 +0300 (MSK) Received: from localhost (localhost [::1]) by mxback19j.mail.yandex.net (mxback/Yandex) with ESMTP id S5naOWrrpz-Kan8GrG5; Fri, 19 Jun 2020 11:20:37 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1592554837; bh=RpEfpHvKVZHO4fOPMbVth3tpzJ0FTMHTMyFT3WgMEMo=; h=Message-Id:Cc:Subject:In-Reply-To:Date:References:To:From; b=Qgka/uK6bv4xQDo2Ui64nMMJTfdL46A3HjGgwJjriu92gkjuquHW+iVmqXe8SelAk Epw80YBBdNufuV6SRmk4g1vRHfnbwlKKUHTforV9twKsnrPrWSZ85H1K078CNcuZ2n V9qm7K2wD9hd+usxLQyZU/Sn1NT9YDmteMHXoMXc= Received: by iva6-22e79380f52c.qloud-c.yandex.net with HTTP; Fri, 19 Jun 2020 11:20:36 +0300 From: Ivan Kozlov In-Reply-To: <20200618201647.73f8b0d5@scratchpost.org> References: <169811592419302@mail.yandex.ru> <20200618201647.73f8b0d5@scratchpost.org> MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Fri, 19 Jun 2020 11:20:36 +0300 Message-Id: <3181592520939@mail.yandex.ru> Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.7 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=yandex.ru header.s=mail header.b=Qgka/uK6; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yandex.ru (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: Pn32twb/jv8i Hi, > What I would do is try to find a file that's only in the kernel when there's > module support (/lib/modules doesn't count since there could be a kernel with > module support but no modules compiled), and then try to ascertain whether > CONFIG_MODULES=y that way, so > (define config-modules? (any (append-map directory-entries with marker-file))) > or something. The only way to do this sort of thing is to have the config. Otherwise the kernel will always sort of exist in a separate world. You can always compile it in a way that breaks the rest of the Guix system’s assumptions, e.g. by disabling the necessary system calls or cgroups controllers, and get no warnings/build failures. This applies to any extra kernel modules, too. I don’t think LKM support stands out. I actually don’t think it is a big problem that using an unofficial Linux package puts some burden on the maintainer, I merely want such setups to be possible. The problem in question really applies to all cases when there aren’t any modules to deal with, as you correctly point out, not necessary having to do with CONFIG_MODULES; e.g. building a system with CONFIG_MODULES=y and no loadable modules, and no extra modules, is perfectly legitimate. > That would silently skip packages that don't contain kernel modules (but for > example supertux or something), too, right? > (so misconfigured guix wouldn't be detected) It is possible to rely on the way operating-system-directory-base-entries builds the manifest to avoid this specific issue: (car #$(manifest-inputs manifest)) should be the kernel. I haven’t really looked into the test suite, here is my guess: diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scm index 953b132ef7..2fc8f52b90 100644 --- a/gnu/tests/linux-modules.scm +++ b/gnu/tests/linux-modules.scm @@ -25,6 +25,7 @@ #:use-module (gnu system) #:use-module (gnu system vm) #:use-module (gnu tests) + #:use-module (gnu tests base) #:use-module (guix derivations) #:use-module (guix gexp) #:use-module (guix modules) @@ -129,3 +130,37 @@ with two extra modules.") (package-arguments ddcci-driver-linux)))))) '("acpi_call" "ddcci"))))) + +(define %test-no-loadable-kernel-modules + (let* ((kernel (package + (inherit linux-libre) + (arguments + (substitute-keyword-arguments (package-arguments linux-libre) + ((#:phases phases) + `(modify-phases ,phases + (add-before 'build 'no-lkm-config + (lambda _ + (substitute* ".config" + (("=m") "=y")) + (let ((port (open-file ".config" "a"))) + (display "CONFIG_MODULES=n" port) + (close-port port)))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (for-each + (let ((out (assoc-ref outputs "out"))) + (lambda (file) (install-file file out))) + (find-files "." "^(\\.config|bzImage|zImage|Image|vmlinuz|System\\.map|Module\\.symvers)$")))))))))) + (os (marionette-operating-system + (operating-system + (inherit (simple-operating-system)) + (kernel kernel) + (initrd-modules '())) + #:imported-modules '((gnu services herd) + (guix combinators)))) + (vm (virtual-machine os))) + (system-test + (name "no-loadable-kernel-modules") + (description "Build and run a basic system without loadable kernel module support") + (value (run-basic-test (virtualized-operating-system os '()) + #~(list #$vm)))))) diff --git a/guix/profiles.scm b/guix/profiles.scm index 25ff146bdf..abf0cf7f27 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -1201,6 +1201,8 @@ for both major versions of GTK+." "Return a derivation that unites all the kernel modules of the manifest and creates the dependency graph of all these kernel modules. +The first entry in the manifest must be a Linux kernel package. + This is meant to be used as a profile hook." (define kmod ; lazy reference (module-ref (resolve-interface '(gnu packages linux)) 'kmod)) @@ -1226,14 +1228,22 @@ This is meant to be used as a profile hook." ;; Note: Should usually result in one entry. (versions (delete-duplicates (append-map directory-entries - module-directories)))) - (match versions - ((version) - (let ((old-path (getenv "PATH"))) - (setenv "PATH" #+(file-append kmod "/bin")) - (make-linux-module-directory inputs version #$output) - (setenv "PATH" old-path))) - (_ (error "Specified Linux kernel and Linux kernel modules + (if (file-exists? (car module-directories)) + module-directories + (cdr module-directories)))))) + (match versions + ((version) + (let ((old-path (getenv "PATH"))) + (setenv "PATH" #+(file-append kmod "/bin")) + (make-linux-module-directory inputs version #$output) + (setenv "PATH" old-path))) + ;; Do nothing when there is nothing to do + (() (mkdir #$output)) + ;; This might not catch a version incompatibility + ;; if all kernel modules reside in extra packages + ;; Would checking the kernel package version have + ;; undesirable effects? + (_ (error "Specified Linux kernel and Linux kernel modules are not all of the same version"))))))) (gexp->derivation "linux-module-database" build #:local-build? #t