1

So I have a Yocto build and I need to install this 3rd party RPM. I've created a recipe for it using the link to the source RPM. Problem is when implementing the do_install() function.

I need to install it, and it's installed via rpm --install rpm_package, and then I need to enable the service.

For the service I know I have to inherit systemd in my recipe file, but for the installation I'm still confused.

The install command only creates directories and copies files over.

Any help is appreciated.

Artmonk14
  • 19
  • 3

2 Answers2

0

Indeed do_install only create install directories in your /tmp/work/cortex[...]/my_recipe_name/ directory Normally if you bitbake your image which include your recipe you should have a warning like:

Files/directories were installed but not shipped in any package

So, after the installation you need to "package them" in order to be in your final linux image, to do so use FILES_$PN like below for instance:

FILES_${PN}_append = " /usr/sbin/"

where /usr/bin is the directory which contain what you want to "install" in your image.

Then the package will be shipped in your final image.

For the service, indeed inherit systemd is mandatory + you have to add in do_install

install -Dm0644 ${WORKDIR}/my_script.service ${D}${systemd_system_unitdir}/my_script.service

and at the end of your .bbfile

SYSTEMD_SERVICE_${PN} = "my_script.service"
void_brain
  • 642
  • 2
  • 13
  • So does the following need to be at the end of the file? Can it be anywhere else? `SYSTEMD_SERVICE_${PN} = "my_script.service"` – Artmonk14 Mar 18 '22 at 19:53
0

You can install packages at runtime with rpm, but it is not recommended for production builds, as that is the whole idea behind Yocto which is creating a custom distribution with all your needs integrated.

In order to use rpm command in runtime you need to configure it to fetch the sources from the right location. And the right location is generally a Yocto build, because it is compatible with your board's architecture and system (Otherwise, you need to handle that manually).

You can link the Yocto build rpm files to the board's rpm command using smart, for more info check first the official Yocto documentation here.

Also, you can check more example here and here.

IMPORTANT

I do not recommend creating a systemd/sysvinit service to install an rpm/deb/ipk/tar package.

The idea is, if you install a package with rpm it means that it is already supported by Yocto and has a recipe. So, simply:

IMAGE_INSTALL_append = " package"
Talel BELHADJSALEM
  • 3,199
  • 1
  • 10
  • 30