Search code examples
nginxyoctoyocto-recipe

trying to extend Recipe using BBCLASSEXTEND = "nginx" but failed


How to install nginx on yocto project

So After correctly install nginx on yocto

Now I am trying to write my own recipe to replace the default_server which I modified while using BBCLASSEXTEND = "nginx"

/etc/nginx/sites-available/default_server

SUMMARY = "nginxconfig"

DESCRIPTION = "${SUMMARY}"

LICENSE = "CLOSED"

LIC_FILES_CHKSUM = "mychecksum"

S = "${WORKDIR}"

BBCLASSEXTEND = "nginx"

SRC_URI = " \
            file://default_server \ 
            "





do_install() {
    install -d ${D}/etc/nginx/sites-available
   
    cp -f ${WORKDIR}/default_server ${D}/etc/nginx/sites-available/
    

}


FILES_${PN} += "/etc/nginx/sites-available/* "

However it shows error

/meta-wmt/recipes-wmt/nginxconfig/nginxconfig.bb: 
Could not inherit file classes/nginx.bbclassA

So what did I miss here I am pretty sure nginx is exist


Solution

  • BBCLASSEXTEND has nothing to do with what you are trying to accomplish.

    In order to override a file that another recipe is providing, the only solution is to override the original process of installing that file which is do_install of the original nginx recipe.

    You do that by creating a bbappend file to nginx: nginx_%.bbappend.

    [NOTE] If your file is related to only a specific version of nginx then specify the version in the bbappend file name.

    Now, you should have this path:

    meta-wmt
       | recipes-httpd
            | nginx
                | nginx_%.bbappend
                | files
                    | default_server.site        
    

    Make note that the original nginx recipe has the file named: default_server.site, so name your file the same exact name. Keep reading you will know why.

    The nginx_%.bbappend file is with the following content only:

    FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
    

    The trick here is that the original recipe will try to find default_server.site in FILESEXTRAPATHS and as you can see we did a prepend on it, so the new path that contains your custom default_server.site will be the first path it will search in, so it will grab your custom file instead.