poky: PACKAGECONFIG的用法

本文详细解释了PACKAGECONFIG在软件包配置中的作用,通过设置不同的条件来调整编译选项和依赖项。例如,在基于x11或directfb的不同情况下,如何配置pango的编译和运行时依赖。

PACKAGECONFIG是用来区分一个软件包在不同的条件下,配置依赖和编译选项

例如:

PACKAGECONFIG ??= "${@base_contains('DISTRO_FEATURES', 'x11', 'x11', '', d)} \
           ${@base_contains('DISTRO_FEATURES', 'directfb', 'directfb', '', d)}"
PACKAGECONFIG[x11] = "--with-x,--without-x,${X11DEPENDS}"
PACKAGECONFIG[directfb] = ",,directfb"


用法说明:

PACKAGECONFIG[foo] = "--enable-foo,--disable-foo,foo_depends,foo_runtime_depends"

有四个参数,

--enable-foo:表示如果有foo的那么使能它

--disable-foo:表示没有foo的情况下就不是能它

foo_depends: 表示如果有foo的情况下编译时的依赖。

foo_runtime_depends:表示如果有foo的情况下,运行时的依赖

上面的例子是pango对基于x11或direcrfb的情况

如果是基于x11的(${@base_contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}),那么configure时,--with-x, 编译依赖${X11DEPENDS}

如果是基于direcrfb(${@base_contains('DISTRO_FEATURES', 'directfb', 'directfb', '', d)})的,那么运行confiure时,--without-x,编译依赖direcrfb

