mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
翻译完成
This commit is contained in:
parent
e891a6a551
commit
ff1f4a51dc
@ -1,191 +1,201 @@
|
||||
ezio is translating
|
||||
如何在 Ubuntu 上用 Yocto 创建你自己的 Linux 发行版
|
||||
========================================
|
||||
|
||||
How to create your own Linux Distribution with Yocto on Ubuntu
|
||||
============================================================
|
||||
### 本文内容
|
||||
|
||||
### On this page
|
||||
1. [开发机的基本条件][1]
|
||||
2. [Yocto 编译和构建的过程][2]
|
||||
|
||||
1. [Prerequisites for the development machine ][1]
|
||||
2. [Yocto Compilation and Building Process][2]
|
||||
In this article, our focus is the creation of a minimal Linux distribution using the Yocto project on the Ubuntu platform. The Yocto project is very famous in the embedded Linux world because of its flexibility and ease of use. The purpose of the Yocto project is to create a Linux distro for manufacturers of embedded hardware and software. A new minimal Linux distro will be created for qemu as the (qemu is a basic software emulator) target machine and we will run it in qemu.
|
||||
|
||||
In this article, our focus is the creation of a minimal Linux distribution using the Yocto project on the Ubuntu platform. The Yocto project is very famous in the embedded Linux world because of its flexibility and ease of use. The purpose of the Yocto project is to create a Linux distro for manufacturers of embedded hardware and software. A new minimal Linux distro will be created for qemu as the (qemu is a basic software emulator) target machine and we will run it in qemu.
|
||||
本文的主要聚焦在如何使用 Yocto 在 Ubuntu 上穿件一个最小化的 Linux 发行版。Yocto 项目在嵌入式 Linux 的世界非常著名,这是因为它用户起来很灵活、方便。Yocto 的目标是为嵌入式软硬件开发商创建自己的 Linux 发行版。本文我们将会创建一个可以运行在 QEMU 上的最小化 Linux,并且在 QEMU 上实际运行。
|
||||
|
||||
### Prerequisites for the development machine
|
||||
### 开发机的基本条件
|
||||
|
||||
* At least 4 - 6 GB RAM.
|
||||
* Recent Ubuntu OS (16.04 LTS in this case).
|
||||
* At least 60-80 GB free space on the disk.
|
||||
* Installation of following packages before creation of new Linux distro.
|
||||
* Download latest Yocto (Poky which is minimal development environment) stable branch.
|
||||
* 最少 4-6 GB 内存
|
||||
* 最新版的 Ubuntu 系统(本文使用了 16.04 LTS)
|
||||
* 磁盘剩余空间至少 60-80 GB
|
||||
* 在创建 Linux 发行版之前先安装下面的软件包
|
||||
* 下载最新的 Yocto(Poky 时最小开发环境)稳定分支
|
||||
|
||||
```
|
||||
apt-get update
|
||||
|
||||
apt-get install wget git-core unzip make gcc g++ build-essential subversion sed autoconf automake texi2html texinfo coreutils diffstat python-pysqlite2 docbook-utils libsdl1.2-dev libxml-parser-perl libgl1-mesa-dev libglu1-mesa-dev xsltproc desktop-file-utils chrpath groff libtool xterm gawk fop
|
||||
```
|
||||
|
||||
### [
|
||||
![Install prerequisites for Yocto](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/1-pre_requisite_packages-1.png)
|
||||
][3]
|
||||
![Install prerequisites for Yocto](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/1-pre_requisite_packages-1.png)
|
||||
|
||||
As shown below, almost 1 GB size is required to install required development packages.
|
||||
如下所示,开发环境要安装的软件包将近 1GB 大小。
|
||||
|
||||
[
|
||||
![Install the development packages](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/2-pre_requisite_packages-2.png)
|
||||
][4]
|
||||
![Install the development packages](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/2-pre_requisite_packages-2.png)
|
||||
|
||||
In this tutorial, the "morty" stable release of poky is cloned on the system.
|
||||
在这个教程中,系统上克隆的 poky 的分支时 `morty` 稳定分支。
|
||||
|
||||
git clone -b morty git://git.yoctoproject.org/poky.git
|
||||
```
|
||||
git clone -b morty git://git.yoctoproject.org/poky.git
|
||||
```
|
||||
|
||||
[
|
||||
![install poky](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/download_morty_of_yocto.png)
|
||||
][5]
|
||||
![install poky](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/download_morty_of_yocto.png)
|
||||
|
||||
Go inside the "poky" directory and run the following command to set/export some variables for yocto development.
|
||||
进入 `poky` 目录,然后运行下面的命令为 Yocto 开发环境设置(set/export)一些环境变量。
|
||||
|
||||
```
|
||||
source oe-init-build-env
|
||||
```
|
||||
|
||||
As shown below, after running the open embedded (oe) build environment script, the path location in the terminal will be changed to a "build" directory for the further configuration and compilation of new distribution.
|
||||
如下所示,在运行了 oepn embeded (oe) 的构建环境脚本之后,为了之后的配置和构建新版本,终端里的路径会自动切换到 `build` 目录。
|
||||
|
||||
[
|
||||
![Prepare OE build environment](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/source_environment_script.png)
|
||||
][6]
|
||||
|
||||
The above screenshot shows that the "local.conf" file is created inside the "conf" directory. This is the configuration file for yocto which specifies details of the target machine and SDK for desired architecture etc.
|
||||
![Prepare OE build environment](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/source_environment_script.png)
|
||||
|
||||
As shown below, setting target machine "qemux86-64".
|
||||
|
||||
[
|
||||
![Set the target machine type](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/selected_target.png)
|
||||
][7]
|
||||
The above screenshot shows that the "local.conf" file is created inside the "conf" directory. This is the configuration file for yocto which specifies details of the target machine and SDK for desired architecture etc.
|
||||
|
||||
Uncomment following parameters in "local.conf" file as shown in the screenshots.
|
||||
下面的截屏展示了在 `conf` 目录下创建的文件 `local.conf`。这是 Yocto 用来设置目标机器细节和 SDK 的目标架构的配置文件。
|
||||
|
||||
如下所示,这里设置的目标机器时 `qemux86-64`。
|
||||
|
||||
![Set the target machine type](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/selected_target.png)
|
||||
|
||||
如下面截图所示,在 `local.conf` 中取消下面参数的注释符号。
|
||||
|
||||
```
|
||||
DL_DIR ?= "${TOPDIR}/downloads"
|
||||
```
|
||||
|
||||
[
|
||||
![Configure local.conf file](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/uncheck_Download_parameters.png)
|
||||
][8]
|
||||
![Configure local.conf file](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/uncheck_Download_parameters.png)
|
||||
|
||||
```
|
||||
SSTATE_DIR ?= "${TOPDIR}/sstate-cache"
|
||||
```
|
||||
|
||||
[
|
||||
![Set SSTATE_DIR](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/uncheck_sstate_parametes.png)
|
||||
][9]
|
||||
|
||||
![Set SSTATE_DIR](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/uncheck_sstate_parametes.png)
|
||||
|
||||
```
|
||||
TMPDIR ?= "${TOPDIR}/tmp"
|
||||
```
|
||||
|
||||
[
|
||||
![Set TMPDIR](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/tempdir_uncheck_paramerter.png)
|
||||
][10]
|
||||
![Set TMPDIR](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/tempdir_uncheck_paramerter.png)
|
||||
|
||||
``
|
||||
PACKAGE_CLASSES ?= "package_rpm"
|
||||
|
||||
SDKMACHINE ?= "i686"
|
||||
```
|
||||
|
||||
[
|
||||
![Set PACKAGE_CLASSES and SDKMACHINE](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/sdk_and_package_selection.png)
|
||||
][11]
|
||||
![Set PACKAGE_CLASSES and SDKMACHINE](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/sdk_and_package_selection.png)
|
||||
|
||||
As shown below, set a blank password for the Yocto based Linux and include the following parameters in the local.conf file. Otherwise, the user will not be able to login in the new distro.
|
||||
|
||||
如下所示,在 `local.conf` 为基于 Yocto 的 Linux 设置空密码和后续的一些参数。否则的话用户就不能登录进新的发行版。
|
||||
|
||||
```
|
||||
EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
|
||||
```
|
||||
|
||||
[
|
||||
![Set debug-tweaks option](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/extra-features_for_blank_password.png)
|
||||
][12]
|
||||
![Set debug-tweaks option](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/extra-features_for_blank_password.png)
|
||||
|
||||
We are not using any GUI tool such as toaster (hob is no more supported) to create Linux OS.
|
||||
我们并不准备使用任何图形化工具来创建 Linux OS,比如 `toaster` (hob 已经不再被支持了)。
|
||||
|
||||
### Yocto Compilation and Building Process
|
||||
### Yocto 编译构建过程
|
||||
|
||||
Now run the following command of the bitbake utility to start the download and compilation of packages for the selected target machine.
|
||||
现在运行下面的 bitbake 组件的命令开始为选定的目标机器下载和编译软件包。
|
||||
|
||||
```
|
||||
bitbake core-image-minimal
|
||||
```
|
||||
|
||||
[
|
||||
![Start bitbake](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/bitbake_coreimageminimal.png)
|
||||
][13]
|
||||
![Start bitbake](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/bitbake_coreimageminimal.png)
|
||||
|
||||
It is important to run the above command as a normal Linux user and not the root user. As shown in the following sscreenshot, an error is generated when you run the bitbake command as root user.
|
||||
|
||||
[
|
||||
![Do not run bitbake as root](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/dont_user_as_a_root.png)
|
||||
][14]
|
||||
非常重要的是在普通 Linux 用户下运行上面的命令,而不是使用 root 用户。如下面截图所示,当你在 root 用户下运行 bitbake 命令会产生下卖弄所示的错误。
|
||||
|
||||
Again, run the export of environment variables script (oe-init-build-env) and re-run the same command to start the downloading and compilation process.
|
||||
|
||||
[
|
||||
![rerun commands](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/runniing_bitbake_again-normal_user.png)
|
||||
][15]
|
||||
![Do not run bitbake as root](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/dont_user_as_a_root.png)
|
||||
|
||||
As shown below, the first step of build script utility is to parse the recipe.
|
||||
|
||||
[
|
||||
![Parse the build recipes](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/parsing-receipe.png)
|
||||
][16]
|
||||
再一次运行导出环境变量的脚本(`oe-init-build-env`),重新执行相同的命令来启动下载和编译进程。
|
||||
|
||||
The following screenshot shows the completion of the parsing step of the build script. It also shows the details of the build system on which the new yocto based distro will be generated.
|
||||
|
||||
[
|
||||
![Building proceeds](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/output_of_parsing.png)
|
||||
][17]
|
||||
![rerun commands](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/runniing_bitbake_again-normal_user.png)
|
||||
|
||||
如下所示,构建脚本组件的第一步工作是解析配置(recipe)。
|
||||
|
||||
|
||||
![Parse the build recipes](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/parsing-receipe.png)
|
||||
|
||||
|
||||
下面的截图展示了构建脚本的解析过程。同时也显示了你要构建的新的基于 yocto 的发行版的构建系统的细节。
|
||||
|
||||
|
||||
![Building proceeds](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/output_of_parsing.png)
|
||||
|
||||
|
||||
After downloading the SDK and necessary libraries, the next step is to download and compile the packages. The following screenshot shows the task for the new distribution. This step will take 2-3 hours because first, it downloads the required packages and then compiles for the new Linux distribution.
|
||||
|
||||
[
|
||||
![Compilation will take several hours](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/task_list.png)
|
||||
][18]
|
||||
在下载了 SDK 和必要的库之后,下一步是下载和编译软件包。如下的截图展示了为构建新发行版而执行的任务。这一步将会执行 2-3 小时,因为第一要下载需要的软件包,然后还要为新的 Linux 发行版编译这些软件包。
|
||||
|
||||
The following screenshot shows the completion of the task list.
|
||||
|
||||
[
|
||||
![](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/downloaded-all_packages_and_compiled.png)
|
||||
][19]
|
||||
![Compilation will take several hours](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/task_list.png)
|
||||
|
||||
The compiled new images for the target machine type "qemux86-64" is inside the "build/tmp/deploy/images/qemux86-64" path as shown below.
|
||||
|
||||
[
|
||||
![Build complete](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/new_linux_compiled_under_qemux86_64.png)
|
||||
][20]
|
||||
下面的截图显示了任务列表执行完毕。
|
||||
|
||||
As shown below, above command will produce an error if run in the Putty.
|
||||
|
||||
[
|
||||
![command error in putty](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/error_on_putty.png)
|
||||
][21]
|
||||
|
||||
Above command is again run inside the terminal via rdp on Ubuntu platform.
|
||||
![](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/downloaded-all_packages_and_compiled.png)
|
||||
|
||||
[
|
||||
![Command works fine in rdp](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/runqemu_command.png)
|
||||
][22]
|
||||
|
||||
Another screen is opened for the qemu emulator for new yocto based Linux distro.
|
||||
为目标机器类型 `qemux86-64` 编译好的新镜像位于 `build/tmp/deploy/images/qemux86-64`:
|
||||
|
||||
[
|
||||
![Open Quemu emulator](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/new_linux_inside_the_qemu_.png)
|
||||
][23]
|
||||
|
||||
The login screen of the new distro is shown below which also shows the reference version of the yocto project. The default username is root and a blank password.
|
||||
|
||||
[
|
||||
![Linux distribution started](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/reference_distro.png)
|
||||
][24]
|
||||
![Build complete](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/new_linux_compiled_under_qemux86_64.png)
|
||||
|
||||
Finally, login in the new distro with root username and an empty password. As shown in the following screenshot, basic commands (date,ifconfig and uname) are run in the minimal version of Linux.
|
||||
|
||||
[
|
||||
![Test the Linux distribution](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/inside_new_linux_distro_running_on_qemu_3.png)
|
||||
][25]
|
||||
如下所示,上面的命令如果运行在 Putty 上会产生一个错误。
|
||||
|
||||
The purpose of this article is to understand the procedure for the creation of new Linux distribution using yocto project.
|
||||
|
||||
![command error in putty](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/error_on_putty.png)
|
||||
|
||||
|
||||
通过 rdp 在 Ubuntu 平台上再次运行上面的命令。
|
||||
|
||||
|
||||
![Command works fine in rdp](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/runqemu_command.png)
|
||||
|
||||
|
||||
|
||||
为运行新的基于 Yocto 的 Linux 发行版的 qemu 打开一个新屏幕。
|
||||
|
||||
|
||||
|
||||
![Open Quemu emulator](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/new_linux_inside_the_qemu_.png)
|
||||
|
||||
|
||||
|
||||
下面展示了新发行版的登录界面,同时也显示了使用的 yocto 项目的版本号。默认的用户名是 `root` ,密码为空。
|
||||
|
||||
|
||||
![Linux distribution started](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/reference_distro.png)
|
||||
|
||||
|
||||
|
||||
最后使用 root 用户名和空密码登录进新发行版。如下截图所示,在这个最小版本的 Linux 上运行了基本的命令(`data` 、 `ifconfig` 和 `uname`)。
|
||||
|
||||
|
||||
![Test the Linux distribution](https://www.howtoforge.com/images/how-to-create-your-own-linux-distribution-with-yocto/inside_new_linux_distro_running_on_qemu_3.png)
|
||||
|
||||
|
||||
本文的目标是理解使用 Yocto 创建新的 Linux 发行版的过程。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/tutorial/how-to-create-your-own-linux-distribution-with-yocto-on-ubuntu/
|
||||
|
||||
作者:[Ahmad][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[Ezio](https://github.com/oska874)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user