LoginSignup
0
2

More than 3 years have passed since last update.

Yoctoでrecipeの追加(ファイルのコピーのみをするレシピの追加)

Posted at

はじめに

Yoctoを使っていて、「単純にファイルをroot fsにコピーするだけのレシピってどうやって書くの?」と思って調べ、作ったレシピを記載します。

やりたいこと

ファイル、ディレクトリをroot fsにコピーしたい。
ここで言うファイル、ディレクトリはレシピでビルドされるコードではない。
単純にコピーをしたいただのファイル。

環境準備

zeusを使用します。
https://git.yoctoproject.org/cgit/cgit.cgi/poky/log/?h=zeus

参考 Release Activity

conf/local.conf

MACHINEもなんでもいいのですが、qemu用の環境を選択。
ここではarm64環境としています。

MACHINE ?= "qemuarm64"

作成するレシピ

$ tree meta-mylayer/
meta-mylayer/
├── COPYING.MIT
├── README
├── conf
│   └── layer.conf
└── recipes-myhellobin
    └── myhellobin
        ├── myhellobin
        │   ├── hello.bin    <------- 適当なファイル(コピーするだけのファイル)
        │   └── hoge.tar.gz  <------- 適当なファイル(コピーするだけのファイル)
        └── myhellobin.bb

hoge.tar.gz

hoge.tar.gz の中身は以下。適当なテキストファイルがあるのみ。

$ tree hoge
hoge
├── hoge01.txt
└── hoge02.txt

参考にしたレシピ

既存のレシピを探したら /etc にファイルをコピーするようなレシピがあったのでこちらを参考にした。
base-files_3.0.14.bb

myhellobin.bb

base-files_3.0.14.bb を参考にした myhellobin.bb がこちら。

hello.bin を /home/rootに、
hoge ディレクトリを /home/root, /etc, /usr/lib にコピーするのみ。

SUMMARY = "copy files"
SECTION = "BASE"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://hello.bin \
file://hoge.tar.gz \
"

S = "${WORKDIR}"
INHIBIT_DEFAULT_DEPS = "1"

do_install() {
    install -d ${D}/home/root
    install -d ${D}/etc
    install -d ${D}/usr/lib

    install -m 0755 ${WORKDIR}/hello.bin ${D}/home/root
    cp -r ${WORKDIR}/hoge ${D}/home/root
    cp -r ${WORKDIR}/hoge ${D}/etc
    cp -r ${WORKDIR}/hoge ${D}/usr/lib
}

FILES_${PN} = "/"

最初、hogeディレクトリのコピーはtarコマンドで

    tar vxf ${WORKDIR}/hoge.tar.gz -C ${D}/home/root

とか書けばのかなと思ったのですが、bitbakeのデフォルトの動作(?)で勝手にworkディレクトリ内に展開されてしまうのでcpコマンドを使用。

メモ

INHIBIT_DEFAULT_DEPS

Prevents the default dependencies, namely the C compiler and standard C library (libc), from being added to DEPENDS. > This variable is usually used within recipes that do not require any compilation using the C compiler.

Set the variable to "1" to prevent the default dependencies from being added.

コンパイラを使用しないレシピでは 1 を設定する、ということですかね。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2