Commit Graph

219 Commits

Author SHA1 Message Date
Emil Velikov e4c1a5b299 configure: manage libkmod.pc.in and version.py.in via AC_CONFIG_FILES
Replace the manual sed command, build rules and dist/clean for using
AC_CONFIG_FILES. It does the exact same thing, with an added bonus...

Currently we're missing version.py.in in the EXTRA_DIST. Thus a simple
"touch Makefile" should retrigger the regeneration of version.py. Which
would presumably fail, since the input file isn't in the distribution
tarball.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-02-21 16:35:42 -08:00
Lucas De Marchi 3d38e322f9 testsuite: Handle different sysconfdir
Instead of skipping tests if sysconfdir isn't /etc, just handle it
during the rootfs setup logic.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2023-02-10 14:29:28 -08:00
Lucas De Marchi 184a070733 testsuite: Move setup-rootfs logic from Makefile to script
It's easier to implement the logic outside of the Makefile, so rename
the populate-modules.sh script to setup-rootfs.sh and move the
additional logic from the makefile to the script.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2023-02-10 14:27:27 -08:00
Dimitri John Ledkov 09ad860552 build: enable building & running tests from a subdir
During dpkg build, in a subdir, it is currently not possible to run
tests. Building testsuite/modules due to non-existance of the
testsuite directory under the build dir. Thus create it, when it is
not there.

Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
2022-06-30 09:55:55 -07:00
Lucas De Marchi 5d46434a63 kmod 30 2022-06-30 08:19:17 -07:00
Lucas De Marchi b6ecfc916a kmod 29 2021-05-20 16:02:57 -07:00
Lucas De Marchi 1921c370c2 testsuite: compress modules if feature is enabled
Since the output needs to be the same, regardless if the module is
compressed, change populate-modules.sh to conditionally compress the
module if that feature is enabled.

This way we can execute the tests with any build-time configuration and
it should still pass.

Suggested-by: Michal Suchánek <msuchanek@suse.de>
Reviewed-by: Michal Suchánek <msuchanek@suse.de>
Tested-by: Michal Suchánek <msuchanek@suse.de>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
2021-02-05 19:52:00 -08:00
Marius Bakke 847247a4a8 testsuite: Automatically skip tests that fail when sysconfdir != /etc. 2021-01-07 19:44:50 -08:00
Lucas De Marchi 1ccfe99428 kmod 28 2021-01-07 10:43:36 -08:00
Lucas De Marchi d977b0daf4 build: add comment with rules for libtool version update 2021-01-07 10:27:49 -08:00
Lucas De Marchi d83f488c60 build: fix distcheck due to missing zstd
Enable zstd since it's used in the testsuite.
2020-12-27 17:02:19 -08:00
Torge Matthies 3821e1971e add Zstandard compression support
I changed the style of the hackargs variable in autogen.sh to multiline
because said line was becoming a bit long with the new --with-zstd arg
added.

A previous version of this patch has been running on my two Arch Linux
installations (with an accompanying mkinitcpio patch) for several months
over many kernel updates without any issues.
Any additional testing and/or patch review would of course be appreciated.

Signed-off-by: Torge Matthies <openglfreak@googlemail.com>
2020-09-10 21:55:01 -07:00
Lucas De Marchi 819a125ca7 kmod 27 2020-02-18 15:54:07 -08:00
Alexey Gladkov 60084cf1cb libkmod: Add parser for modules.builtin.modinfo
The kernel since version v5.2-rc1 exports information about built-in
modules in the modules.builtin.modinfo. Information is stored in
the same format as in the separate modules (null-terminated string
array). The module name is a prefix for each line.

$ tr '\0' '\n' < modules.builtin.modinfo
ext4.softdep=pre: crc32c
ext4.license=GPL
ext4.description=Fourth Extended Filesystem
ext4.author=Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others
ext4.alias=fs-ext4
ext4.alias=ext3
ext4.alias=fs-ext3
ext4.alias=ext2
ext4.alias=fs-ext2
md_mod.alias=block-major-9-*
md_mod.alias=md
md_mod.description=MD RAID framework
md_mod.license=GPL
md_mod.parmtype=create_on_open:bool
md_mod.parmtype=start_dirty_degraded:int
...

Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
2019-12-18 16:56:10 -08:00
Fabrice Fontaine 8aa52bf238 Makefile.am: filter -Wl,--no-undefined
Commit 1d14ef82f4 does not completely fix
the build with python 3.8 as we still get link failure due to
'-z undefs' being ignored by some versions of ld.

Indeed, -z undefs was added by commit
97a232d7335f3bd0231fd9cd39455bde1d563922 in upstream binutils, and this
commit was first present in binutils 2.30.
So any toolchain using binutils version older than that won't have
-z undefs and will build fail on:

