Container Build Guide

The openEuler Embedded build process is based on the openEuler OS, and requires many system tools and build tools to be installed. To help developers quickly set up a build environment, the operating system and tools on which the build process depends are encapsulated into a container. In this way, developers can avoid the time-consuming environment preparation process and focus on development.

Environment Preparation

Use Docker to create a container environment. The software and hardware requirements of Docker are as follows:

  • OS: openEuler 20.03/22.03, Ubuntu 20.04/22.04, Debian 11, and SUSE 12.05 are recommended.
  • Kernel: Linux 3.8 or later is recommended.
  • Driver: The kernel must include a proper storage driver, for example, Device Mapper, AUFS, vfs, btrfs, or ZFS.
  • Architecture: 64-bit architecture (x86-64 or AMD64).

Installing Docker


  1. Check whether Docker has been installed in the current environment.

Run the following command. If the Docker version is displayed, Docker has been installed in the current environment. You can use it directly.

docker version
  1. If Docker is not installed, install it by referring to the official document.

Install Docker on openEuler by referring to the installation guide for CentOS.

For example, run the following command to install Docker on openEuler:

sudo yum install docker

Obtaining the Container Image


Run the docker pull command to pull the image from Huawei Cloud to the host machine:

docker pull swr.cn-north-4.myhuaweicloud.com/openeuler-embedded/openeuler-container:lastest

Preparing the Container Build Environment


1. Start a container.

Run the docker run command to start the container. To ensure that the container can run in the background and access the Internet after being started, you are advised to run the following command to start the container:

docker run -idt --network host swr.cn-north-4.myhuaweicloud.com/openeuler-embedded/openeuler-container:lastest bash

Parameter description:

  • -i: keeps the standard input open.
  • -d: starts a container in daemon mode in the background.
  • -t: allocates a pseudo-tty and binds it to the standard input of the container.
  • --network: connects the container to the network of the host machine.
  • swr.cn-north-4.myhuaweicloud.com/openeuler-embedded/openeuler-container:lastest (image_name:image_version)
  • bash: method for accessing a container.

2. Check the ID of the started container.

docker ps

3. Enter the container.

docker exec -it <container_id> bash

After the build environment is ready, you can build in the container.

Version Build

Downloading Source Code

  1. Obtain the source code download script.
git clone https://gitee.com/openeuler/yocto-meta-openeuler.git -b openEuler-22.03-LTS -v /usr1/openeuler/src/yocto-meta-openeuler
  1. Download the source code using the script.
cd /usr1/openeuler/src/yocto-meta-openeuler/scripts
sh download_code.sh /usr1/openeuler/src

Compiling the build

  • Compilation architecture: aarch64-std, aarch64-pro, arm-std or raspberrypi4-64
  • Build directory: /usr1/build
  • Source code directory: /usr1/openeuler/src
  • Path of the compiler: /usr1/openeuler/gcc/openeuler_gcc_arm64le

NOTE

  • Use different compilers for different compilation architectures. aarch64-std, aarch64-pro, and raspberrypi4-64 use the openeuler_gcc_arm64le compiler, and arm-std uses the openeuler_gcc_arm32le compiler.
  • The following uses the aarch64-std architecture as an example.
  1. Change the owner group of the /usr1 directory to openeuler. Otherwise, permission issues may occur when switching to the openeuler user.
chown -R openeuler:users /usr1
  1. Switch to the openeuler user.
su openeuler
  1. Go to the path where the compilation script is stored and run the script.
cd /usr1/openeuler/src/yocto-meta-openeuler/scripts
source compile.sh aarch64-std /usr1/build /usr1/openeuler/gcc/openeuler_gcc_arm64le
bitbake openeuler-image

Build Result

By default, the files are generated in the output directory of the build directory. For example, the built files of the aarch64-std example are generated in the /usr1/build/output directory, as shown in the following table:

FilenameDescription
Image-*openEuler Embedded image
openeuler-glibc-x86_64-openeuler-image-*-toolchain-**.shopenEuler Embedded SDK toolchain
openeuler-image-qemu-aarch64-*.rootfs.cpio.gzopenEuler Embedded file system
zImageopenEuler Embedded compressed image

有奖捉虫

“有虫”文档片段

存在的问题

提交类型 issue
有点复杂...
找人问问吧。
PR
小问题,全程线上修改...
一键搞定!
问题类型
规范和低错类

● 错别字或拼写错误;标点符号使用错误;

● 链接错误、空单元格、格式错误;

● 英文中包含中文字符;

● 界面和描述不一致,但不影响操作;

● 表述不通顺,但不影响理解;

● 版本号不匹配:如软件包名称、界面版本号;

易用性

● 关键步骤错误或缺失,无法指导用户完成任务;

● 缺少必要的前提条件、注意事项等;

● 图形、表格、文字等晦涩难懂;

● 逻辑不清晰,该分类、分项、分步骤的没有给出;

正确性

● 技术原理、功能、规格等描述和软件不一致,存在错误;

● 原理图、架构图等存在错误;

● 命令、命令参数等错误;

● 代码片段错误;

● 命令无法完成对应功能;

● 界面错误,无法指导操作;

风险提示

● 对重要数据或系统存在风险的操作,缺少安全提示;

内容合规

● 违反法律法规,涉及政治、领土主权等敏感词;

● 内容侵权;

您对文档的总体满意度

非常不满意
非常满意
创Issue赢奖品
根据您的反馈,会自动生成issue模板。您只需点击按钮,创建issue即可。