Setting up a package feed
An embedded system project seldom has the need to introduce changes to the Yocto build system. Most of the time and effort is spent in application development, followed by a lesser amount in maybe kernel and bootloader development.
As such, a whole system rebuild is probably done very few times. A new project is usually built from a prebuilt shared state cache, and application development work only needs to be done to perform full or incremental builds of a handful of packages.
Once the packages are built, they need to be installed on the target system for testing. Emulated machines are fine for application development, but most hardware-related work needs to be done on embedded hardware.
Getting ready
An option is to manually copy the build binaries to the target's root filesystem, either copying it to the NFS share on the host system the target is mounting its root filesystem from (as explained in the Configuring network booting for a development setup recipe earlier) or using any other method like SCP, FTP, or even a microSD card.
This method is also used by IDEs like Eclipse when debugging an application you are working on. However, this method does not scale well when you need to install several packages and dependencies.
The next option would be to copy the packaged binaries (that is, the RPM, deb, or ipk packages) to the target's filesystem and then use the target's package management system to install them. For this to work, your target's filesystem needs to be built with package management tools. Doing this is as easy as adding the package-management
feature to your root filesystem; for example, you may add the following line to your project's conf/local.conf
file:
EXTRA_IMAGE_FEATURES += "package-management"
So for an RPM package, you will copy it to the target and use the rpm or smart utilities to install it. The smart package management tool is GPL licensed and can work with a variety of package formats.
However, the most optimized way to do this is to convert your host system package's output directory into a package feed. For example, if you are using the default RPM package format, you may convert tmp/deploy/rpm
in your build
directory into a package feed that your target can use to update.
For this to work, you need to configure an HTTP server on your computer that serves the packages.
Versioning packages
You also need to make sure that the generated packages are correctly versioned, and that means updating the recipe revision, PR, with every change. It is possible to do this manually, but the recommended—and compulsory way if you want to use package feeds—is to use a PR server.
However, the PR server is not enabled by default. The packages generated without a PR server are consistent with each other but offer no update guarantees for a system that is already running.
The simplest PR server configuration is to run it locally on your host system. To do this, you add the following to your conf/local.conf
file:
PRSERV_HOST = "localhost:0"
With this setup, update coherency is guaranteed for your feed.
If you want to share your feed with other developers, or you are configuring a build server or package server, you would run a single instance of the PR server by running the following command:
$ bitbake-prserv --host <server_ip> --port <port> --start
And you will update the project's build configuration to use the centralized PR server, editing conf/local.conf
as follows:
PRSERV_HOST = "<server_ip>:<port>"
Also, if you are using a shared state cache as described before, all of the contributors to the shared state cache need to use the same PR server.
Once the feed's integrity is guaranteed, we need to configure an HTTP server to serve the feed.
How to do it...
We will use lighttpd
for this example, as it is lightweight and easy to configure. Follow these steps:
- Install the web server:
$ sudo apt-get install lighttpd
- By default, the document root specified in the
/etc/lighttpd/lighttpd.conf
configuration file is/var/www/
, so we only need a symlink to our package feed:$ sudo mkdir /var/www/wandboard-quad $ sudo ln -s /opt/yocto/fsl-community-bsp/wandboard- quad/tmp/deploy/rpm /var/www/wandboard-quad/rpm
Next, reload the configuration as follows:
$ sudo service lighttpd reload
- Refresh the package index. This needs to be done manually to update the package feed after every build:
$ bitbake package-index
- Then we need to configure our target filesystem with the new package feeds:
# smart channel --add all type=rpm-md \ baseurl=http://<server_ip>/wandboard-quad/rpm/all # smart channel --add wandboard_quad type=rpm-md \ baseurl=http://<server_ip>/wandboard-quad/rpm/wandboard_quad # smart channel --add cortexa9hf_vfp_neon type=rpm-md \ baseurl=http://<server_ip>/wandboard- quad/rpm/cortexa9hf_vfp_neon
- Once the setup is ready, we will be able to query and update packages from the target's root filesystem with the following:
# smart update # smart query <package_name> # smart install <package_name>
To make this change persistent in the target's root filesystem, we can configure the package feeds at compilation time by using the PACKAGE_FEED_URIS
variable in conf/local.conf
as follows:
PACKAGE_FEED_URIS = "http://<server_ip>/wandboard-quad"
See also
- More information and a user manual for the smart utility can be found at https://labix.org/smart/