
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
build-yocto是https://github.com/gmacario/easy-build%E7%9A%84%E5%AD%90%E9%A1%B9%E7%9B%AE%EF%BC%8C%E6%8F%90%E4%BE%9B%E4%BA%86%E4%B8%80%E7%A7%8D%E5%BF%AB%E9%80%9F%E7%AE%80%E4%BE%BF%E7%9A%84%E6%96%B9%E5%BC%8F%EF%BC%8C%E7%94%A8%E4%BA%8E%E4%BD%BF%E7%94%A8Yocto Project工具创建嵌入式Linux发行版。该镜像预配置了Yocto Project所需的构建环境和工具链,使开发人员能够快速搭建干净的Yocto开发环境,无需手动配置依赖。
wic工具,用于构建系统镜像适用于嵌入式Linux开发人员,尤其是需要使用Yocto Project构建定制化嵌入式Linux发行版的场景。无论是学习Yocto Project、开发嵌入式系统,还是构建特定硬件平台的Linux镜像,都可以通过该镜像快速启动开发流程。
从easy-build项目构建镜像:
bash$ cd .../easy-build $ docker build -t gmacario/build-yocto build-yocto/
基本运行
执行以下命令启动一个干净的Yocto Project开发环境:
bash$ docker run -ti gmacario/build-yocto
带目录共享运行
可使用--volume=[host-src:]container-dest选项在主机和容器间共享目录,示例:
bash$ docker run -ti --volume=${PWD}/shared:/home/build/shared gmacario/build-yocto
详细说明请参考Docker卷文档。
启动后,即可使用Yocto Project工具创建自定义嵌入式Linux发行版。
以下命令用于验证Yocto构建环境是否正确安装。详细信息请参考Yocto Project文档。
克隆Yocto元数据
克隆poky仓库(示例中为Yocto Project 2.0,代号"jethro"):
bash$ mkdir -p ~/shared && sudo chown build.build ~/shared $ cd ~/shared $ git clone -b jethro git://git.yoctoproject.org/poky
更新Yocto元数据
获取poky仓库的最新更新:
bash$ cd ~/shared/poky && git pull --all --prune
创建构建环境
bash$ cd ~/shared $ source ~/shared/poky/oe-init-build-env ~/shared/build-test01
可检查并根据需要修改conf/目录下的配置文件。
构建最小Yocto镜像
执行oe-init-build-env后,即可开始构建:
bash$ bitbake -k core-image-minimal
构建结果示例:
build@afaf6ac0c0e4:~/shared/build-test01$ bitbake -k core-image-minimal Parsing recipes: 100% |############################################################################################| Time: 00:00:25 Parsing of 899 .bb files complete (0 cached, 899 parsed). 1329 targets, 38 skipped, 0 masked, 0 errors. NOTE: Resolving any missing task queue dependencies Build Configuration: BB_VERSION = "1.28.0" BUILD_SYS = "x86_64-linux" NATIVELSBSTRING = "Ubuntu-14.04" TARGET_SYS = "i586-poky-linux" MACHINE = "qemux86" DISTRO = "poky" DISTRO_VERSION = "2.0.1" TUNE_FEATURES = "m32 i586" TARGET_FPU = "" meta meta-yocto meta-yocto-bsp = "jethro:7fe17a2942ff03e2ec47d566fd5393f52b2eb736" NOTE: Preparing RunQueue NOTE: Executing SetScene Tasks NOTE: Executing RunQueue Tasks WARNING: Failed to fetch URL ftp://invisible-island.net/ncurses/current/ncurses-5.9-20150329.tgz, attempting MIRRORS if available WARNING: Failed to fetch URL http://www.openssl.org/source/openssl-1.0.2d.tar.gz, attempting MIRRORS if available WARNING: QA Issue: python-pygobject: /python-pygobject/usr/lib/python2.7/site-packages/pygtk.pth is owned by uid 30000, which is the same as the user running bitbake. This may be due to host contamination [host-user-contaminated] NOTE: Tasks Summary: Attempted 2005 tasks of which 9 didn't need to be rerun and all succeeded. Summary: There were 3 WARNING messages shown. build@afaf6ac0c0e4:~/shared/build-test01$
构建结果存储在tmp/deploy/images/${MACHINE}目录下:
build@afaf6ac0c0e4:~/shared/build-test01$ ls -la tmp/deploy/images/qemux86/ total 97344 drwxr-xr-x 2 build build 4096 Feb 22 15:04 . drwxr-xr-x 3 build build 4096 Feb 22 14:46 .. -rw-r--r-- 2 build build 294 Feb 22 15:04 README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt lrwxrwxrwx 1 build build 72 Feb 22 14:46 bzImage -> bzImage--4.1.17+git0+46bb64d605_2e0ac7b6c4-r0-qemux86-20160222140016.bin -rw-r--r-- 2 build build 6978640 Feb 22 14:45 bzImage--4.1.17+git0+46bb64d605_2e0ac7b6c4-r0-qemux86-20160222140016.bin lrwxrwxrwx 1 build build 72 Feb 22 14:46 bzImage-qemux86.bin -> bzImage--4.1.17+git0+46bb64d605_2e0ac7b6c4-r0-qemux86-20160222140016.bin -rw-r--r-- 1 build build 9138176 Feb 22 15:04 core-image-minimal-qemux86-20160222140016.rootfs.ext4 -rw-r--r-- 1 build build 721 Feb 22 15:04 core-image-minimal-qemux86-20160222140016.rootfs.manifest -rw-r--r-- 1 build build 2399203 Feb 22 15:04 core-image-minimal-qemux86-20160222140016.rootfs.tar.bz2 lrwxrwxrwx 1 build build 53 Feb 22 15:04 core-image-minimal-qemux86.ext4 -> core-image-minimal-qemux86-20160222140016.rootfs.ext4 lrwxrwxrwx 1 build build 57 Feb 22 15:04 core-image-minimal-qemux86.manifest -> core-image-minimal-qemux86-20160222140016.rootfs.manifest lrwxrwxrwx 1 build build 56 Feb 22 15:04 core-image-minimal-qemux86.tar.bz2 -> core-image-minimal-qemux86-20160222140016.rootfs.tar.bz2 -rw-r--r-- 2 build build 83265178 Feb 22 14:46 modules--4.1.17+git0+46bb64d605_2e0ac7b6c4-r0-qemux86-20160222140016.tgz lrwxrwxrwx 1 build build 72 Feb 22 14:46 modules-qemux86.tgz -> modules--4.1.17+git0+46bb64d605_2e0ac7b6c4-r0-qemux86-20160222140016.tgz build@afaf6ac0c0e4:~/shared/build-test01$
使用"wic"工具
从Yocto Project 1.5版本开始,wic工具可用于构建系统镜像。
显示程序版本
bash$ wic --version
Yocto 2.0(jethro)的wic版本为0.2.0:
build@afaf6ac0c0e4:~/shared/build-test01$ wic --version wic version 0.2.0 build@afaf6ac0c0e4:~/shared/build-test01$
显示程序帮助
bash$ wic --help
结果:
build@afaf6ac0c0e4:~/shared/build-test01$ wic --help Usage: Create a customized OpenEmbedded image usage: wic [--version] | [--help] | [COMMAND [ARGS]] Current 'wic' commands are: help Show help for command or one of the topics (see below) create Create a new OpenEmbedded image list List available canned images and source plugins Help topics: overview wic overview - General overview of wic plugins wic plugins - Overview and API kickstart wic kickstart - wic kickstart reference Options: --version show program's version number and exit -h, --help show this help message and exit build@afaf6ac0c0e4:~/shared/build-test01$
列出可用的OpenEmbedded镜像属性
bash$ wic list images
结果:
build@afaf6ac0c0e4:~/shared/build-test01$ wic list images mkhybridiso Create a hybrid ISO image directdisk-multi-rootfs Create multi rootfs image using rootfs plugin qemux86-directdisk Create a qemu machine 'pcbios' direct disk image directdisk-gpt Create a 'pcbios' direct disk image mkgummidisk Create an EFI disk image directdisk Create a 'pcbios' direct disk image sdimage-bootpart Create SD card image with a boot partition mkefidisk Create an EFI disk image build@afaf6ac0c0e4:~/shared/build-test01$
获取"wic create"帮助
bash$ wic help create
结果:
NAME wic create - Create a new OpenEmbedded image SYNOPSIS wic create <wks file or image name> [-o <DIRNAME> | --outdir <DIRNAME>] [-e | --image-name] [-s, --skip-build-check] [-D, --debug] [-r, --rootfs-dir] [-b, --bootimg-dir] [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs] [-c, --compress-with] DESCRIPTION This command creates an OpenEmbedded image based on the 'OE kickstart commands' found in the <wks file>. In order to do this, wic needs to know the locations of the various build artifacts required to build the image. Users can explicitly specify the build artifact locations using the -r, -b, -k, and -n options. See below for details on where the corresponding artifacts are typically found in a normal OpenEmbedded build. Alternatively, users can use the -e option to have 'wic' determine those locations for a given image. If the -e option is used, the user needs to have set the appropriate MACHINE variable in local.conf, and have sourced the build environment. The -e option is used to specify the name of the image to use the artifacts from e.g. core-image-sato. The -r option is used to specify the path to the /rootfs dir to use as the .wks rootfs source. The -b option is used to specify the path to the dir containing the boot artifacts (e.g. /EFI or /syslinux dirs) to use as the .wks bootimg source. The -k option is used to specify the path to the dir containing the kernel to use in the .wks bootimg. The -n option is used to specify the path to the native sysroot containing the tools to use to build the image. The -f option is used to build rootfs by running "bitbake <image>" The -s option is used to skip the build check. The build check is a simple sanity check used to determine whether the user has sourced the build environment so that the -e option can operate correctly. If the user has specified the build artifact locations explicitly, 'wic' assumes the user knows what he or she is doing and skips the build check. The -D option is used to display debug information detailing exactly what happens behind the scenes when a create request is fulfilled (or not, as the case may be). It enumerates and displays the command sequence used, and should be included in any bug report describing unexpected results. When 'wic -e' is used, the locations for the build artifacts values are determined by 'wic -e' from the output of the 'bitbake -e' command given an image name e.g. 'core-image-minimal' and a given machine set in local.conf. In that case, the image is created as if the following 'bitbake -e' variables were used: -r: IMAGE_ROOTFS -k: STAGING_KERNEL_DIR -n: STAGING_DIR_NATIVE -b: empty (plugin-specific handlers must determine this) If 'wic -e' is not used, the user needs to select the appropriate value for -b (as well as -r, -k, and -n). If 'wic -e' is not used, the user needs to select the appropriate value for -b (as well as -r, -k, and -n). The -o option can be used to place the image in a directory with a different name and location. The -c option is used to specify compressor utility to compress an image. gzip, bzip2 and xz compressors are supported.
创建镜像
bash$ bitbake dosfstools-native mtools-native parted-native syslinux $ wic create directdisk -e core-image-minimal
结果:
build@afaf6ac0c0e4:~/shared/build-test01$ wic create directdisk -e core-image-minimal Checking basic build environment... Done. Creating image(s)... Info: The new image(s) can be found here: /var/tmp/wic/build/directdisk-201602221523-sda.direct The following build artifacts were used to create the image(s): ROOTFS_DIR: /home/build/shared/build-test01/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/rootfs BOOTIMG_DIR: /home/build/shared/build-test01/tmp/sysroots/qemux86/usr/share KERNEL_DIR: /home/build/shared/build-test01/tmp/deploy/images/qemux86 NATIVE_SYSROOT: /home/build/shared/build-test01/tmp/sysroots/x86_64-linux The image(s) were created using
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务