如何在Yocto Kirkstone版本中为镜像添加php-pear包?
在Yocto Kirkstone版本中添加php-pear包的解决方法
问题背景
使用Yocto Kirkstone版本,基于php_8.1.29.bb搭建的PHP环境运行正常,但将php-pear添加到镜像配置后执行bitbake core-image-minimal时,出现包找不到的错误:
User-Agent: falling back to 'libdnf': could not detect OS or basearch repo: using cache for: oe-repo oe-repo: using metadata from Mon 29 Jul 2024 04:42:57 PM UTC. Last metadata expiration check: 0:00:01 ago on Tue 30 Jul 2024 07:58:42 AM UTC. No match for argument: php-pear Error: Unable to find a match: php-pear
尽管php_8.1.29.bb的PACKAGES字段中提到了php-pear,但实际编译未生成该包。
解决步骤
检查并启用PHP配方中PEAR的编译开关
打开php_8.1.29.bb配方文件,查找是否存在PACKAGECONFIG对PEAR的控制项,例如:PACKAGECONFIG[pear] = "--with-pear,--without-pear"如果有类似配置,在
local.conf中添加以下内容启用PEAR编译:PACKAGECONFIG:append:pn-php = " pear"验证php-pear包是否生成
清理PHP的编译缓存并重新编译:bitbake php -c cleanall && bitbake php查看编译产物目录(如
tmp/work/${MACHINE}/php/8.1.29-r0/packages/或tmp/deploy/rpm/${ARCH}/),确认是否存在php-pear相关包文件。更新镜像安装配置
将php-pear正确添加到镜像安装列表中,确保空格分隔:IMAGE_INSTALL:append = " php-pear"或添加到
CORE_IMAGE_EXTRA_INSTALL:CORE_IMAGE_EXTRA_INSTALL += "php-pear"重新编译镜像
执行以下命令重新生成镜像:bitbake core-image-minimal若仍有缓存问题,可先清理镜像的编译状态:
bitbake -c cleansstate core-image-minimal && bitbake core-image-minimal
原因说明
配方中PACKAGES字段仅定义了可能生成的包列表,但如果编译时未启用对应的功能(如PEAR的--with-pear配置),实际不会生成php-pear包,因此包管理工具无法找到该包。
内容的提问来源于stack exchange,提问作者Jinu Jose
相关产品推荐
相关产品推荐

