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
- Version Build
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).
- 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.
- 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
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
- -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.
3. Enter the container.
docker exec -it <container_id> bash
After the build environment is ready, you can build in the container.
Downloading Source Code
- 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
- 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
- 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.
- 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
- Switch to the openeuler user.
- 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
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:
|Image-*||openEuler Embedded image|
|openeuler-glibc-x86_64-openeuler-image-*-toolchain-**.sh||openEuler Embedded SDK toolchain|
|openeuler-image-qemu-aarch64-*.rootfs.cpio.gz||openEuler Embedded file system|
|zImage||openEuler Embedded compressed image|