AN-XELK-003: Package Management with Yocto

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
Axel-04.png Applies to Axel Ultra
Axel-02.png Applies to AXEL ESATTA
Axel-lite 02.png Applies to Axel Lite

History

Version Date XELK version Notes
1.0.0 October 2016 2.2.0 First release
1.0.1 November 2016 2.2.0 Add SMART commands examples

Introduction

This application note details:

  • how to build packages and packages feeds with Yocto
  • how to deploy your own package manager server
  • how to use a package manager with a Yocto based root file system

Yocto Package Manager

The default XELK packaging system is RPM [1], which can be used with SMART [2][3][4] to install a package, with all its dependencies, from a remote repository.

To use smart, you need to be sure that the image is build with runtime package management support:

IMAGE_FEATURES += " package-management"

This is already enabled in default XELK images.

Building packages and feeds

After bootstrapping the XELK Yocto environment and build the packages you want to publish, you can create the package feeds with:

bitbake package-index

The files to deploy on server are inside $BUILD_DIR/tmp/deploy/rpm

User can also build all the recipe inside the project layers with:

bitbake -k world

Please note that, due the fact that some packages may fail to build, the -k switch is needed to tell bitbake continue even in case of failure.

It also require a lot of disk space (~60-80 GiB including work dir and intermediate files) and a long build time (both to download and compile the various packages)

Configuring the webserver

Here we give an example in how to configure the Apache webserver on a Ubuntu 14.04 LTS distribution to serve Yocto packages. We assume that you already configure the networking properly (e.g. setup public or local DNS) and that you already install Apache with its dependencies.

  • Create a new virtualhost by entering the following text inside, for example, /etc/apache2/sites-available/myyocto
<VirtualHost *:80>
	ServerName myyocto.example.com
	ServerAdmin admin@example.com

	DocumentRoot /var/www/yocto
	<Directory /var/www/yocto>
		Options FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
		Options +Indexes
	</Directory>

	ErrorLog ${APACHE_LOG_DIR}/yocto-error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog ${APACHE_LOG_DIR}/yocto-access.log combined
</VirtualHost>
  • enable the virtualhost
sudo a2ensite yocto
  • apply the changes to Apache
sudo service apache2 restart
  • copy the feeds and packages from your build environment into the webserver directory, e.g. via ftp or scp
scp -r $BUILD_DIR/tmp/deploy/rpm/* user@myyocto.example.com:/var/www/yocto

Installing packages on target

To use smart at runtime first of all you need to enable a channel, which commonly is a remote webserver that provide packages feed and the binary packages itself, like the one we configured in the previous section.

On the target just run the following command:

smart channel --add cortexa9hf_vfp_neon type=rpm-md baseurl=http://myyocto.example.com/cortexa9hf_vfp_neon

Where:

You can also add a local directory, for example mounted via NFS directly on target, with the following command:

smart channel --add local type=rpm-dir name=localrpms manual=true priority=1 path=/opt/rpms -y


After you configure the channel and/or update packages feed on server, you need to update smart database:

smart update

Finally you can install the packages on the target with the following command:

smart install PACKAGE_NAME

E.g. smart install emacs


The package dependencies will be resolved automatically.

Other useful SMART commands

A brief guide to SMART command line interface is here. In the next section we'll show some example of SMART usage.

Gathering statistics

To view some information on repositories use smart stats

root@axel:~# smart stats
Loading cache...
Updating cache...               ######################################## [100%]

Installed Packages: 331
Total Packages: 11757
Total Provides: 27765
Total Requires: 4798
Total Upgrades: 11704
Total Conflicts: 73

List installed packages

User can see the list of installed packages with smart query --installed

root@axel:~# smart query --installed
Loading cache...
Updating cache...               ######################################## [100%]

alsa-conf-1.0.28-r0@cortexa9hf_vfp_neon
alsa-conf-base-1.0.28-r0@cortexa9hf_vfp_neon
alsa-state-0.2.0-r5@cortexa9hf_vfp_neon
alsa-states-0.2.0-r5@cortexa9hf_vfp_neon
alsa-utils-alsactl-1.0.28-r1@cortexa9hf_vfp_neon
alsa-utils-alsamixer-1.0.28-r1@cortexa9hf_vfp_neon
apm-3.2.2+14-r2@cortexa9hf_vfp_neon
apmd-3.2.2+14-r2@cortexa9hf_vfp_neon
avahi-daemon-0.6.31-r11.1@cortexa9hf_vfp_neon
[...]

List available packages

To list the available packages into the current configured channels use smart query

Please note that this will show all package, it's usually more useful to give it a pattern, e.g.:

root@axel:~# smart query '*httpd*'
Loading cache...
Updating cache...               ######################################## [100%]

libmicrohttpd-bin-0.9.34-r0@cortexa9hf_vfp_neon
libmicrohttpd-dbg-0.9.34-r0@cortexa9hf_vfp_neon
libmicrohttpd-dev-0.9.34-r0@cortexa9hf_vfp_neon
libmicrohttpd-doc-0.9.34-r0@cortexa9hf_vfp_neon
libmicrohttpd10-0.9.34-r0@cortexa9hf_vfp_neon
lighttpd-1.4.35-r1@cortexa9hf_vfp_neon
lighttpd-1.4.35-r1@cortexa9hf_vfp_neon
lighttpd-dbg-1.4.35-r1@cortexa9hf_vfp_neon
lighttpd-dev-1.4.35-r1@cortexa9hf_vfp_neon
lighttpd-doc-1.4.35-r1@cortexa9hf_vfp_neon
lighttpd-module-access-1.4.35-r1@cortexa9hf_vfp_neon
[...]

References