Search code examples
yoctobitbakerecipe

Bitbake recipes - Simple file copy


I know there is already an answer for my problem here : bitbake recipe - doing a simple copy of the image

I also want to copy files but I have this error when trying to compile my recipe :

gcc: error: none: No such file or directory

Removing the line :

inherit allarch

Won't cause me any problem, but apparently I need it to copy my files...

Here is my recipe :

DESCRIPTION = "My description"
#To prevent the LICENSE field not set
LICENSE = "CLOSED"
PR = "r1"

SRC_URI = "file://main.c \
           file://foo_update.sh \
           file://foo.service \
           "

S = "${WORKDIR}/"

FILES_${PN} += "/script"

inherit allarch

do_compile() {
        ${CC} ${WORKDIR}/main.c -o fooupdate
}


do_install() {
        install -m 0755 -d ${D}${bindir} ${D}/script
        install -m 0755 ${S}/fooupdate ${D}${bindir}
        install -m 0755 ${S}/foo_update.sh ${D}/script
        install -m 0755 ${S}/foo.service ${D}/script
}

What am I doing wrong ?

Thank you for your help !


Solution

  • Find the solution thanks to this question : bitbake recipe for copying folder, subfolders for yocto

    Remove inherit allarch and instead of using install -m 0755 for the files you want to copy:

    install -m 0755 ${S}/foo_update.sh ${D}/script
    install -m 0755 ${S}/foo.service ${D}/script
    

    Use cp:

    cp ${S}/foo_update.sh ${D}/script
    cp ${S}/foo.service ${D}/script
    

    Complete recipe :

    DESCRIPTION = "My description"
    #To prevent the LICENSE field not set
    LICENSE = "CLOSED"
    PR = "r1"
    
    SRC_URI = "file://main.c \
               file://foo_update.sh \
               file://foo.service \
               "
    
    S = "${WORKDIR}/"
    
    FILES_${PN} += "/script"
    
    inherit allarch
    
    do_compile() {
            ${CC} ${WORKDIR}/main.c -o fooupdate
    }
    
    
    do_install() {
            install -m 0755 -d ${D}${bindir} ${D}/script
            install -m 0755 ${S}/fooupdate ${D}${bindir}
            cp ${S}/foo_update.sh ${D}/script
            cp ${S}/foo.service ${D}/script
    }