Bitbake构建时Python函数异常导致RPM包打包任务失败求助
Perl 5.30.1 RPM构建任务报错排查指南
报错信息中文翻译
错误:perl-5.30.1-r0 do_package_write_rpm:执行exec_func_python()自动生成的Python函数时出错 触发异常的Python调用栈如下: 文件:'exec_func_python() autogenerated',行号:2,函数:<module> 0001: *** 0002:do_package_rpm(d) 0003: 文件:'/srv/yocto/poky/meta/classes/package_rpm.bbclass',行号:712,函数:do_package_rpm 0708: 0709: # 构建RPM包! 0710: d.setVar('BUILDSPEC', cmd + "\n" + cleanupcmd + "\n") 0711: d.setVarFlag('BUILDSPEC', 'func', '1') 0712: bb.build.exec_func('BUILDSPEC', d) 0713: 0714: if d.getVar('RPM_SIGN_PACKAGES') == '1': 0715: bb.build.exec_func("sign_rpm", d) 0716:} 文件:'/srv/yocto/poky/bitbake/lib/bb/build.py',行号:254,函数:exec_func 0250: with bb.utils.fileslocked(lockfiles): 0251: if ispython: 0252: exec_func_python(func, d, runfile, cwd=adir) 0253: else: *** 0254: exec_func_shell(func, d, runfile, cwd=adir) 0255: 0256: try: 0257: curcwd = os.getcwd() 0258: except: 文件:'/srv/yocto/poky/bitbake/lib/bb/build.py',行号:455,函数:exec_func_shell 0451: with open(fifopath, 'r+b', buffering=0) as fifo: 0452: try: 0453: bb.debug(2, "执行shell函数 %s" % func) 0454: with open(os.devnull, 'r+') as stdin, logfile: *** 0455: bb.process.run(cmd, shell=False, stdin=stdin, log=logfile, extrafiles=[(fifo,readfifo)]) 0456: finally: 0457: os.unlink(fifopath) 0458: 0459: bb.debug(2, "Shell函数 %s 执行完成" % func) 文件:'/srv/yocto/poky/bitbake/lib/bb/process.py',行号:184,函数:run 0180: 0181: if pipe.returncode != 0: 0182: if log: 0183: # 如果已经记录日志,就不要在异常里重复输出内容 *** 0184: raise ExecutionError(cmd, pipe.returncode, None, None) 0185: raise ExecutionError(cmd, pipe.returncode, stdout, stderr) 0186: return stdout, stderr 异常:bb.process.ExecutionError:执行'/srv/yocto/build/tmp/work/corei7-64-poky-linux/perl/5.30.1-r0/temp/run.BUILDSPEC.35372'失败,退出码1
核心问题说明
该报错本质不是Python层逻辑错误,是Python层捕获到了RPM打包的shell脚本执行失败的异常,真正的错误原因在shell执行日志里。
排查思路
- 优先查看对应构建日志:打开报错中提到的同目录下的
log.BUILDSPEC.35372文件,里面会记录rpmbuild执行的详细报错,比如spec文件语法错误、依赖缺失、文件不存在、权限不足这类具体问题,90%以上的同类问题都可以通过这一步定位根因。 - 验证前置构建步骤是否正常:分别执行
bitbake perl -c compile和bitbake perl -c install,确认编译、安装步骤没有隐藏错误,安装目录下的perl二进制、库、模块文件都完整,没有缺失或权限异常。 - 检查RPM打包配置:确认是否自定义过和perl打包相关的变量,比如
FILES_perl、RPM_EXTRA_PACKAGES等,没有错误加入不存在的路径,也没有遗漏必要的打包路径导致自动生成的spec文件异常。 - 验证宿主机rpmbuild工具:执行
rpmbuild --version确认工具可以正常运行,没有缺失依赖,版本和当前使用的Yocto版本适配。 - 清理缓存重试:执行
bitbake perl -c cleansstate清理perl任务的所有缓存状态,再重新执行bitbake perl -c package_write_rpm,排除缓存损坏导致的偶发故障。 - 检查系统资源与权限:确认构建目录所在磁盘剩余空间充足,当前构建用户对整个构建目录有完整的读写执行权限,没有被selinux、防火墙等安全工具拦截文件操作。
内容的提问来源于stack exchange,提问作者Maksym Iliev
相关产品推荐
相关产品推荐

