In my quest to automate the testing of the Linux Kernel, I need to automate the build of the Linux Kernel. To build the Kernel, you need the requisite packages. What are they? Let’s find out.
I am staring with a Baremetal Fedora Image. It has 344 packages installed already. I’m going to assume that this set is available when I do my automated build as well, or that the needed packages will get pulled in by dependencies. If not, I will find out when my automation fails to run and I will add them at that point.
Most Fedora and CentOS based documents on building the Kernel have you do a group install of the “Development Tools” yum package group. I don’t want to do this for two reasons. First, I want to use the beaker format which just lists the packages in the job description. Second, I want to minimize the non-required packages, and Development Tools is general purpose group for coding; not everyone needs everythingm, and I don’t want to put non-essential packages on the system.
In order to build the linux Kernel, I need to get the code on the server. While I could push it from a remote system, if I want to run this from a beaker job, I will have no machine that can push it. Thus, I will start by installing git.
sudo yum install git
That installs 66 Packages and takes Installed size: 58 MB of space.
Next I clone the Linux kernel tree. I am using https://gitlab.com/linux-kernel/linux, but you can do the same thing from the kernel.org Repo or one of the other public git mirrors. This is quite large and takes a while.
Receiving objects: 100% (8358688/8358688), 1.51 GiB | 20.57 MiB/s, done.
I’m going to use an existing config file to make the old configuration into my new one.
$ make olddefconfig -bash: make: command not found
OK, first missing package. make pulls in libtool-ltdl and guile22
$ make olddefconfig HOSTCC scripts/basic/fixdep /bin/sh: line 1: gcc: command not found make: *** [scripts/Makefile.host:95: scripts/basic/fixdep] Error 127 make: *** [Makefile:552: scripts_basic] Error 2
gcc. No Suprise there. That pulls in 17 packages.
$ make olddefconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o LEX scripts/kconfig/lexer.lex.c /bin/sh: line 1: flex: command not found make: *** [scripts/Makefile.host:9: scripts/kconfig/lexer.lex.c] Error 127 make: *** [Makefile:616: olddefconfig] Error 2
flex also pulls in m4
$ make olddefconfig LEX scripts/kconfig/lexer.lex.c YACC scripts/kconfig/parser.tab.[ch] /bin/sh: line 1: bison: command not found make: *** [scripts/Makefile.host:17: scripts/kconfig/parser.tab.h] Error 127 make: *** [Makefile:616: olddefconfig] Error 2
That gets through the config build process. Lets checkout the main compile. To speed things up, I compile with 1 thread per CPU:
make -j 32
scripts/sign-file.c:25:10: fatal error: openssl/opensslv.h: No such file or directory 25 | #include <openssl/opensslv.h> | ^~~~~~~~~~~~~~~~~~~~ compilation terminated. make: *** [scripts/Makefile.host:95: scripts/sign-file] Error 1 make: *** [Makefile:1203: scripts] Error 2
I’m sure there were flamewars about including cryptography in the Linux Kernel.
/bin/sh: line 1: bc: command not found make: *** [Kbuild:24: include/generated/timeconst.h] Error 127 make: *** Waiting for unfinished jobs.... make: *** [Makefile:1219: prepare0] Error 2
main.c:55:10: fatal error: libelf.h: No such file or directory 55 | #include <libelf.h> | ^~~~~~~~~~
elfutils-libelf-devel. And with that, the make process completes successfully. Lets’ now make the modules.
That works, too.
So the minimal list for compile is