Mind Chasers Inc.

Use DNF Package Manager on a Yocto-built Development System

We show an example of the use of DNF package manager along with supporting notes with our Yocto-built t1040rdb development board.


We're developing with the Yocto / Poky master branch and have switched over to DNF for runtime package management. Provided below is an example of the use of DNF with our NXP t1040rdb development board along with various notes that are intended to support the existing Yocto documentation. Note that we use the Linux mainline repository and our own Poky Linux mainline recipe to build our kernel for the t1040rdb.

# uname -a
Linux t1040rdb-64b 4.14.0-yocto-standard #4 SMP Tue Dec 19 12:03:15 EST 2017 ppc64 ppc64 ppc64 GNU/Linux

This article assumes the reader is somewhat familiar with both the DNF & Yocto documentation and can refer to these resources for further information.

Target Configuration

DNF is a python app installed under our site-packages directory. There is also a dnf script under /usr/bin.

# which dnf
# ls -l /usr/bin/dnf
lrwxrwxrwx 1 root root 5 Dec 17 22:46 /usr/bin/dnf -> dnf-3
# file /usr/bin/dnf-3
/usr/bin/dnf-3: Python script, ASCII text executable
# ls /usr/lib64/python3.5/site-packages/dnf
__init__.py  cli       crypto.py      history.py  match_counter.py  pycomp.py    rpm          transaction.py
automatic    comps.py  drpm.py        i18n.py     package.py        query.py     sack.py      util.py
base.py      conf      exceptions.py  lock.py     persistor.py      repo.py      selector.py  yum
callback.py  const.py  goal.py        logging.py  plugin.py         repodict.py  subject.py

Next we set up the configuration on the target:

# more /etc/dnf/dnf.conf

# mkdir /etc/yum.repos.d
# touch /etc/yum.repos.d/oe-packages.repo
baseurl=http://<build machine>
Note that we use the same Linux host PC as our build machine and http server for package management.

Build Machine Configuration

Below are snippets of our build machine configuration to support runtime package management along with other notes. This closely follows the previously referenced Yocto documentation

image recipe
IMAGE_FEATURES += "package-management"
PACKAGE_CLASSES ?= "package_rpm"

A .manifest file, which lists all installed packages, can be found in our image's work directory under deploy-<image name>-image-complete.

rpm's can be found under each working directory in deploy-rpms regardless of whether they are installed in the rootfs as part of the image.

We run an HTTP server using python's http.server from our deploy/rpm directory. Make sure to run bitbake package-index to create the repodata directory under deploy/rpm

$ cd /<build_dir>/tmp-glibc/deploy/rpm

$ sudo python3 -m http.server --bind <ip address> 80
Serving HTTP on <ip address> port 80 ...

Basic usage on target

# tree /var/cache/dnf
|-- expired_repos.json
|-- oe-repo-8ab9e3847eb1e406
|   `-- repodata
`-- tempfiles.json
# dnf makecache
timer: config: 30 ms
DNF version: 2.6.3
Metadata cache created.
Cleaning up.

Refer back to the build machine to see which files were fetched from the http server:

"GET /repodata/repomd.xml HTTP/1.1" 200 -
"GET /repodata/afe97716a59c8d8b6011e70f8fc5791cd1c30e2750595ca1f43a5e74bbbe81fe-primary.xml.gz HTTP/1.1" 200 -
"GET /repodata/f64b0e6040a96af9373671f95098a656db8ad27ecb084b708d18c90353209192-filelists.xml.gz HTTP/1.1" 200 -

Examine how /var/cache/dnf has changed after making the cache:

# tree /var/cache/dnf
|-- expired_repos.json
|-- oe-packages-629a55811292ca3d
|   `-- repodata
|       |-- afe97716a59c8d8b6011e70f8fc5791cd1c30e2750595ca1f43a5e74bbbe81fe-primary.xml.gz
|       |-- f64b0e6040a96af9373671f95098a656db8ad27ecb084b708d18c90353209192-filelists.xml.gz
|       `-- repomd.xml
|-- oe-packages-filenames.solvx
|-- oe-packages.solv
|-- oe-repo-8ab9e3847eb1e406
|   `-- repodata
`-- tempfiles.json

Let's see which python3 packages are installed on our target. Keep in mind that we are including debug information due to our debuglevel setting in dnf.conf.

# dnf info python3-* | more

Installed Packages
Name         : python3-2to3
Version      : 3.5.2
Release      : r1.0

Install a new package

Let's install bison:

# bison
-sh: bison: command not found

# dnf install bison
timer: config: 25 ms
DNF version: 2.6.3
  bison.ppce500v2 3.0.4-r0                                                                                                            

Cleaning up.
/var/cache/dnf/oe-packages-629a55811292ca3d/packages/bison-3.0.4-r0.ppce500v2.rpm removed

# bison --version
bison (GNU Bison) 3.0.4

We'll continue to update this article throughout the year...


Please help us improve this article by adding your comment or question:

For enhanced features and capabilities, please authenticate using a popular third party

your email address will be kept private
previous month
next month