From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:51608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBP6k-0005J9-F6 for guix-patches@gnu.org; Tue, 02 Apr 2019 15:30:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBP6i-00052B-N7 for guix-patches@gnu.org; Tue, 02 Apr 2019 15:30:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56431) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hBP6h-00051d-Jn for guix-patches@gnu.org; Tue, 02 Apr 2019 15:30:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hBP6h-0003FC-Fr for guix-patches@gnu.org; Tue, 02 Apr 2019 15:30:03 -0400 Subject: [bug#35110] [PATCH 1/3] gnu: Add make-linux-module. Resent-Message-ID: From: Danny Milosavljevic Date: Tue, 2 Apr 2019 21:28:53 +0200 Message-Id: <20190402192855.5314-1-dannym@scratchpost.org> In-Reply-To: <20190402192729.5262-1-dannym@scratchpost.org> References: <20190402192729.5262-1-dannym@scratchpost.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 35110@debbugs.gnu.org * gnu/packages/linux.scm (make-linux-module): New procedure. --- gnu/packages/linux.scm | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 9e4261eb02..55a314258f 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -415,6 +415,72 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration." It has been modified to remove all non-free binary blobs.") (license license:gpl2))) +;; FIXME: Remove CONFIG_MODULE_SRCVERSION_ALL=y from our configs. +(define (make-linux-module linux module) + "Given a LINUX package and a MODULE package, build MODULE using LINUX." + (let ((linux-source + (package + (inherit linux) + (name "linux-source") + (arguments + (substitute-keyword-arguments (package-arguments linux) + ((#:phases phases) + `(modify-phases ,phases + (replace 'build + (lambda _ + (invoke "make" "modules_prepare"))) + (delete 'strip) ; faster. + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (out-lib-build (string-append out "/lib/modules/build"))) + ; TODO: Only preserve the minimum, i.e. [Kbuild], Kconfig, scripts, include, ".config". + (copy-recursively "." out-lib-build) + #t)))))))))) + (package + (inherit module) + (name (string-append (package-name module) "-" (package-name linux))) + (native-inputs + `(("linux-source" ,linux-source) + ("kmod" ,kmod) + ;("elfutils" ,elfutils) ; Needed to enable CONFIG_STACK_VALIDATION + ("gcc" ,gcc-7) + ,@(package-native-inputs module))) + (arguments + (substitute-keyword-arguments + (default-keyword-arguments (package-arguments module) + `(#:phases #f + #:make-flags '())) + ((#:phases phases) + `(modify-phases ,phases + (replace 'build + (lambda* (#:key inputs make-flags #:allow-other-keys) + (apply invoke "make" "-C" + (string-append (assoc-ref inputs "linux-source") + "/lib/modules/build") + (string-append "M=" (getcwd)) + make-flags))) + ;; This block was copied from make-linux-libre--only took the + ;; "modules_install" part. + (replace 'install + (lambda* (#: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"))) + ;; Install kernel modules + (mkdir-p moddir) + (invoke "make" + "-C" + (string-append (assoc-ref inputs "linux-source") + "/lib/modules/build") + (string-append "M=" (getcwd)) + (string-append "DEPMOD=" kmod "/bin/depmod") + (string-append "MODULE_DIR=" moddir) + (string-append "INSTALL_PATH=" out) + (string-append "INSTALL_MOD_PATH=" out) + "INSTALL_MOD_STRIP=1" + "modules_install"))))))))))) + (define %linux-libre-version "5.0.5") (define %linux-libre-hash "1yivxqprxfzhzid4qv9hpnb5i38kijrj2g2pyzz7niliya1c58li")