Sha*_*sai 4 bash embedded-linux yocto
我编写了一个简单的脚本来在我的主板上使用 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';
Run Code Online (Sandbox Code Playgroud)
其对应的systemd脚本如下:
[Unit]
Description=Enable UMTS Dongle for Cloud Connectivity
[Service]
Type=oneshot
ExecStart=/usr/umts.sh
RemainAfterExit=true
[Install]
WantedBy=default.target
Run Code Online (Sandbox Code Playgroud)
我还有其他此类systemd文件用于某些应用程序文件,我目前已直接在板上编写这些文件,但希望它们可用于我为新板制作的每个图像。
我应该如何在食谱方面解决这个问题?
我想创建自己的 Yocto 层:
meta-custom
------ recipes-custom/
------------- files / all such scripts here
------------ custom_1.0.bb
Run Code Online (Sandbox Code Playgroud)
我应该只执行食谱do_install()中的 bash 脚本吗custom_1.0.bb?因为脚本不需要编译?
Creating own layer is a good idea and structure you listed is fine too.
in your recipes you can create empty do_compile and do_configure tasks\ here is a pseudo recipe. And dont forget to add it to IMAGE_INSTALL in the end so that your image build picks it up as dependency.
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>"
Run Code Online (Sandbox Code Playgroud)