将自定义可执行 bash 脚本及其 systemd 脚本添加到 Yocto Build
Add a custom executable bash script and its systemd script to Yocto Build
我已经编写了一个简单的脚本来在我的开发板上使用 3G UMTS Dongle。
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
我应该只执行 do_install()
custom_1.0.bb
食谱中的 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>"
我已经编写了一个简单的脚本来在我的开发板上使用 3G UMTS Dongle。
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
我应该只执行 do_install()
custom_1.0.bb
食谱中的 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>"