From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:55980) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMvzz-0006tI-Ms for guix-patches@gnu.org; Tue, 22 Oct 2019 11:23:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMvzy-0003sD-6v for guix-patches@gnu.org; Tue, 22 Oct 2019 11:23:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:51517) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iMvzy-0003s7-3H for guix-patches@gnu.org; Tue, 22 Oct 2019 11:23:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iMvzx-0006FK-UX for guix-patches@gnu.org; Tue, 22 Oct 2019 11:23:01 -0400 Subject: [bug#37868] [PATCH] guix: Allow multiple packages to provide Linux modules in the system profile. Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:55953) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMvzi-0006rO-JI for guix-patches@gnu.org; Tue, 22 Oct 2019 11:22:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMvzg-0003hE-Dt for guix-patches@gnu.org; Tue, 22 Oct 2019 11:22:46 -0400 Received: from dd26836.kasserver.com ([85.13.145.193]:60970) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iMvzg-0003fg-19 for guix-patches@gnu.org; Tue, 22 Oct 2019 11:22:44 -0400 From: Danny Milosavljevic Date: Tue, 22 Oct 2019 17:22:38 +0200 Message-Id: <20191022152238.12856-1-dannym@scratchpost.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 37868@debbugs.gnu.org Cc: Danny Milosavljevic * guix/profiles.scm (linux-module-database): New procedure. (%default-profile-hooks): Add it. * gnu/system.scm (operating-system-profile): Add kernel to what profile-service-type gives. * gnu/services.scm (%modprobe-wrapper): Use that profile. * guix/build/linux-module-build-system.scm (install): Disable DEPMOD. --- gnu/services.scm | 7 ++- gnu/system.scm | 8 ++- guix/build/linux-module-build-system.scm | 5 +- guix/profiles.scm | 75 +++++++++++++++++++++++- 4 files changed, 87 insertions(+), 8 deletions(-) diff --git a/gnu/services.scm b/gnu/services.scm index 6ee05d4580..2a6d2bc464 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -491,7 +491,12 @@ ACTIVATION-SCRIPT-TYPE." (program-file "modprobe" #~(begin (setenv "LINUX_MODULE_DIRECTORY" - "/run/booted-system/kernel/lib/modules") + (if (file-exists? + "/run/booted-system/profile/lib/modul= es") + "/run/booted-system/profile/lib/module= s" + ;; Provides compatibility with previou= s + ;; Guix generations. + "/run/booted-system/kernel/lib/modules= ")) (apply execl #$modprobe (cons #$modprobe (cdr (command-line)))))))) =20 diff --git a/gnu/system.scm b/gnu/system.scm index a353b1a5c8..66270b38bb 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -887,12 +887,14 @@ we're running in the final root." (define* (operating-system-profile os) "Return a derivation that builds the system profile of OS." (mlet* %store-monad - ((services -> (operating-system-services os)) + ((kernel -> (operating-system-kernel os)) + (services -> (operating-system-services os)) (profile (fold-services services - #:target-type profile-service-type))) + #:target-type + profile-service-type))) (match profile (("profile" profile) - (return profile))))) + (return (cons kernel profile)))))) ; FIXME: Doesn't work for some= reason. I don't think this place is ever reached. =20 (define (operating-system-root-file-system os) "Return the root file system of OS." diff --git a/guix/build/linux-module-build-system.scm b/guix/build/linux-= module-build-system.scm index cd76df2de7..e4e6993a49 100644 --- a/guix/build/linux-module-build-system.scm +++ b/guix/build/linux-module-build-system.scm @@ -60,15 +60,14 @@ ;; part. (define* (install #:key inputs native-inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) - (moddir (string-append out "/lib/modules")) - (kmod (assoc-ref (or native-inputs inputs) "kmod"))) + (moddir (string-append out "/lib/modules"))) ;; Install kernel modules (mkdir-p moddir) (invoke "make" "-C" (string-append (assoc-ref inputs "linux-module-builder") "/lib/modules/build") (string-append "M=3D" (getcwd)) - (string-append "DEPMOD=3D" kmod "/bin/depmod") + "DEPMOD=3Dtrue" ; disable depmod. (string-append "MODULE_DIR=3D" moddir) (string-append "INSTALL_PATH=3D" out) (string-append "INSTALL_MOD_PATH=3D" out) diff --git a/guix/profiles.scm b/guix/profiles.scm index cd3b21e390..fd77392588 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -9,6 +9,7 @@ ;;; Copyright =C2=A9 2017 Huang Ying ;;; Copyright =C2=A9 2017 Maxim Cournoyer ;;; Copyright =C2=A9 2019 Kyle Meyer +;;; Copyright =C2=A9 2019 Danny Milosavljevic ;;; ;;; This file is part of GNU Guix. ;;; @@ -1125,6 +1126,77 @@ for both major versions of GTK+." (hook . gtk-im-modules))) (return #f))))) =20 +(define (linux-module-database manifest) + (mlet %store-monad + ((kmod (manifest-lookup-package manifest "kmod"))) + (define build + (with-imported-modules '((guix build utils) + (guix build union)) + #~(begin + (use-modules (srfi srfi-1) + (srfi srfi-26) + (guix build utils) + (guix build union) + (ice-9 ftw) + (ice-9 match)) + (let* ((inputs '#$(manifest-inputs manifest)) + (input-files (lambda (path) + (filter file-exists? + (map (cut string-append <> path) input= s)))) + (module-directories (input-files "/lib/modules")) + (System.maps (input-files "/System.map")) + (Module.symverss (input-files "/Module.symvers")) + (directory-entries (lambda (directory-name) + (filter (lambda (basename) + (not (string-prefix? ".= " + ba= sename))) + (scandir directory-name))= )) + ;; Note: Should result in one entry. + (versions (append-map directory-entries module-director= ies))) + ;; TODO: if len(module-directories) =3D=3D 1: return modul= e-directories[0] + (mkdir-p (string-append #$output "/lib/modules")) + ;; Iterate over each kernel version directory (usually one= ). + (for-each (lambda (version) + (let ((destination-directory (string-append #$= output "/lib/modules/" version))) + (when (not (file-exists? destination-directo= ry)) ; unique + (union-build destination-directory + ;; All directories with the s= ame version as us. + (filter-map (lambda (director= y-name) + (if (member ver= sion + (di= rectory-entries directory-name)) + (string-app= end directory-name "/" version) + #f)) + module-directorie= s) + #:create-all-directories? #t) + ;; Delete generated files (they will be re= created shortly). + (for-each (lambda (basename) + (when (string-prefix? "modules= ." basename) + (false-if-file-not-found + (delete-file + (string-append + destination-directory "/= " + basename))))) + (directory-entries destination-d= irectory)) + (unless (zero? (system* (string-append #$k= mod "/bin/depmod") + "-e" ; Report symb= ols that aren't supplied + "-w" ; Warn on dup= licates + "-b" #$output ; de= stination-directory + "-F" (match System= .maps + ((x) x)) + "-E" (match Module= .symverss + ((x) x)) + version)) + (display "FAILED\n" (current-error-port)= ) + (exit #f))))) + versions) + (exit #t))))) + (gexp->derivation "linux-module-database" build + #:local-build? #t + #:substitutable? #f + #:properties + `((type . profile-hook) + (hook . linux-module-database))))) + (define (xdg-desktop-database manifest) "Return a derivation that builds the @file{mimeinfo.cache} database fr= om desktop files. It's used to query what applications can handle a given @@ -1425,7 +1497,8 @@ MANIFEST." gtk-im-modules texlive-configuration xdg-desktop-database - xdg-mime-database)) + xdg-mime-database + linux-module-database)) =20 (define* (profile-derivation manifest #:key