Raspberry Pi and a package manager

The basic building block of the Yocto Project is the generation of packages; therefore, it is possible to include a package manager to our Yocto distribution (similar to a Linux distribution, for example). Indeed, after the generation of the image (refer Chapter 2), it contains no package manager, so this means that our image is not updateable (similar to a firmware, for example).

The inclusion of a package manager in our distribution is done through this variable, if adding it to conf/local.conf:

EXTRA_IMAGE_FEATURES += "package-management" 

If adding to a recipe file (such as rpi-basic-image.bb), use this instead:

IMAGE_FEATURES += "package-management" 

With this addition, we have now an image with a package manager that is more flexible, updateable, and more industrial. Here's how to install a package with the opkg package manager:

$ opkg install package_name.ipk 

Package format availablility

Bitbake (the task scheduler) supports the following package formats:

RPM: Originally used by Red Hat due to its name, Red Hat Package Manager, it is now used by other distributions (openSUSE, for example).

DEB: The Debian package format is used by Debian and derivate distributions such as Ubuntu.

IPK: This stands for Itsy Package Management System (originally of the handhelds.org project). It is a lightweight package management system designed for embedded systems (such as the Gumstix platform: http://gumstix.org/add-software-packages.html ). OpenEmbedded-Core, and as a consequence Poky, uses the opkg package manager to support the IPK format.

Note

If you are an Android enthusiast, you can make an analogy with the APK package format.

Choosing a package format

Support for the formats is provided using a set of classes (package_rpm, package_deb, and package_ipk). The choice of the package formats depends very much on project needs. Factors to consider include the following:

  • Memory footprint
  • Resource usage,
  • Speed of installation

Note

By default, Poky uses the RPM (Red Hat Package Manager) package format.

The selection of package format is done through the PACKAGE_CLASSES variable in the conf/local.conf file.

Type this to include the RPM package format:

PACKAGE_CLASSES ?= "package_rpm" 

Type this to include the DEB package format:

PACKAGE_CLASSES ?= "package_deb" 

Type this to include the IPK package format:

PACKAGE_CLASSES ?= "package_ipk" 

Note

It is possible to specify several package formats but, to build images, Bitbake searches based on the first package format in the PACKAGE_CLASSES variable: PACKAGE_CLASSES ?= "package_rpm package_deb package_ipk"

Installing and updating a package on the target

Now that we have covered package formats, we will see how to integrate them with the Raspberry Pi.

RPM packages

With RPM packages, it is possible to use (after copying it to the target) RPM or SMART utilities to install packages on the Raspberry Pi.

Installing manually

To manually install RPM packages, use one of these commands:

$ rpm -ivh package_name.rpm
$ smart install package_name.rpm

Installing automatically

During the development and debugging phases, it may be worthwhile for the developer to update the packages (binaries) on the target (Raspberry Pi) without having to handle many Linux commands.

The first step consists of creating the package index in our repository (in order to use package feeds):

$ source oe-init-build-env rpi-build
$ bitbake package-index

After that, we can install a web server (such as lighttpd):

$ sudo apt-get install lighttpd

By default, the document root specified in the /etc/lighttpd/lighttpd.conf configuration file is /var/www/:

$ tree /var/www/
/var/www/
html
amod.png
formulaire.html
index.html
logo.png
play_48.png
index.lighttpd.html
1 directory, 6 files

So, we only need a symlink to our package feed:

$ mkdir /var/www/rpi-deploy
$ ln -s rpi-build/tmp/deploy/rpm /var/www/rpi-deploy/rpm

At this point, you need to restart the lighttpd server:

$ sudo /etc/init.d/lighttpd restart

On the Raspberry Pi, we need to inform smart of every package database we want to use. For example, for the all directory in rpi-deploy/rpm, we will need to issue this command:

$ smart channel --add all type=rpm-md baseurl=http://<server-ip> /rpi-deploy/rpm/all

Now that our environment is in place, we can query and update packages from the Raspberry Pi's root filesystem with the following commands:

$ smart update
$ smart query <package_name>
$ smart install <package_name>
$ smart query -installed

Here's an example of removing a package from the Raspberry Pi (the Monkey web server):

$ smart remove monkey
Updating cache..  ################################################################################################### [100%]
Computing transaction...
Removing packages (1):
monkey-1.5.4-r0@armv6-vfp
479.4kB will be freed. Confirm changes? (Y/n): Y
Committing transaction...
Preparing...################################################################################################### [  0%]
Stopping Monkey HTTP Server: stopped /usr/bin/monkey (pid 1448)
monkey
Output from monkey:(  0%)
warning: /etc/monkey/sites/default saved as /etc/monkey/sites/default.rpmsave 
warning: /etc/monkey/plugins/logger/logger.conf saved as /etc/monkey/plugins/logger/logger.conf.rpmsave
warning: /etc/monkey/plugins.load saved as /etc/monkey/plugins.load.rpmsave
1:Removing monkey ################################################################################################### [100%]
Removing any system startup links for monkey ...
/etc/rc0.d/K70monkey /etc/rc1.d/K70monkey /etc/rc2.d/S70monkey /etc/rc3.d/S70monkey /etc/rc4.d/S70monkey /etc/rc5.d/S70monkey /etc/rc6.d/K70monkey Saving cache...

Note

More information and a user manual for the smart utility can be found at https://labix.org/smart/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.42.70