* [bug#35110] [PATCH 0/3] Add support for loadable modules.
@ 2019-04-02 19:27 Danny Milosavljevic
2019-04-02 19:28 ` [bug#35110] [PATCH 1/3] gnu: Add make-linux-module Danny Milosavljevic
2019-04-05 11:05 ` [bug#35110] [PATCH v2 0/2] Add support for loadable modules Danny Milosavljevic
0 siblings, 2 replies; 16+ messages in thread
From: Danny Milosavljevic @ 2019-04-02 19:27 UTC (permalink / raw)
To: 35110
Danny Milosavljevic (2):
gnu: Add make-linux-module.
gnu: linux-libre: Disable module versioning.
Pierre Neidhardt (1):
gnu: Add vhba-module-linux-libre.
.../aux-files/linux-libre/5.0-x86_64.conf | 2 +-
gnu/packages/linux.scm | 94 +++++++++++++++++++
2 files changed, 95 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH 1/3] gnu: Add make-linux-module.
2019-04-02 19:27 [bug#35110] [PATCH 0/3] Add support for loadable modules Danny Milosavljevic
@ 2019-04-02 19:28 ` Danny Milosavljevic
2019-04-02 19:28 ` [bug#35110] [PATCH 2/3] gnu: Add vhba-module-linux-libre Danny Milosavljevic
` (2 more replies)
2019-04-05 11:05 ` [bug#35110] [PATCH v2 0/2] Add support for loadable modules Danny Milosavljevic
1 sibling, 3 replies; 16+ messages in thread
From: Danny Milosavljevic @ 2019-04-02 19:28 UTC (permalink / raw)
To: 35110
* 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")
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH 2/3] gnu: Add vhba-module-linux-libre.
2019-04-02 19:28 ` [bug#35110] [PATCH 1/3] gnu: Add make-linux-module Danny Milosavljevic
@ 2019-04-02 19:28 ` Danny Milosavljevic
2019-04-02 21:51 ` Pierre Neidhardt
2019-04-02 19:28 ` [bug#35110] [PATCH 3/3] gnu: linux-libre: Disable module versioning Danny Milosavljevic
2019-04-03 20:16 ` [bug#35110] [PATCH 1/3] gnu: Add make-linux-module Ludovic Courtès
2 siblings, 1 reply; 16+ messages in thread
From: Danny Milosavljevic @ 2019-04-02 19:28 UTC (permalink / raw)
To: 35110; +Cc: Pierre Neidhardt
From: Pierre Neidhardt <mail@ambrevar.xyz>
* gnu/packages/linux.scm (vhba-module): New variable.
(vhba-module-linux-libre): New variable. Export it.
Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
---
gnu/packages/linux.scm | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 55a314258f..a2adb9b13d 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -495,6 +495,34 @@ It has been modified to remove all non-free binary blobs.")
#:patches %linux-libre-5.0-patches
#:configuration-file kernel-config))
+(define vhba-module
+ (package
+ (name "vhba-module")
+ (version "20170610")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append
+ "http://downloads.sourceforge.net/cdemu/vhba-module-"
+ version ".tar.bz2"))
+ (sha256
+ (base32
+ "1v6r0bgx0a65vlh36b1l2965xybngbpga6rp54k4z74xk0zwjw3r"))))
+ (build-system gnu-build-system)
+ (arguments
+ ;; TODO: No tests?
+ `(#:tests? #f
+ #:phases
+ (modify-phases %standard-phases
+ (delete 'configure))))
+ (home-page "https://cdemu.sourceforge.io/")
+ (synopsis "Kernel module that emulates SCSI devices")
+ (description "VHBA module provides a Virtual (SCSI) HBA, which is the link
+between the CDemu userspace daemon and linux kernel.")
+ (license license:gpl2+)))
+
+(define-public vhba-module-linux-libre
+ (make-linux-module linux-libre vhba-module))
+
(define %linux-libre-4.19-version "4.19.32")
(define %linux-libre-4.19-hash "19bryl8nmnnnrfh91pc8q9yiayh5ca2nb6b32qyx6riahc5dy0i9")
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH 3/3] gnu: linux-libre: Disable module versioning.
2019-04-02 19:28 ` [bug#35110] [PATCH 1/3] gnu: Add make-linux-module Danny Milosavljevic
2019-04-02 19:28 ` [bug#35110] [PATCH 2/3] gnu: Add vhba-module-linux-libre Danny Milosavljevic
@ 2019-04-02 19:28 ` Danny Milosavljevic
2019-04-03 20:16 ` [bug#35110] [PATCH 1/3] gnu: Add make-linux-module Ludovic Courtès
2 siblings, 0 replies; 16+ messages in thread
From: Danny Milosavljevic @ 2019-04-02 19:28 UTC (permalink / raw)
To: 35110
* gnu/packages/aux-files/linux-libre/5.0-x86_64.conf: Remove
CONFIG_MODULE_SRCVERSION_ALL.
---
gnu/packages/aux-files/linux-libre/5.0-x86_64.conf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gnu/packages/aux-files/linux-libre/5.0-x86_64.conf b/gnu/packages/aux-files/linux-libre/5.0-x86_64.conf
index 9e1a7eff0e..193413110f 100644
--- a/gnu/packages/aux-files/linux-libre/5.0-x86_64.conf
+++ b/gnu/packages/aux-files/linux-libre/5.0-x86_64.conf
@@ -794,7 +794,7 @@ CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
# CONFIG_MODULE_FORCE_UNLOAD is not set
CONFIG_MODVERSIONS=y
-CONFIG_MODULE_SRCVERSION_ALL=y
+# CONFIG_MODULE_SRCVERSION_ALL is not set
# CONFIG_MODULE_SIG is not set
# CONFIG_MODULE_COMPRESS is not set
CONFIG_MODULES_TREE_LOOKUP=y
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH 2/3] gnu: Add vhba-module-linux-libre.
2019-04-02 19:28 ` [bug#35110] [PATCH 2/3] gnu: Add vhba-module-linux-libre Danny Milosavljevic
@ 2019-04-02 21:51 ` Pierre Neidhardt
2019-04-02 22:36 ` Danny Milosavljevic
0 siblings, 1 reply; 16+ messages in thread
From: Pierre Neidhardt @ 2019-04-02 21:51 UTC (permalink / raw)
To: Danny Milosavljevic, 35110
[-- Attachment #1: Type: text/plain, Size: 292 bytes --]
Thanks for looking into this!
Danny Milosavljevic <dannym@scratchpost.org> writes:
> +(define-public vhba-module-linux-libre
> + (make-linux-module linux-libre vhba-module))
What is make-linux-module? I cannot find it on master :p
--
Pierre Neidhardt
https://ambrevar.xyz/
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH 2/3] gnu: Add vhba-module-linux-libre.
2019-04-02 21:51 ` Pierre Neidhardt
@ 2019-04-02 22:36 ` Danny Milosavljevic
2019-04-03 6:48 ` Pierre Neidhardt
0 siblings, 1 reply; 16+ messages in thread
From: Danny Milosavljevic @ 2019-04-02 22:36 UTC (permalink / raw)
To: Pierre Neidhardt; +Cc: 35110
[-- Attachment #1: Type: text/plain, Size: 74 bytes --]
See PATCH 1/3, Message ID <20190402192855.5314-1-dannym@scratchpost.org>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH 2/3] gnu: Add vhba-module-linux-libre.
2019-04-02 22:36 ` Danny Milosavljevic
@ 2019-04-03 6:48 ` Pierre Neidhardt
0 siblings, 0 replies; 16+ messages in thread
From: Pierre Neidhardt @ 2019-04-03 6:48 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: 35110
[-- Attachment #1: Type: text/plain, Size: 89 bytes --]
Brilliant! Thank you so much for this!
--
Pierre Neidhardt
https://ambrevar.xyz/
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH 1/3] gnu: Add make-linux-module.
2019-04-02 19:28 ` [bug#35110] [PATCH 1/3] gnu: Add make-linux-module Danny Milosavljevic
2019-04-02 19:28 ` [bug#35110] [PATCH 2/3] gnu: Add vhba-module-linux-libre Danny Milosavljevic
2019-04-02 19:28 ` [bug#35110] [PATCH 3/3] gnu: linux-libre: Disable module versioning Danny Milosavljevic
@ 2019-04-03 20:16 ` Ludovic Courtès
2019-04-03 20:48 ` Danny Milosavljevic
2 siblings, 1 reply; 16+ messages in thread
From: Ludovic Courtès @ 2019-04-03 20:16 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: 35110
Hi Danny,
Danny Milosavljevic <dannym@scratchpost.org> skribis:
> * gnu/packages/linux.scm (make-linux-module): New procedure.
Neat!
Would it make sense to turn it into a ‘linux-module-build-system’? That
would avoid having to create a package object that cannot be built, just
to pass it to ‘make-linux-module’. ‘linux-libre’ and ‘kmod’ would be
implicit inputs.
> +;; FIXME: Remove CONFIG_MODULE_SRCVERSION_ALL=y from our configs.
What does that flag do?
> + (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)
Is it OK to use the default GCC?
Other than that it looks really cool!
Thank you,
Ludo’.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH 1/3] gnu: Add make-linux-module.
2019-04-03 20:16 ` [bug#35110] [PATCH 1/3] gnu: Add make-linux-module Ludovic Courtès
@ 2019-04-03 20:48 ` Danny Milosavljevic
2019-04-04 7:48 ` Ludovic Courtès
0 siblings, 1 reply; 16+ messages in thread
From: Danny Milosavljevic @ 2019-04-03 20:48 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 35110
[-- Attachment #1: Type: text/plain, Size: 2360 bytes --]
Hi Ludo,
On Wed, 03 Apr 2019 22:16:07 +0200
Ludovic Courtès <ludo@gnu.org> wrote:
> Would it make sense to turn it into a ‘linux-module-build-system’?
I started on it but haven't finished it yet.
>That would avoid having to create a package object that cannot be built, just
It can be built, it's just not very useful standalone because it only contains
the source code and a few build artifacts (only the ones required to start
building a module). On the other hand it can be substituted and that's nice
(if we can cut down the source code a lot, that is).
I don't understand how a build system would enable us to remove this step.
(If it can, that's cool!)
> to pass it to ‘make-linux-module’. ‘linux-libre’ and ‘kmod’ would be
> implicit inputs.
>
> > +;; FIXME: Remove CONFIG_MODULE_SRCVERSION_ALL=y from our configs.
>
> What does that flag do?
It adds a field "srcversion" to the ELF file of the module which is a hash of
all the source files used to build it.
Instead of removing it, we can also merge bug# 35111 instead and use that.
Otherwise, the problem is that if CONFIG_MODULE_SRCVERSION_ALL is set and
bug# 35111 not merged, one cannot build standalone modules because those
would require the file "Module.symvers" of the completely built kernel
to be available.
Linux would also write a new file "Module.symvers" in the MODPOST step of
the build of the module.
> Is it OK to use the default GCC?
Definitely not. It has to be exactly the same gcc as used in building the
Linux kernel.
> Other than that it looks really cool!
It's just a quick hack.
I've started with the build system but it was too much work and I didn't
understand the mechanisms well enough.
For example, the lowest maintenance overhead would be to somehow have
most of linux-libre's phases be injected into the module package and have
both build in one build environment. I.e. the module would have a package
which would actually have phases 'unpack 'prepare-linux 'build 'check 'install
where all the phases except for 'prepare-linux would be module-specific and
'prepare-linux would unpack the linux source and do everything just
like the linux-libre package would have done, up until the 'build phase.
It turned out that's too complicated to get to work for me for now.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH 1/3] gnu: Add make-linux-module.
2019-04-03 20:48 ` Danny Milosavljevic
@ 2019-04-04 7:48 ` Ludovic Courtès
0 siblings, 0 replies; 16+ messages in thread
From: Ludovic Courtès @ 2019-04-04 7:48 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: 35110
Hi Danny,
Danny Milosavljevic <dannym@scratchpost.org> skribis:
> On Wed, 03 Apr 2019 22:16:07 +0200
> Ludovic Courtès <ludo@gnu.org> wrote:
>
>> Would it make sense to turn it into a ‘linux-module-build-system’?
>
> I started on it but haven't finished it yet.
>
>>That would avoid having to create a package object that cannot be built, just
>
> It can be built, it's just not very useful standalone because it only contains
> the source code and a few build artifacts (only the ones required to start
> building a module). On the other hand it can be substituted and that's nice
> (if we can cut down the source code a lot, that is).
Can it be built (I’m talking about the ‘vhba-module’ package that you
sent)? I’d expect it to look for the Linux makefile snippet and to fail
at that point, no?
> I don't understand how a build system would enable us to remove this step.
> (If it can, that's cool!)
We’d directly write:
(define-public vhba-module
(package
(name "vhba-module")
;; …
(build-system linux-module-build-system))
and that would abstract away the choice of dependencies (linux-libre,
kmod, GCC) and the set of build phases.
>> > +;; FIXME: Remove CONFIG_MODULE_SRCVERSION_ALL=y from our configs.
>>
>> What does that flag do?
>
> It adds a field "srcversion" to the ELF file of the module which is a hash of
> all the source files used to build it.
>
> Instead of removing it, we can also merge bug# 35111 instead and use that.
>
> Otherwise, the problem is that if CONFIG_MODULE_SRCVERSION_ALL is set and
> bug# 35111 not merged, one cannot build standalone modules because those
> would require the file "Module.symvers" of the completely built kernel
> to be available.
>
> Linux would also write a new file "Module.symvers" in the MODPOST step of
> the build of the module.
OK. Sounds like we should merge #35111 then.
> For example, the lowest maintenance overhead would be to somehow have
> most of linux-libre's phases be injected into the module package and have
> both build in one build environment. I.e. the module would have a package
> which would actually have phases 'unpack 'prepare-linux 'build 'check 'install
> where all the phases except for 'prepare-linux would be module-specific and
> 'prepare-linux would unpack the linux source and do everything just
> like the linux-libre package would have done, up until the 'build phase.
> It turned out that's too complicated to get to work for me for now.
What about factorizing these phases in a new (guix build
linux-module-build-system) module, which would export them as
‘%standard-phases’? Then packages using ‘linux-module-build-system’
would use these phases by default, like we do for the other build
systems.
Does that make sense?
Thank you,
Ludo’.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH v2 0/2] Add support for loadable modules.
2019-04-02 19:27 [bug#35110] [PATCH 0/3] Add support for loadable modules Danny Milosavljevic
2019-04-02 19:28 ` [bug#35110] [PATCH 1/3] gnu: Add make-linux-module Danny Milosavljevic
@ 2019-04-05 11:05 ` Danny Milosavljevic
2019-04-05 11:05 ` [bug#35110] [PATCH v2 1/2] Add (guix build-system linux-module) Danny Milosavljevic
2019-04-05 11:05 ` [bug#35110] [PATCH v2 2/2] gnu: Add vhba-module Danny Milosavljevic
1 sibling, 2 replies; 16+ messages in thread
From: Danny Milosavljevic @ 2019-04-05 11:05 UTC (permalink / raw)
To: 35110
Danny Milosavljevic (1):
Add (guix build-system linux-module).
Pierre Neidhardt (1):
gnu: Add vhba-module.
Makefile.am | 2 +
gnu/packages/linux.scm | 23 ++++
guix/build-system/linux-module.scm | 166 +++++++++++++++++++++++
guix/build/linux-module-build-system.scm | 82 +++++++++++
4 files changed, 273 insertions(+)
create mode 100644 guix/build-system/linux-module.scm
create mode 100644 guix/build/linux-module-build-system.scm
^ permalink raw reply [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH v2 1/2] Add (guix build-system linux-module).
2019-04-05 11:05 ` [bug#35110] [PATCH v2 0/2] Add support for loadable modules Danny Milosavljevic
@ 2019-04-05 11:05 ` Danny Milosavljevic
2019-04-11 10:50 ` Ludovic Courtès
2019-04-05 11:05 ` [bug#35110] [PATCH v2 2/2] gnu: Add vhba-module Danny Milosavljevic
1 sibling, 1 reply; 16+ messages in thread
From: Danny Milosavljevic @ 2019-04-05 11:05 UTC (permalink / raw)
To: 35110
* guix/build/linux-module-build-system.scm: New file.
* guix/build-system/linux-module.scm: New file.
* Makefile.am (MODULES): Add them.
---
Makefile.am | 2 +
guix/build-system/linux-module.scm | 166 +++++++++++++++++++++++
guix/build/linux-module-build-system.scm | 82 +++++++++++
3 files changed, 250 insertions(+)
create mode 100644 guix/build-system/linux-module.scm
create mode 100644 guix/build/linux-module-build-system.scm
diff --git a/Makefile.am b/Makefile.am
index c331da7267..ea07632526 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -120,6 +120,7 @@ MODULES = \
guix/build-system/gnu.scm \
guix/build-system/guile.scm \
guix/build-system/haskell.scm \
+ guix/build-system/linux-module.scm \
guix/build-system/perl.scm \
guix/build-system/python.scm \
guix/build-system/ocaml.scm \
@@ -172,6 +173,7 @@ MODULES = \
guix/build/texlive-build-system.scm \
guix/build/waf-build-system.scm \
guix/build/haskell-build-system.scm \
+ guix/build/linux-module-build-system.scm \
guix/build/store-copy.scm \
guix/build/utils.scm \
guix/build/union.scm \
diff --git a/guix/build-system/linux-module.scm b/guix/build-system/linux-module.scm
new file mode 100644
index 0000000000..3ed3351353
--- /dev/null
+++ b/guix/build-system/linux-module.scm
@@ -0,0 +1,166 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 Danny Milosavljevic <dannym@scratchpost.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build-system linux-module)
+ #:use-module (guix store)
+ #:use-module (guix utils)
+ #:use-module (guix derivations)
+ #:use-module (guix search-paths)
+ #:use-module (guix build-system)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix packages)
+ #:use-module (ice-9 match)
+ #:export (%linux-module-build-system-modules
+ linux-module-build
+ linux-module-build-system))
+
+;; Commentary:
+;;
+;; Code:
+
+(define %linux-module-build-system-modules
+ ;; Build-side modules imported by default.
+ `((guix build linux-module-build-system)
+ ,@%gnu-build-system-modules))
+
+(define (default-linux)
+ "Return the default Linux package."
+
+ ;; Do not use `@' to avoid introducing circular dependencies.
+ (let ((module (resolve-interface '(gnu packages linux))))
+ (module-ref module 'linux-libre)))
+
+(define (default-kmod)
+ "Return the default kmod package."
+
+ ;; Do not use `@' to avoid introducing circular dependencies.
+ (let ((module (resolve-interface '(gnu packages linux))))
+ (module-ref module 'kmod)))
+
+(define (default-gcc)
+ "Return the default gcc package."
+
+ ;; Do not use `@' to avoid introducing circular dependencies.
+ (let ((module (resolve-interface '(gnu packages gcc))))
+ (module-ref module 'gcc-7)))
+
+(define (make-linux-module-builder linux)
+ (package
+ (inherit linux)
+ (name (string-append (package-name linux) "-module-builder"))
+ (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)))))))))
+
+(define* (lower name
+ #:key source inputs native-inputs outputs
+ system target
+ (linux (default-linux))
+ #:allow-other-keys
+ #:rest arguments)
+ "Return a bag for NAME."
+ (define private-keywords
+ '(#:source #:target #:gcc #:kmod #:linux #:inputs #:native-inputs))
+
+ (and (not target) ;XXX: no cross-compilation
+ (bag
+ (name name)
+ (system system)
+ (host-inputs `(,@(if source
+ `(("source" ,source))
+ '())
+ ,@inputs
+ ,@(standard-packages)))
+ (build-inputs `(("linux" ,linux) ; for "Module.symvers".
+ ("linux-module-builder"
+ ,(make-linux-module-builder linux))
+ ,@native-inputs
+ ;; TODO: Remove "gmp", "mpfr", "mpc" since they are only needed to compile the gcc plugins. Maybe remove "flex", "bison", "elfutils", "perl", "openssl". That leaves very little ("bc", "gcc", "kmod").
+ ,@(package-native-inputs linux)))
+ (outputs outputs)
+ (build linux-module-build)
+ (arguments (strip-keyword-arguments private-keywords arguments)))))
+
+(define* (linux-module-build store name inputs
+ #:key
+ (search-paths '())
+ (tests? #t)
+ (phases '(@ (guix build linux-module-build-system)
+ %standard-phases))
+ (outputs '("out"))
+ (system (%current-system))
+ (guile #f)
+ (imported-modules
+ %linux-module-build-system-modules)
+ (modules '((guix build linux-module-build-system)
+ (guix build utils))))
+ "Build SOURCE using LINUX, and with INPUTS."
+ (define builder
+ `(begin
+ (use-modules ,@modules)
+ (linux-module-build #:name ,name
+ #:source ,(match (assoc-ref inputs "source")
+ (((? derivation? source))
+ (derivation->output-path source))
+ ((source)
+ source)
+ (source
+ source))
+ #:search-paths ',(map search-path-specification->sexp
+ search-paths)
+ #:phases ,phases
+ #:system ,system
+ #:tests? ,tests?
+ #:outputs %outputs
+ #:inputs %build-inputs)))
+
+ (define guile-for-build
+ (match guile
+ ((? package?)
+ (package-derivation store guile system #:graft? #f))
+ (#f ; the default
+ (let* ((distro (resolve-interface '(gnu packages commencement)))
+ (guile (module-ref distro 'guile-final)))
+ (package-derivation store guile system #:graft? #f)))))
+
+ (build-expression->derivation store name builder
+ #:system system
+ #:inputs inputs
+ #:modules imported-modules
+ #:outputs outputs
+ #:guile-for-build guile-for-build))
+
+(define linux-module-build-system
+ (build-system
+ (name 'linux-module)
+ (description "The Linux module build system")
+ (lower lower)))
+
+;;; linux-module.scm ends here
diff --git a/guix/build/linux-module-build-system.scm b/guix/build/linux-module-build-system.scm
new file mode 100644
index 0000000000..2da1d32652
--- /dev/null
+++ b/guix/build/linux-module-build-system.scm
@@ -0,0 +1,82 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 Danny Milosavljevic <dannym@scratchpost.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build linux-module-build-system)
+ #:use-module ((guix build gnu-build-system) #:prefix gnu:)
+ #:use-module (guix build utils)
+ #:use-module (ice-9 ftw)
+ #:use-module (ice-9 match)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:export (%standard-phases
+ linux-module-build))
+
+;; Commentary:
+;;
+;; Builder-side code of linux-module build.
+;;
+;; Code:
+
+(define* (configure #:key inputs #:allow-other-keys)
+ #t)
+; (let ((source (string-append (assoc-ref inputs "linux")
+; "/Module.symvers")))
+; (if (file-exists? source)
+; (install-file source out-lib-build))
+; #t))
+
+(define* (build #:key inputs make-flags #:allow-other-keys)
+ (apply invoke "make" "-C"
+ (string-append (assoc-ref inputs "linux-module-builder")
+ "/lib/modules/build")
+ (string-append "M=" (getcwd))
+ (or make-flags '())))
+
+;; This block was copied from make-linux-libre--only took the "modules_install"
+;; 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")))
+ ;; Install kernel modules
+ (mkdir-p moddir)
+ (invoke "make" "-C"
+ (string-append (assoc-ref inputs "linux-module-builder")
+ "/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 %standard-phases
+ (modify-phases gnu:%standard-phases
+ (replace 'configure configure)
+ (replace 'build build)
+ (replace 'install install)))
+
+(define* (linux-module-build #:key inputs (phases %standard-phases)
+ #:allow-other-keys #:rest args)
+ "Build the given package, applying all of PHASES in order, with a Linux kernel in attendance."
+ (apply gnu:gnu-build
+ #:inputs inputs #:phases phases
+ args))
+
+;;; linux-module-build-system.scm ends here
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH v2 2/2] gnu: Add vhba-module.
2019-04-05 11:05 ` [bug#35110] [PATCH v2 0/2] Add support for loadable modules Danny Milosavljevic
2019-04-05 11:05 ` [bug#35110] [PATCH v2 1/2] Add (guix build-system linux-module) Danny Milosavljevic
@ 2019-04-05 11:05 ` Danny Milosavljevic
2019-04-11 10:51 ` Ludovic Courtès
1 sibling, 1 reply; 16+ messages in thread
From: Danny Milosavljevic @ 2019-04-05 11:05 UTC (permalink / raw)
To: 35110; +Cc: Pierre Neidhardt
From: Pierre Neidhardt <mail@ambrevar.xyz>
* gnu/packages/linux.scm (vhba-module): New variable.
Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
---
gnu/packages/linux.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index e4f6e241ec..52ae0387d1 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -118,6 +118,7 @@
#:use-module (guix build-system gnu)
#:use-module (guix build-system python)
#:use-module (guix build-system trivial)
+ #:use-module (guix build-system linux-module)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module ((guix licenses) #:prefix license:)
@@ -438,6 +439,28 @@ It has been modified to remove all non-free binary blobs.")
#:patches %linux-libre-5.0-patches
#:configuration-file kernel-config))
+(define-public vhba-module
+ (package
+ (name "vhba-module")
+ (version "20170610")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append
+ "http://downloads.sourceforge.net/cdemu/vhba-module-"
+ version ".tar.bz2"))
+ (sha256
+ (base32
+ "1v6r0bgx0a65vlh36b1l2965xybngbpga6rp54k4z74xk0zwjw3r"))))
+ (build-system linux-module-build-system)
+ (arguments
+ ;; TODO: No tests?
+ `(#:tests? #f))
+ (home-page "https://cdemu.sourceforge.io/")
+ (synopsis "Kernel module that emulates SCSI devices")
+ (description "VHBA module provides a Virtual (SCSI) HBA, which is the link
+between the CDemu userspace daemon and linux kernel.")
+ (license license:gpl2+)))
+
(define %linux-libre-4.19-version "4.19.33")
(define %linux-libre-4.19-hash "147ksl3ksxdv2ifr18cbzq4647n9d7yr7kbxg02sljia7z3b70cm")
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH v2 1/2] Add (guix build-system linux-module).
2019-04-05 11:05 ` [bug#35110] [PATCH v2 1/2] Add (guix build-system linux-module) Danny Milosavljevic
@ 2019-04-11 10:50 ` Ludovic Courtès
2019-04-11 15:53 ` bug#35110: " Danny Milosavljevic
0 siblings, 1 reply; 16+ messages in thread
From: Ludovic Courtès @ 2019-04-11 10:50 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: 35110
Hi Danny,
Danny Milosavljevic <dannym@scratchpost.org> skribis:
> * guix/build/linux-module-build-system.scm: New file.
> * guix/build-system/linux-module.scm: New file.
> * Makefile.am (MODULES): Add them.
Awesome!
> +(define* (configure #:key inputs #:allow-other-keys)
> + #t)
> +; (let ((source (string-append (assoc-ref inputs "linux")
> +; "/Module.symvers")))
> +; (if (file-exists? source)
> +; (install-file source out-lib-build))
> +; #t))
I think you should either remove this comment or add an explanation
and/or a TODO.
Could you also add a note in doc/guix.texi under “Build Systems”?
Otherwise LGTM, thank you!
Ludo’.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [bug#35110] [PATCH v2 2/2] gnu: Add vhba-module.
2019-04-05 11:05 ` [bug#35110] [PATCH v2 2/2] gnu: Add vhba-module Danny Milosavljevic
@ 2019-04-11 10:51 ` Ludovic Courtès
0 siblings, 0 replies; 16+ messages in thread
From: Ludovic Courtès @ 2019-04-11 10:51 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: Pierre Neidhardt, 35110
Danny Milosavljevic <dannym@scratchpost.org> skribis:
> From: Pierre Neidhardt <mail@ambrevar.xyz>
>
> * gnu/packages/linux.scm (vhba-module): New variable.
>
> Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
LGTM, thanks!
Ludo'.
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#35110: [PATCH v2 1/2] Add (guix build-system linux-module).
2019-04-11 10:50 ` Ludovic Courtès
@ 2019-04-11 15:53 ` Danny Milosavljevic
0 siblings, 0 replies; 16+ messages in thread
From: Danny Milosavljevic @ 2019-04-11 15:53 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 35110-done
[-- Attachment #1: Type: text/plain, Size: 352 bytes --]
Hi Ludo,
On Thu, 11 Apr 2019 12:50:42 +0200
Ludovic Courtès <ludo@gnu.org> wrote:
> > +(define* (configure #:key inputs #:allow-other-keys)
> I think you should either remove this comment or add an explanation
> and/or a TODO.
Added TODO.
> Could you also add a note in doc/guix.texi under “Build Systems”?
Did so.
Pushed!
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2019-04-11 15:54 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-02 19:27 [bug#35110] [PATCH 0/3] Add support for loadable modules Danny Milosavljevic
2019-04-02 19:28 ` [bug#35110] [PATCH 1/3] gnu: Add make-linux-module Danny Milosavljevic
2019-04-02 19:28 ` [bug#35110] [PATCH 2/3] gnu: Add vhba-module-linux-libre Danny Milosavljevic
2019-04-02 21:51 ` Pierre Neidhardt
2019-04-02 22:36 ` Danny Milosavljevic
2019-04-03 6:48 ` Pierre Neidhardt
2019-04-02 19:28 ` [bug#35110] [PATCH 3/3] gnu: linux-libre: Disable module versioning Danny Milosavljevic
2019-04-03 20:16 ` [bug#35110] [PATCH 1/3] gnu: Add make-linux-module Ludovic Courtès
2019-04-03 20:48 ` Danny Milosavljevic
2019-04-04 7:48 ` Ludovic Courtès
2019-04-05 11:05 ` [bug#35110] [PATCH v2 0/2] Add support for loadable modules Danny Milosavljevic
2019-04-05 11:05 ` [bug#35110] [PATCH v2 1/2] Add (guix build-system linux-module) Danny Milosavljevic
2019-04-11 10:50 ` Ludovic Courtès
2019-04-11 15:53 ` bug#35110: " Danny Milosavljevic
2019-04-05 11:05 ` [bug#35110] [PATCH v2 2/2] gnu: Add vhba-module Danny Milosavljevic
2019-04-11 10:51 ` Ludovic Courtès
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.