/home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/mips-linux-gnu/5.3.0/../../../../mips-linux-gnu/bin/ld: warning: -z undefs ignored.

/home/naourr/work/instance-1/output-1/host/opt/ext-toolchain/bin/../lib/gcc/aarch64_be-linux-gnu/7.3.1/../../../../aarch64_be-linux-gnu/bin/ld: warning: -z undefs ignored.

So filter -Wl,--no-undefined to fix the issue

Fixes:
 - http://autobuild.buildroot.org/results/e9645d9969481b09f507f6e0d0b35faaa283eb60
 - http://autobuild.buildroot.org/results/06a6d865b6b7d8ebd793bde214f4a4c40e0962e1

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2019-11-18 15:30:26 -08:00
Thomas Petazzoni 1d14ef82f4 Do not check for undefined symbols when building the Python modules
kmod's configure.ac uses the -Wl,--no-undefined linker flag to verify
at link time that all symbols of shared libraries are available, and
that there are no undefined symbols.

This make perfect sense for regular shared libraries. However, for
Python extensions, which will be dlopen()ed inside the Python
interpreter, it makes less sense.

Since Python 3.8, there is a change in python-config script and
Python's pkg-config file: it no longer links Python extensions with
the libpython library. See
https://docs.python.org/dev/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
which states:

  On the other hand, pkg-config python3.8 --libs no longer contains
  -lpython3.8. C extensions must not be linked to libpython (except on
  Android and Cygwin, whose cases are handled by the script); this
  change is backward incompatible on purpose. (Contributed by Victor
  Stinner in bpo-36721.)

So, when linking the kmod Python extensions, it currently fails with
numerous unresolved symbols, that were previously provided by
libpython:

/home/test/autobuild/run/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/powerpc64-buildroot-linux-gnu/7.4.0/../../../../powerpc64-buildroot-linux-gnu/bin/ld: libkmod/python/kmod/.libs/list_la-list.o: in function `__Pyx_PyObject_GetAttrStr':
list.c:(.text.__Pyx_PyObject_GetAttrStr+0x48): undefined reference to `PyObject_GetAttr'
/home/test/autobuild/run/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/powerpc64-buildroot-linux-gnu/7.4.0/../../../../powerpc64-buildroot-linux-gnu/bin/ld: libkmod/python/kmod/.libs/list_la-list.o: in function `__pyx_tp_dealloc_4kmod_4list_ModListItem':
list.c:(.text.__pyx_tp_dealloc_4kmod_4list_ModListItem+0x78): undefined reference to `PyObject_CallFinalizerFromDealloc'
/home/test/autobuild/run/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/powerpc64-buildroot-linux-gnu/7.4.0/../../../../powerpc64-buildroot-linux-gnu/bin/ld: libkmod/python/kmod/.libs/list_la-list.o: in function `__pyx_tp_dealloc_4kmod_4list_ModList':
list.c:(.text.__pyx_tp_dealloc_4kmod_4list_ModList+0x30): undefined reference to `PyErr_Fetch'

