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

时间:2018-05-17 15:34:04

标签: bash embedded-linux yocto

我写了一个简单的脚本,在我的主板上使用3G UMTS Dongle。

bash脚本如下:

mtcars$font_face

及其对应的#!/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 文件,但希望它们可用于我为新电路板制作的每张图像。

我应该如何在食谱方面解决这个问题?

我想创建自己的Yocto图层:

systemd

我应该只在 meta-custom ------ recipes-custom/ ------------- files / all such scripts here ------------ custom_1.0.bb 食谱中执行do_install() bash脚本吗?因为脚本不需要编译吗?

1 个答案:

答案 0 :(得分:2)

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

在你的食谱中你可以创建空的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>"
相关问题