5

I try to build the Linux kernel with Buildroot using Docker. I've created a simple Docker image:

FROM debian:7
MAINTAINER OrangeTux


RUN apt-get update && \
    apt-get install -y \
    build-essential \
    bash \
    bc \
    binutils \
    build-essential \
    bzip2 \
    cpio \
    g++ \
    gcc \
    git \
    gzip \
    make \
    libncurses5-dev \
    patch \
    perl \
    python \
    rsync \
    sed \
    tar \
    unzip \
    wget

WORKDIR /root

RUN git clone git://git.buildroot.net/buildroot 

WORKDIR /root/buildroot

CMD ["/bin/bash"]

I want to keep dl/ andoutput/build/ when container stops, so I don't have to download and compile all dependencies every time. I also want the build products on my host. Therefore I start container like this:

$ docker run -ti -v $(pwd)/dl:/root/buildroot/dl -v \ $(pwd)/output/build:/root/buildroot/output/build -v \ $(pwd)/output/images:/root/buildroot/output/images orangetux/buildroot

I'm able to run make menuconfig which builds the configuration for Buildroot. I've made a few modifications to the defaults. Here's the output of make savedefconfig:

BR2_arm=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_DEFCONFIG="at91_dt"

The next step is to build linux-menuconfig. This action failed and I've no clue what is going wrong:

 $ make linux-menuconfig
/usr/bin/make -j1  HOSTCC="/usr/bin/gcc" HOSTCXX="/usr/bin/g++" silentoldconfig
make[1]: Entering directory `/root/buildroot'
BR2_DEFCONFIG='' KCONFIG_AUTOCONFIG=/root/buildroot/output/build/buildroot-config/auto.conf KCONFIG_AUTOHEADER=/root/buildroot/output/build/buildroot-config/autoconf.h KCONFIG_TRISTATE=/root/buildroot/output/build/buildroot-config/tristate.config BR2_CONFIG=/root/buildroot/.config BR2_EXTERNAL=support/dummy-external SKIP_LEGACY= /root/buildroot/output/build/buildroot-config/conf --silentoldconfig Config.in

*** Error during update of the configuration.

make[1]: *** [silentoldconfig] Error 1
make[1]: Leaving directory `/root/buildroot'
make: *** [/root/buildroot/output/build/buildroot-config/auto.conf] Error 2

The file /root/buildroot/output/build/buildroot-config/auto.conf doesn't exists.

Why does the file not exists and how can I build linux-menuconfig?

OrangeTux
  • 1,053
  • 2
  • 16
  • 26

4 Answers4

1

After extensive debugging I found out that mounting a folder on my host system at /root/buildroot/output/ causes the problem. Remove this mount and make linux-menuconfig is possible.

Further debugging revealed that mounting a host folder at /root/buildroot/output/build in the container is the problem. I've no clue why.

OrangeTux
  • 1,053
  • 2
  • 16
  • 26
  • 2
    Because the folder you're mounting does not belong to root. Do it like so:`WORKDIR /usr/src/debian-custom` `git clone git clone git://git.buildroot.net/buildroot` ` ln -s /usr/srx/linux /usr/src/debian-custom`, then run `make menuconfig` from /usr/src/linux. See [Building a Custom Kernel for Debian](https://www.debian.org/releases/jessie/i386/ch08s06.html.en) – eyoung100 Apr 24 '15 at 22:48
  • Unfortunately my Docker container doesn't have a folder `/usr/src/linux`. And I don't want to compile Linux for Debian, but for a custom root file system. But I don't know it that matters in this case. – OrangeTux Apr 25 '15 at 07:51
1

I am having the exact same problem using a Docker container running on a Jenkins agent. But the problem also occurs, when executing the container on my local machine with a mount into the container. I just want to document my experiences here.

There is prepared build data in the Docker container available which is stored at /home/jenkins/data. Symbolic links to these data are created in /home/jenkins/workspace/<ourproject>/buildroot/output/build/ (which is a folder mounted into the container).

If I use a 'customWorkspace' in the Jenkins pipeline, that is automatically mounted into the docker container like this:

$ docker run -t -d -u 1001:1001 -w /home/jenkins/workspace -v /home/jenkins/workspace:/home/jenkins/workspace:rw,z -v /home/jenkins/workspace@tmp:/home/jenkins/workspace@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** ***.***.net/***/jenkins/build-images/***-builder:latest cat

And I work in this mounted workspace folder /home/jenkins/workspace/ (checking out buildroot and try to build it) I get the same error as mentioned in the initial question:

    jenkins@cec47254b4d1:~/workspace/clip/buildroot$ cat br.log 
2022-08-11T17:43:47 >>>   Buildroot 2021.02.9 Collecting legal info
2022-08-11T17:43:47 COPYING: OK (sha256: 9755181e27175cb3510b4da8629caa406fb355a19aa8e7d55f06bf8ab33323c4)
2022-08-11T17:43:47 /usr/bin/make -j1 O=/home/jenkins/workspace/clip/buildroot/output/beme HOSTCC="/usr/bin/gcc" HOSTCXX="/usr/bin/g++" syncconfig
2022-08-11T17:43:47 GEN     /home/jenkins/workspace/clip/buildroot/output/beme/Makefile
2022-08-11T17:43:47 
2022-08-11T17:43:47 *** Error during update of the configuration.
2022-08-11T17:43:47 
2022-08-11T17:43:47 make[2]: *** [Makefile:1019: syncconfig] Error 1
2022-08-11T17:43:47 make[1]: *** [Makefile:592: /home/jenkins/workspace/clip/buildroot/output/beme/build/buildroot-config/auto.conf] Error 2
2022-08-11T17:43:47 make: *** [Makefile:84: _all] Error 2

But if I am not using a 'customWorkspace', so not working inside mounted folders from the host but working in the same folder structure (/home/jenkins/workspace) within the Docker container filesystem everything works perfectly fine. Also creating links to the prepared data is just fine if the links are not created in the folder mounted into Docker container from the host.

So as mentioned by M Y I also tried to start the Docker container in privileged mode (adding option args "--privileged" to Docker Agent options in Jenkinsfile). This did not solve the problem for me.

The files in the mounted folder are owned by user Jenkins with user id 1001, same es the user the container is started with.

The main problem is calling make syncconfig.

Doing a make clean fixes the problem, because the prepared build data is deleted.

piewen
  • 11
  • 1
0

This sounds like a permissions problem. Either user permissions (chmod or acl), MAC (Mandatory Access Control, often selinux or similar) or filesystem write permissions. I think it is probably the third in that your container is not able to write to the device.

hildred
  • 5,759
  • 3
  • 30
  • 43
0

I solved that by:

1- Stop the lxc .

lxc stop <container-name>

2- Adjust the security privileged to true .

 lxc config set <container-name> security.privileged true

3- Start the container again .

lxc start 
M Y
  • 103
  • 1
  • 5