Skip to content

build in docker container #250

@MichaelSp

Description

@MichaelSp

I try to build the firmware inside a docker container (not to mess up my system). But for some reason it does not work. Any idea how to run the build inside docker?

I tried it in master branch:

$ make
make -C buildroot
make[1]: Entering directory '/build/buildroot'
Makefile:592: *** libglib2 is in the dependency chain of bluez5_utils that has added it to its _DEPENDENCIES variable without selecting it or depending on it from Config.in.  Stop.
make[1]: Leaving directory '/build/buildroot'
make: *** [Makefile:3: all] Error 2

and in next branch:

br-user@fab4de019cec:/build$ make
mkdir -p /build/output
mkdir -p /build/output/images
mkdir -p /build/output/initramfs
make -C /build/output/build/initramfs
make[1]: Entering directory '/build/output/build/initramfs'
>>> toolchain-external-custom  Configuring
mkdir -p /build/output/build/initramfs/per-package/toolchain-external-custom/host
rsync -a /build/output/build/initramfs/per-package/host-skeleton/host/ /build/output/build/initramfs/per-package/toolchain-external-custom/host
rsync -a /build/output/build/initramfs/per-package/skeleton/host/ /build/output/build/initramfs/per-package/toolchain-external-custom/host
mkdir -p /build/output/build/initramfs/per-package/toolchain-external-custom/target
rsync -a /build/output/build/initramfs/per-package/host-skeleton/target/ /build/output/build/initramfs/per-package/toolchain-external-custom/target
rsync -a /build/output/build/initramfs/per-package/skeleton/target/ /build/output/build/initramfs/per-package/toolchain-external-custom/target
Cannot execute cross-compiler '/arm-linux-gcc'    ################### ERROR
make[2]: *** [package/pkg-generic.mk:285: /build/output/build/initramfs/build/toolchain-external-custom/.stamp_configured] Error 1
make[1]: *** [Makefile:23: _all] Error 2
make[1]: Leaving directory '/build/output/build/initramfs'
make: *** [Makefile:61: initramfs] Error 2

Build root not found. I assume some PATH is missing: Cannot execute cross-compiler '/arm-linux-gcc'
For some reason the toolchain is not found / built.


Appendix

Dockerfile
FROM debian

LABEL description="Container with everything needed to run Buildroot"

# Setup environment
ENV DEBIAN_FRONTEND noninteractive

# The container has no package lists, so need to update first
RUN apt-get -o APT::Retries=3 update -y
RUN apt-get -o APT::Retries=3 install -y --no-install-recommends \
        bc \
        build-essential \
        bzr \
        ca-certificates \
        cmake \
        cpio \
        cvs \
        file \
        git \
        gcc-arm-linux-gnueabi \
        libc6 \
        libncurses5-dev \
        locales \
        mercurial \
        openssh-server \
        python3 \
        python3-flake8 \
        python3-magic \
        python3-nose2 \
        python3-pexpect \
        python3-pytest \
        qemu-system-arm \
        qemu-system-x86 \
        rsync \
        shellcheck \
        subversion \
        unzip \
        wget \
        && \
    apt-get -y autoremove && \
    apt-get -y clean

# To be able to generate a toolchain with locales, enable one UTF-8 locale
RUN sed -i 's/# \(en_US.UTF-8\)/\1/' /etc/locale.gen && \
    /usr/sbin/locale-gen

RUN useradd -ms /bin/bash br-user && \
    chown -R br-user:br-user /home/br-user

USER br-user
WORKDIR /home/br-user
ENV HOME /home/br-user
ENV LC_ALL en_US.UTF-8

Since I mounted the /build from outside, the hard-link didn't work and I had to patch this file in /build/buildroot

diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
index 973eabe437..05b442774e 100644
--- a/package/pkg-utils.mk
+++ b/package/pkg-utils.mk
@@ -184,7 +184,7 @@ ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
 define per-package-rsync
        mkdir -p $(3)
        $(foreach pkg,$(1),\
-               rsync -a --link-dest=$(PER_PACKAGE_DIR)/$(pkg)/$(2)/ \
+               rsync -a \
                $(PER_PACKAGE_DIR)/$(pkg)/$(2)/ \
                $(3)$(sep))
 endef

running it with docker-compose.yaml

services:
  build:
    build: .
    volumes:
      - ./:/build
    working_dir: /build
    command:
    - make

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions