背景:,我正在尝试在Yocto食谱中构建旋涡OpenSplice社区版。
当我尝试在Bash中构建OpenSplice时,一切都很好。但是,当我试图在sh shell中构建OpenSplice时,存在很多问题。问题是配置脚本(以及它调用的脚本)有大量的bashism(数组、popd、pushd等等)。Bash配置文件太长,太复杂,无法用Yocto修补程序文件重写sh。
Problem I无法在Yocto食谱中的do_configure()中使用Bash脚本来设置环境变量。
我可以在Yocto食谱中运行配置脚本。例如,这样做是可行的:
bash -c "printf '5' | source ${S}/configure"配置脚本询问要构建OpenSplice的平台,printf '5'输入选项5。
但是这个脚本没有设置应该设置的环境变量。我知道,Bash启动一个子shell,并且环境变量不会离开这个shell。
我试着在我的食谱:. bash -c "printf '5' | source ${S}/configure"中找到Bash
但这会导致以下错误: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
}发布于 2019-12-11 03:56:56
您可以尝试从do_configure方法中更改这一行:
bash -c "printf '5' | source ${S}/configure"像这样的事情:
bash -c ". /some/path/fileName && printf '5' | source ${S}/configure"发布于 2019-12-12 16:04:57
您无法在Yocto菜谱中来源具有特定Bash命令的Bash脚本。
幸运的是,在OpenSplice配置脚本的末尾,所有环境变量都被转储到sh文件中。然后,可以以与POSIX兼容的方式来获取这个sh文件。由此产生的配方如下:
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=c4bfc022908a26f6f895ab14b6baebca"
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 "
do_configure () {
# configure prompts for choice of target architecture
# printf '5' enters choice 5; armv7l.linux-release
# This command creates the file ./envs-armv7l.linux-release.sh
# which is sourced by do_compile and do_install
bash -c "printf '5' | source ${S}/configure"
}
do_compile () {
# Source the file with the environment variables
. ${S}/envs-armv7l.linux-release.sh
make
}
do_install_prepend () {
# Source the file with the environment variables
. ${S}/envs-armv7l.linux-release.sh
}
do_install_append () {
install -d ${D}/bin/
install -m 0644 ${S}/exec/armv7l.linux-release/* ${D}/bin/
install -d ${D}/lib/
install -m 0644 ${S}/lib/armv7l.linux-release/* ${D}/lib/
}https://stackoverflow.com/questions/59271765
复制相似问题