AN-DIVELK-001: Package Management with Yocto

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
Diva-am335x-overview.png Applies to Diva
Yocto-logo.png Applies to Yocto

History

Version Date DIVELK version Notes
1.0.0 July 2017 3.0.0 First release

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 DIVELK packaging system is Open PacKaGe management, OPKG [1], which can be used with opkg command line utility to install a package, with all its dependencies, from a remote repository.

To use opkg, 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 DIVELK images.

Building packages and feeds

After bootstrapping the DIVELK 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/ipk

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/ipk/* user@myyocto.example.com:/var/www/yocto

Installing packages on target

To use opkg at runtime first of all you need configure it with the address of your server and the kind of packages it provides.

Usually a standard Yocto build provide three kind of packages:

  • architecture dependent packages (all)
  • CPU architecture dependent packages (cortexa8hf-vfp-neon, for DIVELK)
  • board dependent packages (e.g. the one that depends on the specific kernel, those packages are named diva for DIVELK)

opkg configuration reside in /etc/opkg. User can run the following commands to configure all the three packages type above:

URL=http://yocto.example.com
FEEDS="all cortexa8hf-vfp-neon diva"

rm -f /etc/opkg/divelk-feeds.conf
for feed in $FEEDS; do
  echo "feed:$feed"
  echo "src/gz $feed $URL/$feed" >> /etc/opkg/divelk-feeds.conf

done

Where http://yocto.example.com is the URL of the webserver.


200px-Emblem-important.svg.png DAVE already provides pre-build packages (from world build) for DIVELK. The URL of the server is https://yocto.dave.eu/divelk-x.y.z, where x.y.z is the DIVELK release. The latest release is always available at https://yocto.dave.eu/divelk-latest 200px-Emblem-important.svg.png

After you change one of the opkg configuration files and/or update packages feed on server, you need to update opkg database with:

opkg update

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

opkg install PACKAGE_NAME

E.g. opkg install emacs


The package dependencies will be resolved automatically.

Other useful OPKG commands

Apart from Yocto Project, OPKG is used on OpenWRT[2] project too, thus documentation about its usage can be found into their documentation pages

In the next section we'll show some example of OPKG usage.

List installed packages

User can see the list of installed packages with opkg list-installed

List available packages

To list the available packages into the current configured channels use opkg list

root@diva:~# opkg list
a52dec - 0.7.4-r4 - ATSC A/52 surround sound stream decoder  ATSC A/52 surround sound stream
 decoder.
a52dec-doc - 0.7.4-r4 - ATSC A/52 surround sound stream decoder  ATSC A/52 surround sound stream
 decoder.
accel-ppp - 1.7.3+git-r1 - ACCEL-PPP is a high performance VPN server application for linux  ACCEL-
 PPP is a high performance VPN server application for linux.
accel-ppp-dbg - 1.7.3+git-r1 - ACCEL-PPP is a high performance VPN server application for linux -
 Debugging files  ACCEL-PPP is a high performance VPN server application
 for linux.  This   package contains ELF symbols and related sources for
[...]

Please note that Description field may contains line break and thus this may break grepping into its output.

Search for files

Files belonging to a package can be found with opkg files <pkg>, e.g.:

Packages providing a given file can be found with opkg search <file>, e.g.:

References