【问题标题】:Add a custom executable bash script and its systemd script to Yocto Build将自定义可执行 bash 脚本及其 systemd 脚本添加到 Yocto Build
【发布时间】:2018-05-17 23:53:51
【问题描述】:

我编写了一个简单的脚本,以便在我的主板上使用 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

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

【问题讨论】:

    标签: bash embedded-linux yocto


    【解决方案1】:

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

    在您的食谱中,您可以创建空的 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>"
    

    【讨论】:

    • 这会将systemd脚本推送到图像但是umts.sh/usr/bin/文件夹我也可以在那里使用install吗?一份需要单独配方的遗嘱?
    • 我正在查看大型手册,而这正是需要做的。我认为对于预编译的第三方二进制文件,可能只需要使用inherit bin_package。 (为将来查看此查询的人提供的旁注)
    猜你喜欢
    • 2013-09-02
    • 2017-11-21
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    • 2017-06-20
    • 2018-06-07
    • 1970-01-01
    • 2022-10-20
    相关资源
    最近更新 更多