将自定义可执行 bash 脚本及其 systemd 脚本添加到 Yocto Build



我写了一个简单的脚本来在我的开发板上使用3G UMTS加密狗。

bash 脚本如下:

#!/bin/bash
sleep 1;
/usr/bin/tmux new-session -d -s Cloud
/usr/bin/tmux set-option set-remain-on-exit on
/usr/bin/tmux new-window -d -n 'usb_modeswitch' -t Cloud:2 '/usr/sbin/usb_modeswitch --default-vendor 12d1 --default-product 1446 -J';
/usr/bin/tmux new-window -d -n 'wvdial' -t Cloud:1 'sleep 10; /usr/bin/wvdialconf; /usr/bin/wvdial';

其对应的systemd脚本如下:

[Unit]
Description=Enable UMTS Dongle for Cloud Connectivity
[Service]
Type=oneshot
ExecStart=/usr/umts.sh
RemainAfterExit=true
[Install]
WantedBy=default.target

我还有其他这样的systemd文件,用于我目前直接在板上编写的某些应用程序文件,但希望它们可用于我为新开发板制作的每个图像。

就食谱而言,我应该如何解决这个问题?

我想创建自己的Yocto层:

meta-custom
------ recipes-custom/
------------- files / all such scripts here
------------  custom_1.0.bb

我应该只执行custom_1.0.bb配方中的do_install()bash 脚本吗? 因为脚本不需要编译?

创建自己的图层是个好主意,您列出的结构也很好。

在您的食谱中,您可以创建空do_compile和do_configure任务\ 这是一个伪食谱。并且不要忘记将其添加到IMAGE_INSTALL 结束,以便映像生成将其作为依赖项选取。

SRC_URI = "file://file.service 
file://file.sh 
"
inherit systemd
do_configure(){
:
}
do_compile() {
:
}
do_install() {
install -Dm 0644 ${WORKDIR}/<file.service> ${D}/${systemd_unitdir}/system/<file.service>
install -Dm 0755 ${WORKDIR}/<file.sh> ${D}/${bindir}/<file.sh>
...
}
SYSTEMD_SERVICE_${PN} = "<file.service>"

最新更新