【发布时间】:2019-12-10 16:35:01
【问题描述】:
背景:
我正在尝试在 Yocto 食谱中构建 ADLINK Vortex OpenSplice Community Edition。
当我尝试在 Bash shell 中构建 OpenSplice 时,一切正常。但是,当我尝试在 sh shell 中构建 OpenSplice 时会出现很多问题。问题是配置脚本(以及它调用的脚本)有很多 bashisms(数组、popd、pushd 等)。 Bash 配置文件太长且复杂,无法使用 Yocto 补丁文件重写为 sh。
问题我无法获取 Bash 脚本来在 Yocto 配方的 do_configure() 中设置环境变量。
我可以在我的 Yocto 配方中运行配置脚本。例如:bash -c "printf '5' | source ${S}/configure"
配置脚本询问我要构建 OpenSplice 的平台,printf '5' 输入选项 5。
但是这个脚本没有设置应该设置的环境变量。我知道,Bash 会启动一个子 shell,并且环境变量不会离开那个 shell。
我试图在我的食谱中找到 Bash:
. bash -c "printf '5' | source ${S}/configure"
但这会产生以下错误:
sh: 3: /bin/bash: Syntax error: Unterminated quoted string
我还尝试过在 python 中使用系统调用。但这会产生同样的问题,它会打开一个子 shell,并且父 shell 中的环境变量不可用。
问题 那么,问题是如何在 Yocto 配方中获取 Bash 脚本?欢迎任何解决方案,包括肮脏的解决方案。
食谱
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=c4bfc022908a26f6f895ab14b6baebca"
# Opensplice does not work with semantic versioning. Therefore ${PV} cannot be used.
# OSPL_V6_9_190925OSS_RELEASE is the 10th release of Opensplice V6.9 (.9 in zero-based
# numbering). SRCREV is commit hash of OSPL_V6_9_190925OSS_RELEASE.
SRC_URI = "git://github.com/ADLINK-IST/opensplice.git"
SRCREV = "c98e118a2e4366d2a5a6af8cbcecdf112bf9e4ab"
S = "${WORKDIR}/git"
DEPENDS += " bash gcc gawk flex bison perl bison-native "
RDEPENDS_${PN} += " bash bison "
do_configure () {
# # configure prompts for choice of target architecture
# # printf '5' enters choice 5; armv7l.linux-release
bash -c "printf '5' | source ${S}/configure"
}
do_build () {
make
}
do_install () {
make install
}
【问题讨论】:
标签: bash shell yocto data-distribution-service opensplice