[LINUX] Add recipe in Yocto (add recipe that only copies files)

Introduction

I'm using Yocto, I wondered "How do I write a recipe that simply copies a file to root fs?", And I will describe the recipe I made.

Thing you want to do

I want to copy files and directories to root fs. The files and directories mentioned here are not the code built by the recipe. The file you just copied.

Environmental preparation

Use zeus. https://git.yoctoproject.org/cgit/cgit.cgi/poky/log/?h=zeus

Reference Release Activity

conf/local.conf

MACHINE can be anything, but select the environment for qemu. Here, it is an arm64 environment.

MACHINE ?= "qemuarm64"

Recipe to create

$ tree meta-mylayer/
meta-mylayer/
├── COPYING.MIT
├── README
├── conf
│   └── layer.conf
└── recipes-myhellobin
    └── myhellobin
        ├── myhellobin
        │   ├── hello.bin    <-------Appropriate file(Files just to copy)
        │   └── hoge.tar.gz  <-------Appropriate file(Files just to copy)
        └── myhellobin.bb

hoge.tar.gz

The contents of hoge.tar.gz are as follows. There is only a suitable text file.

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

Referenced recipe

When I searched for an existing recipe, there was a recipe that copied the file to / etc, so I referred to this. base-files_3.0.14.bb

myhellobin.bb

[base-files_3.0.14.bb](https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/recipes-core/base-files/base-files_3.0.14.bb?h= Here is myhellobin.bb which is based on zeus).

Hello.bin to / home / root Just copy the hoge directory to / 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} = "/"

Initially, copy the hoge directory with the tar command

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

I thought I should write it, but I used the cp command because it is expanded in the work directory by the default operation (?) Of bitbake.

Note

INHIBIT_DEFAULT_DEPS

https://www.yoctoproject.org/docs/latest/ref-manual/ref-manual.html#var-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.

Does that mean setting 1 for recipes that don't use a compiler?

Recommended Posts

Add recipe in Yocto (add recipe that only copies files)
How to add page numbers to PDF files (in Python)
Extract only elements that meet specific conditions in Python