lgrosz / my-yocto-dockerfiles

Just trying to see if I can make something like crops that supports more than just the current yocto versions... felt smart, may delete later.
0 stars 0 forks source link

Install buildtools #6

Closed lgrosz closed 1 year ago

lgrosz commented 1 year ago

Yocto has specific versions of dependencies that must be present on the host system. These are available from the either a web download or built from the poky repository. Right now it seems this isn't required, as proper versions seem to be installed through the base distribution package registries. However, to be as pedantic as possible, these build tools should be used.

The web download is the easiest. It can be done with the following snippets...

# [Build tools](https://docs.yoctoproject.org/ref-manual/system-requirements.html#downloading-a-pre-built-buildtools-tarball)
# NOTE Cannot use {.sh,.sh.sha256sum} syntax with wget as dockerfile does some weird encoding
RUN wget https://downloads.yoctoproject.org/releases/yocto/yocto-${YOCTO_VERSION}/buildtools/x86_64-buildtools-nativesdk-standalone-${YOCTO_VERSION}.sh \
  && wget https://downloads.yoctoproject.org/releases/yocto/yocto-${YOCTO_VERSION}/buildtools/x86_64-buildtools-nativesdk-standalone-${YOCTO_VERSION}.sh.sha256sum \
  && sha256sum -c *.sha256sum \
  && bash x86_64-buildtools-nativesdk-standalone-${YOCTO_VERSION}.sh -y \
  && rm x86_64-buildtools-nativesdk-standalone-${YOCTO_VERSION}.*

There are some issues with the web download though...

... therefore, we should build it by source.

The following dockerfile snippet will create the buildtools from source.

# [Build tools](https://docs.yoctoproject.org/ref-manual/system-requirements.html#downloading-a-pre-built-buildtools-tarball)
FROM ubuntu:20.04 as buildtools-builder

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC
# [Required packages for build host](https://docs.yoctoproject.org/ref-manual/system-requirements.html#ubuntu-and-debian)
RUN apt-get update && apt-get install -y \
  build-essential \
  chrpath \
  cpio \
  debianutils \
  diffstat \
  gawk \
  gcc \
  git \
  iputils-ping \
  libegl1-mesa \
  liblz4-tool \
  libsdl1.2-dev \
  mesa-common-dev \
  pylint3 \
  python3 \
  python3-git \
  python3-jinja2 \
  python3-pexpect \
  python3-pip \
  python3-subunit \
  socat \
  texinfo \
  unzip \
  wget \
  xterm \
  xz-utils \
  zstd \
  && rm -rf /var/lib/apt/lists/*

# Locale setup
RUN apt-get update && apt-get install -y \
  locales \
  && rm -rf /var/lib/apt/lists/*
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
  locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

RUN useradd chef
USER chef
WORKDIR /workdir

RUN git clone git://git.yoctoproject.org/poky . \
  && git checkout langdale-4.1.3 \
  && . ./oe-init-build-env \
  && bitbake buildtools-extended-tarball

... it then can be loaded into an image for install later...

COPY --from=buildtools-builder /workdir/build/tmp/deploy/sdk/*-buildtools-extended-nativesdk-standalone-${YOCTO_VERSION}.sh /

There were some issues initially getting this working...

lgrosz commented 1 year ago

The following distros need buildtools as they are missing Python 3.8 or something else...

lgrosz commented 1 year ago

Solution by #16