修改后,报错: ERROR: qtwayland-native-5.15.3+gitAUTOINC+f9dfeb6e72-r0 do_configure: Error calling /DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/recipe-sysroot-native/usr/bin/qmake -makefile -o Makefile QT_BUILD_PARTS-=examples QT_BUILD_PARTS-=tests -no-feature-wayland-vulkan-server-buffer /DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/git/src/qtwaylandscanner -- -no-feature-wayland-brcm -no-feature-wayland-client -no-feature-wayland-drm-egl-server-buffer -no-feature-wayland-egl -no-feature-wayland-libhybris-egl-server-buffer -no-feature-wayland-server -no-feature-wayland-vulkan-server-buffer -no-feature-xcomposite-egl -no-feature-xcomposite-glx ERROR: qtwayland-native-5.15.3+gitAUTOINC+f9dfeb6e72-r0 do_configure: ExecutionError('/DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/temp/run.do_configure.102733', 1, None, None) ERROR: Logfile of failure stored in: /DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/temp/log.do_configure.102733 Log data follows: | DEBUG: Executing python function extend_recipe_sysroot | NOTE: Direct dependencies are ['/DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/poky/meta-joynext/meta-qt5/recipes-qt/qt5/qtbase-native_git.bb:do_populate_sysroot', '/DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/poky/meta/recipes-devtools/quilt/quilt-native_0.67.bb:do_populate_sysroot', 'virtual:native:/DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/poky/meta-joynext/meta-qt5/recipes-qt/qt5/qtdeclarative_git.bb:do_populate_sysroot', 'virtual:native:/DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/poky/meta/recipes-devtools/pkgconfig/pkgconfig_git.bb:do_populate_sysroot', 'virtual:native:/DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/poky/meta/recipes-graphics/wayland/wayland_1.20.0.bb:do_populate_sysroot'] | NOTE: Installed into sysroot: [] | NOTE: Skipping as already exists in sysroot: ['qtbase-native', 'quilt-native', 'qtdeclarative-native', 'pkgconfig-native', 'wayland-native', 'zlib-native', 'dbus-native', 'expat-native', 'libffi-native', 'python3-native', 'libxml2-native', 'xz-native', 'libtool-native', 'glib-2.0-native', 'gettext-minimal-native', 'cmake-native', 'texinfo-dummy-native', 'readline-native', 'ncurses-native', 'openssl-native', 'libtirpc-native', 'sqlite3-native', 'gdbm-native', 'util-linux-libuuid-native', 'bzip2-native', 'libnsl2-native', 'libpcre-native', 'gettext-native', 'util-linux-native', 'zstd-native', 'curl-native', 'perl-native', 'libpcre2-native', 'libcap-ng-native', 'make-native'] | DEBUG: Python function extend_recipe_sysroot finished | DEBUG: Executing shell function qmake5_base_preconfigure | DEBUG: Shell function qmake5_base_preconfigure finished | DEBUG: Executing shell function do_configure | NOTE: qmake using profiles: '/DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/git/src/qtwaylandscanner' | NOTE: qmake prevar substitution: ' QT_BUILD_PARTS-=examples QT_BUILD_PARTS-=tests -no-feature-wayland-vulkan-server-buffer' | NOTE: qmake configure substitution: ' -no-feature-wayland-brcm -no-feature-wayland-client -no-feature-wayland-drm-egl-server-buffer -no-feature-wayland-egl -no-feature-wayland-libhybris-egl-server-buffer -no-feature-wayland-server -no-feature-wayland-vulkan-server-buffer -no-feature-xcomposite-egl -no-feature-xcomposite-glx' | Usage: /DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/recipe-sysroot-native/usr/bin/qmake [mode] [options] [files] | | QMake has two modes, one mode for generating project files based on | some heuristics, and the other for generating makefiles. Normally you | shouldn't need to specify a mode, as makefile generation is the default | mode for qmake, but you may use this to test qmake on an existing project | | Mode: | -project Put qmake into project file generation mode | In this mode qmake interprets [files] as files to | be added to the .pro file. By default, all files with | known source extensions are added. | Note: The created .pro file probably will | need to be edited. For example add the QT variable to | specify what modules are required. | -makefile Put qmake into makefile generation mode (default) | In this mode qmake interprets files as project files to | be processed, if skipped qmake will try to find a project | file in your current working directory | | Warnings Options: | -Wnone Turn off all warnings; specific ones may be re-enabled by | later -W options | -Wall Turn on all warnings | -Wparser Turn on parser warnings | -Wlogic Turn on logic warnings (on by default) | -Wdeprecated Turn on deprecation warnings (on by default) | | Options: | * You can place any variable assignment in options and it will be * | * processed as if it was in [files]. These assignments will be * | * processed before [files] by default. * | -o file Write output to file | -d Increase debug level | -t templ Overrides TEMPLATE as templ | -tp prefix Overrides TEMPLATE so that prefix is prefixed into the value | -help This help | -v Version information | -early All subsequent variable assignments will be | parsed right before default_pre.prf | -before All subsequent variable assignments will be | parsed right before [files] (the default) | -after All subsequent variable assignments will be | parsed after [files] | -late All subsequent variable assignments will be | parsed right after default_post.prf | -norecursive Don't do a recursive search | -recursive Do a recursive search | -set <prop> <value> Set persistent property | -unset <prop> Unset persistent property | -query <prop> Query persistent property. Show all if <prop> is empty. | -qtconf file Use file instead of looking for qt.conf | -cache file Use file as cache [makefile mode only] | -spec spec Use spec as QMAKESPEC [makefile mode only] | -nocache Don't use a cache file [makefile mode only] | -nodepend Don't generate dependencies [makefile mode only] | -nomoc Don't generate moc targets [makefile mode only] | -nopwd Don't look for files in pwd [project mode only] | ***Unknown option -no-feature-wayland-vulkan-server-buffer | ERROR: Error calling /DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/recipe-sysroot-native/usr/bin/qmake -makefile -o Makefile QT_BUILD_PARTS-=examples QT_BUILD_PARTS-=tests -no-feature-wayland-vulkan-server-buffer /DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/git/src/qtwaylandscanner -- -no-feature-wayland-brcm -no-feature-wayland-client -no-feature-wayland-drm-egl-server-buffer -no-feature-wayland-egl -no-feature-wayland-libhybris-egl-server-buffer -no-feature-wayland-server -no-feature-wayland-vulkan-server-buffer -no-feature-xcomposite-egl -no-feature-xcomposite-glx | WARNING: /DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/temp/run.do_configure.102733:212 exit 1 from 'exit 1' | WARNING: Backtrace (BB generated script): | #1: bbfatal_log, /DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/temp/run.do_configure.102733, line 212 | #2: die, /DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/temp/run.do_configure.102733, line 202 | #3: qmake5_base_do_configure, /DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/temp/run.do_configure.102733, line 188 | #4: do_configure, /DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/temp/run.do_configure.102733, line 156 | #5: main, /DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/build-qti-distro-rb-debug/tmp-glibc/work/x86_64-linux/qtwayland-native/5.15.3+gitAUTOINC+f9dfeb6e72-r0/temp/run.do_configure.102733, line 216 ERROR: Task (virtual:native:/DATA/Joynext/zhao_w1/SA8538/LE.PRODUCT.2.1.R3/poky/meta-joynext/meta-qt5/recipes-qt/qt5/qtwayland_git.bb:do_configure) failed with exit code '1' WARNING: Recipe inherits features_check but doesn't use it
08-14
<think>我们分析用户问题:用户希望理解执行`docker run`命令启动`crops/poky:ubuntu-20.04`容器后,进入容器工作目录并执行`ls`列出文件的操作原理,以及常见情况说明。 操作流程示例: 1. 启动容器并进入:`docker run -it crops/poky:ubuntu-20.04 /bin/bash` 2. 进入容器后,默认会进入工作目录(通常是`/workdir`,具体由镜像定义) 3. 执行`ls`列出文件 原理分析: 1. `docker run`命令创建并启动容器 2. `-it`选项分配一个交互式终端并保持STDIN打开 3. 容器启动后执行`/bin/bash`,进入交互式shell 4. 容器内的当前工作目录由镜像的`WORKDIR`指令设置(如果没有设置则为根目录`/`) 5. `ls`命令列出当前工作目录下的文件和目录 关键点: - **工作目录(WORKDIR)**:在Dockerfile中,可以通过`WORKDIR`指令设置工作目录。对于`crops/poky:ubuntu-20.04`镜像,我们可以查看其[Dockerfile](https://github.com/crops/docker-images/blob/master/poky/ubuntu-20.04/Dockerfile)来确定工作目录。根据官方Dockerfile,该镜像设置了`WORKDIR /workdir`。 - **`ls`命令的执行**:在容器内执行`ls`命令,会显示当前工作目录下的文件和目录。如果该目录为空,则没有输出。 常见情况说明: 1. **工作目录为空**:如果刚刚启动容器,且镜像没有在工作目录中预置文件,则`ls`命令不会显示任何内容。 2. **挂载卷的影响**:如果在运行容器时使用了`-v`选项挂载主机目录到容器的工作目录,则`ls`会显示主机目录中的文件。例如:`docker run -it -v $(pwd):/workdir crops/poky:ubuntu-20.04`,这样容器的工作目录就会显示主机当前目录的文件。 3. **权限问题**:如果容器中的用户没有工作目录的读取权限,`ls`命令会报错“Permission denied”。默认情况下,`crops/poky`镜像使用非root用户(通常为`crops`),因此需要确保该用户有工作目录的权限。在Dockerfile中,通常已经设置好权限。 4. **工作目录不存在**:如果镜像中设置的工作目录不存在,则启动容器时会报错。但`crops/poky`的Dockerfile中通过`RUN mkdir`创建了`/workdir`目录。 深入原理: - 当执行`docker run`时,Docker引擎会执行以下步骤: 1. 从镜像创建一个新的容器 2. 分配文件系统和网络 3. 设置工作目录(由镜像的`WORKDIR`指定) 4. 执行命令(这里是`/bin/bash`) - 在容器内执行命令(如`ls`)时,是在容器的隔离文件系统环境中运行。容器文件系统由镜像的只读层和顶部的可写层组成。 操作示例: ```bash # 启动容器,进入bash docker run -it crops/poky:ubuntu-20.04 /bin/bash # 在容器内,查看当前工作目录 crops@container-id:/workdir$ pwd /workdir # 列出文件 crops@container-id:/workdir$ ls # 可能没有输出(空目录),或者显示挂载的内容 # 退出容器 crops@container-id:/workdir$ exit ``` 注意事项: - 容器退出后,对文件系统的更改(除非使用卷)会丢失(除非使用`docker commit`保存为镜像)。 - 如果需要保存工作目录中的更改,建议使用卷(`-v`)或绑定挂载。 引用: - [Dockerfile reference - WORKDIR](https://docs.docker.com/engine/reference/builder/#workdir)[^1] - [Docker run reference](https://docs.docker.com/engine/reference/run/)[^2] §§相关问题§§ 1. 如何查看 `crops/poky:ubuntu-20.04` 镜像的 Dockerfile 内容? 2. 在 Docker 容器中如何更改工作目录? 3. 如何将主机目录挂载到容器的工作目录? </think> ### Docker 容器操作原理分析:`docker run` + `ls` 工作目录 #### 一、操作流程分解 ```bash # 启动容器并进入交互模式 docker run -it crops/poky:ubuntu-20.04 /bin/bash # 容器内操作(自动进入工作目录) ls ``` #### 二、底层原理详解 1. **`docker run` 阶段** - 创建容器:基于镜像`crops/poky:ubuntu-20.04`创建新容器实例 - 分配资源:分配文件系统、网络栈和进程空间(通过 Linux namespaces 隔离) - 挂载层:在镜像只读层上添加可写层(Copy-on-Write 机制)[^1] - 启动进程:执行`/bin/bash`作为 PID 1 进程 2. **工作目录进入机制** ```mermaid graph LR A[Dockerfile] -->|WORKDIR 指令| B(镜像元数据) B --> C[docker run] C --> D[容器启动时自动cd到指定目录] ``` - 该镜像的 Dockerfile 定义了 `WORKDIR /workdir`(Yocto 标准路径) - 容器启动时自动切换到此目录(等效于执行 `cd /workdir`) 3. **`ls` 命令执行过程** - 在容器进程空间执行 `/bin/ls` 程序 - 读取当前目录(`/workdir`)的 inode 信息 - 通过联合文件系统(OverlayFS)访问目录内容: - 底层:镜像只读层 - 上层:容器可写层 - 输出结果到伪终端(由 `-it` 参数分配) #### 三、常见目录状态及原因 | 现象 | 原因 | 解决方案 | |------|------|----------| | `ls` 无输出 | 全新容器未添加文件 | 挂载主机目录:`docker run -v ./host_dir:/workdir ...` | | 权限错误 | 容器用户(crops)无权限 | 启动时加 `-u 0` 切root 或 `chmod` 改权限 | | 目录不存在 | 镜像未设置 WORKDIR | 手动创建目录:`mkdir mydir && cd mydir` | | 文件不显示 | OverlayFS 挂载问题 | 检查存储驱动:`docker info | grep Storage` | #### 四、关键配置验证方法 ```bash # 1. 检查镜像预设的工作目录 docker inspect crops/poky:ubuntu-20.04 | grep -A 3 WorkingDir # 2. 查看实际目录内容(不进入容器) docker run --rm crops/poky:ubuntu-20.04 ls /workdir # 3. 诊断文件系统挂载 docker run --rm --mount type=tmpfs,dst=/workdir crops/poky:ubuntu-20.04 ``` #### 五、典型应用场景 1. **Yocto 项目构建** ```bash # 挂载主机代码目录到工作目录 docker run -v $(pwd)/yocto:/workdir crops/poky:ubuntu-20.04 ``` 2. **环境调试** ```bash # 检查目录结构 docker run --rm crops/poky:ubuntu-20.04 find /workdir -type d ``` 3. **文件权限修复** ```bash # 递归修改工作目录权限 docker run -v mydata:/workdir crops/poky:ubuntu-20.04 \ chown -R crops:crops /workdir ``` > **提示**:通过 `docker exec` 可在运行中的容器执行命令,如 `docker exec -it <container-id> ls /workdir`
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值