4

I'm having trouble updating the /etc/fstab of my Linux distribution, when building it with Yocto. I'm pretty new to Yocto, so maybe I'm off my rocker.

My latest attempt is to add a recipe named base-files_%.bbappend.

mount_smackfs () {
    cat >> ${IMAGE_ROOTFS}/etc/fstab <<EOF

# Generated from smack-userspace
smackfs /smack smackfs smackfsdefault=* 0 0 

EOF
} 

ROOTFS_POSTPROCESS_COMMAND += "mount_smackfs; "

But, the output /etc/fstab on the distribution hasn't changed. So the questions are:

  1. Is there a better way to do this?
  2. How can I tell if my .bbappend file was actually executed?
slashingweapon
  • 11,007
  • 4
  • 31
  • 50
  • 1
    A useful thing- you can add a statement: bbplain "Am here now..." inside a shell function within a recipe; it's echo'ed to stdout while 'cooking'. See: https://stackoverflow.com/a/59027178/779269 – kaiwan Jun 02 '21 at 10:31

3 Answers3

11

ROOTFS_POSTPROCESS_COMMAND is handled in image recipes and not in package recipes. You have 2 possibilities.

  • Update your fstab in base-files_%.bbappend:

    do_install_append () {
        cat >> ${D}${sysconfdir}/fstab <<EOF
    
    # Generated from smack-userspace
    smackfs /smack smackfs smackfsdefault=* 0 0 
    
    EOF
    }
    
  • Update the fstab in your image's recipe: In this case, you just append what you wrote above (in your post) in the image's recipe.

Passiday
  • 7,573
  • 8
  • 42
  • 61
john madieu
  • 1,209
  • 12
  • 16
8

Create a new layer using

yocto-layer create mylayer

inside it, create a folder called recipes-core and inside this folder create another folder called base-files.

Inside this folder create a file called base-files_%.bbappend, with the following content:

FILESEXTRAPATHS_append := "${THISDIR}/${PN}:"

Create another folder called base-files, inside which you should put a file called fstab with your configurations.

Make sure to enable your new layer in the bblayers.conf and it will work correctly, no need to create any append recipe or thing. I had this issue and solved it using this method today.

SHERIF OMRAN
  • 157
  • 2
  • 5
5

Given the following directory structure:

.
└── recipes-core/
    └── base-files/
        ├── base-files/
        │   └── fstab
        └── base-files_%.bbappend

and the following content for the recipe base-files_%.bbappend in question

DESCRIPTION = "Allows to customize the fstab"
PR = "r0"

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI += " \
   file://fstab \
"

do_install_append(){
   install -m 0644 ${WORKDIR}/fstab ${D}${sysconfdir}/
}

You can specify the fstab you want in that file and include this in your own custom layer. Once the compilation is finished you will have the custom fstab on the target system.

afinfante
  • 61
  • 1
  • 7