[Complete log at http://autobuild.buildroot.net/results/79a/79a5a0398723e8cfea0d0aa3dec5f7649aee4c63/build-end.log]

Linking with libpython is no longer recommended: those symbols should
remain unresolved in the Python extensions, as they wil be properly
resolved when the Python extension gets loaded into the Python
interpreter.

Since we want to keep -Wl,--no-undefined globally in kmod, we leave
the configure.ac file unchanged, and instead, specifically in the
LDFLAGS used to build the Python extensions, we override
-Wl,--no-undefined with -Wl,-z,undefs. Ideally, -Wl,--no-undefined is
the same as -Wl,-z,defs, and the effect of these options can be
canceled on the linker command line by a following -Wl,-z,undefs (see
the ld man page for details).

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Victor Stinner <victor.stinner@gmail.com>
2019-10-25 15:02:25 -07:00
Adrian Bunk f8b8d7b330 build: Stop using dolt
This does regress "make -12" from 0.7s to 0.9s on my
Coffee Lake machine, but even on slower hardware this
will not amount to a noticable slowdown.

On the other hand using dolt can create problems for
people doing cross-compilation, e.g. Yocto has two
hacks just for dolt in kmod:
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/recipes-kernel/kmod/kmod.inc?id=a17abae00785c76cfffe5381a22fb2c86b982e82

(Lucas: remove leftover entry in Makefile and reformat commit message)
2019-02-20 10:38:56 -08:00
Dave Reisner 8e266b9eef Link against libcrypto, not all of openssl
In the previous build setup, libkmod.so would link to not just
libcrypto.so, but also libssl.so:

$ readelf -d /lib/libkmod.so | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [liblzma.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libssl.so.1.1]
 0x0000000000000001 (NEEDED)             Shared library: [libcrypto.so.1.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

We don't need any symbols from libssl, though. This patch ensures that
we pass 'libcrypto' to pkgconfig rather than 'openssl', getting only the
library that we need:

$ readelf -d  ./libkmod/.libs/libkmod.so.2.3.4 | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [liblzma.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libcrypto.so.1.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
2019-02-13 09:36:57 -08:00
Lucas De Marchi 58133a96c8 kmod 26 2019-02-07 13:46:40 -08:00
Lucas De Marchi 9a015bcdde build: fix make distcheck
Make sure to add the dummy.pkcs7 file to the dist files.

While at it, also change the distcheck flags to include --with-openssl.
2019-02-07 13:44:39 -08:00
Yauheni Kaliuta 391b4714b4 libkmod-signature: implement pkcs7 parsing with openssl
The patch adds data fetching from the PKCS#7 certificate using
openssl library (which is used by scripts/sign-file.c in the linux
kernel to sign modules).

In general the certificate can contain many signatures, but since
kmod (modinfo) supports only one signature at the moment, only first
one is taken.

With the current sign-file.c certificate doesn't contain signer
key's fingerprint, so "serial number" is used for the key id.

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
2019-02-04 13:51:27 -08:00
Lucas De Marchi 028d4df365 Remove bootstrap* scripts
Let's just use autogen.sh, no need for wrapper scripts. Now
`autogen.sh c` uses the same recommended options for developing kmod and
also accepts extra arguments.
2018-12-17 09:52:05 -08:00
Lucas De Marchi aca4eca103 kmod 25 2018-01-08 17:30:39 -08:00
Lucas De Marchi 7bc6b67dc6 testsuite: generalize mkosi support for other distros
Instead of using the mkosi.default symlink, use an env var passed from
the build system. We would need to pass the --default switch nonetheless
or change the symlink, making the git tree dirty.

Also, search for installed kernel headers in a way that's compatible
with more distros. On Fedora, for example, the
/usr/lib/modules/<kver>/build symlink is only available if there's a
kernel installed. We don't care about a kernel installed since we don't
need to boot it on a real machine: the only thing we need is the
kernel-devel package.
2018-01-03 14:22:05 -08:00
Lucas De Marchi 8d9c7e37c9 build: use tool from configure
This way we make sure the tool will be the one we actually configured
before going through sudo.
2018-01-02 18:17:51 -08:00
Lucas De Marchi cc71e0a589 build: add mkosi hooks
Right now there's support for building on Archlinux only.
2018-01-02 15:05:44 -08:00
Lucas De Marchi ef4257b59c kmod 24 2017-02-23 23:32:51 -08:00
Lucas De Marchi 527658ad89 build: add missing header
Fix failing distcheck
2017-02-23 18:26:54 -08:00
Yauheni Kaliuta 9be03c52cc testsuite: depmod: check netsted loops reporting
The patch adds nested loops configuration for the loop test:

mod-loop-h -> mod-loop-i -> mod-loop-j -> mod-loop-k
   ^                           |               |
    ---------------------------                |
   |                                           |
    -------------------------------------------

making 2 loops with common edges:

mod-loop-h -> mod-loop-i -> mod-loop-j -> mod-loop-h
mod-loop-h -> mod-loop-i -> mod-loop-j -> mod-loop-k -> mod-loop-h

The actual output for the loops is:

depmod: ERROR: Cycle detected: mod_loop_h -> mod_loop_h
depmod: ERROR: Cycle detected: mod_loop_i -> mod_loop_j -> mod_loop_k -> mod_loop_h -> mod_loop_i

(the order in the second doesn't matter, but the first one is
incorrect)

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
2017-02-22 04:50:22 -08:00
Lucas De Marchi 67d1534318 build: fix build with disabled test modules
install: cannot stat 'testsuite/module-playground/mod-loop-f.ko': No
such file or directory
Makefile:2881: recipe for target 'rootfs' failed
make[1]: *** [rootfs] Error 1
make[1]: *** Waiting for unfinished jobs....
Makefile:2101: recipe for target 'check-recursive' failed

We need to ship pre-compiled binaries so it's possible to run
"make check" on servers without kernel headers.

Also add them to EXTRA_DIST as other sources.
2016-11-10 23:47:19 -02:00
Lucas De Marchi 780a4e97e2 Add scratchbuf implementation
This should fill the requirements for "we need to loop over a lot of
strings that usually are small enough to remain on stack, but we want to
protect ourselves against huge strings not fitting in the static
buffer we estimated as sufficient"
2016-08-15 10:26:42 -03:00
Lucas De Marchi 65a885df5f kmod 23 2016-07-20 01:38:42 -03:00
Héctor Orón Martínez 90a6e7983f kmod: compiling with old sed version (!ERE support)
Makefile.am uses `sed -E', which it is found on BSD sed; however a
  replacement on GNU sed would be `sed -r'. Both intend to use extended
  regular expressions (ERE). However I have a system that does not support
  those, in benefit for portability could you consider replacing ERE by BRE.

Signed-off-by: Héctor Orón Martínez <hector.oron@gmail.com>
2016-05-21 15:07:27 -03:00
Lucas De Marchi 42f32b8ae4 kmod 22 2015-11-17 22:12:07 -02:00
Natanael Copa e414d087d9 build: let sed use posix ERE instead of GNU extension
Use POSIX Extended Regular Expression (ERE) instead of the GNU extension
\| in the install-exec-hook. This makes it create the symlink properly
with busybox sed built with musl libc. It will silently create a broken
symlink otherwise.

Lucas De Marchi:  fix up added newline.
2015-06-22 11:23:57 -03:00
Lucas De Marchi 2bfcd7ef80 kmod 21 2015-06-09 02:36:14 -03:00
Lucas De Marchi fc1bc8155f build: add cache to distributed files
We were missing the cache directory on the distributed files.
2015-06-09 02:03:36 -03:00
Lucas De Marchi 681c623e71 build: silence stderr on coverity rules
We try to execute git in order to get the dependencies for the coverity
rules. And it gets executed even when we are not calling that specific
rule.  Later we may want to improve it, but for now let's just silence
the errors of not being a git repository when executing this on a
packaged version.
2015-06-09 02:01:11 -03:00
Lucas De Marchi 013e855043 tools: Hide new commands behind experimental flag
Hide the commands behind a flag so we can continue doing releases while
the commands aren't ready.
2015-06-06 23:26:31 -03:00
Lucas De Marchi 23603f1f83 build: cache modules from playground
Now that we are able to build our own test modules, also allow to use
cached modules so a) kernel headers are not required and b) distro
maintainers are happy.  It's still need a "--disable-test-modules" in
the configure since the default is enabled.

There's no license problems anymore since all modules come from our own
repository, we ship the sources and the modules can be easily rebuilt.
2015-05-31 15:38:47 -03:00
Lucas De Marchi 9cc8a20d34 build: sync dolt with upstream 2015-03-10 15:17:03 -03:00
Caio Marcelo de Oliveira Filho 037618816c tools: add basic versions of insert and remove 2015-03-07 12:09:51 -03:00
Caio Marcelo de Oliveira Filho 0f079cba76 testsuite: remove .gitignore files when populating rootfs
Usually this file is added to keep a directory existing in the
repository but without any real content. In rootfs this can be
problematic if a directory will have all its files inspected. This
happens for kmod_module_get_holders().

Side-note: the 'test-loaded.c' is hit by this problem but doesn't
"notice" because the invalid module returned by get_holders() is not
checked. The modules in its loop are only used to get the name and
generate an output, and NULL was a valid value to generate the name.
2015-03-05 23:56:36 -03:00
Lucas De Marchi d9c7175859 kmod 20 2015-03-01 14:43:09 -03:00
Lucas De Marchi dbf90dc3a8 testsuite: test builtin state
The second test, that creates the module by name and then retrieves the
initstate was broken before b95fa91 ('Fix race while loading modules').
We would check /sys and return either builtin (if the module has
parameters) or give an error because we don't find the module (even if
it's in the modules.builtin index)
2015-02-28 14:18:54 -03:00
Lucas De Marchi 0bcdef9700 build: add helpers to upload coverity tarball 2015-02-25 12:57:31 -03:00
Lucas De Marchi 80f6ab5c9c build: add missing files to EXTRA_DIST
Fix make distcheck.
2015-02-24 01:50:32 -03:00
Lucas De Marchi 0e68c6258e build: let touch on directory as last step
We need to let these instructions in kmod to be the last executed ones.
Otherwise the subdirectory containing the modules could propagate up the
time access.
2015-02-03 05:19:38 -02:00
Lucas De Marchi 450c1f037b testsuite: port test-dependencies to module-playground 2015-02-03 01:12:13 -02:00
Lucas De Marchi 4002d77aff testsuite: beef up module-playground in the build system
Instead of shipping pre-compiled module, this prepares the build system
to be able to compile the necessary modules from module-playground. This
preparations starts by replacing md5.ko with our own dummy
mod-simple.ko, built from source. It works by copying the modules to
their final location while preparing the rootfs.
2015-02-03 01:09:17 -02:00