Mind Chasers Inc.
Mind Chasers Inc.

Use DNF Package Manager on a Yocto Linux Development System

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

advertisement

Overview

We develop and test with the Yocto / Poky master branch and use DNF (Dandified YUM) 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 kernel (e.g., 5.0) and our own Poky Linux mainline recipe to build our kernel for our T1040RDB.

# uname -a
Linux t1040rdb-64b 5.0.0-yocto-standard #21 SMP Sat Mar 9 12:05:54 EST 2019 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 on our T1040RDB. There is also a dnf script under /usr/bin.

Note that we're currently working with the master branch for the 2.7 release.

# which dnf
/usr/bin/dnf
root@:~# ls -l /usr/bin/dnf
lrwxrwxrwx 1 root root 5 Mar  9 13:03 /usr/bin/dnf -> dnf-3
root@:~# file /usr/bin/dnf-3
/usr/bin/dnf-3: Python script, ASCII text executable
# python3 --version
Python 3.7.2

ls /usr/lib64/python3.7/site-packages/dnf
__init__.py  cli       crypto.py  exceptions.py  lock.py           package.py    query.py     sack.py         util.py
automatic    comps.py  db         goal.py        logging.py        persistor.py  repo.py      selector.py     yum
base.py      conf      dnssec.py  history.py     match_counter.py  plugin.py     repodict.py  subject.py
callback.py  const.py  drpm.py    i18n.py        module            pycomp.py     rpm          transaction.py

Next we set up the configuration on our target:

# more /etc/dnf/dnf.conf
[main]
debuglevel=10
installonly_limit=3
clean_requirements_on_remove=True

# mkdir /etc/yum.repos.d
# touch /etc/yum.repos.d/oe-packages.repo
oe-packages.repo
[oe-packages]
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"
local.conf
PACKAGE_CLASSES ?= "package_rpm"

A manifest file, which lists all installed packages, can be found under our deploy folder

$ more tmp-glibc/deploy/images/t1040rdb-64b/custom-image-t1040rdb-64b.manifest
acl ppc64e5500 2.2.52
acl-dbg ppc64e5500 2.2.52
acl-dev ppc64e5500 2.2.52
attr ppc64e5500 2.4.47
...

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
/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/552855dd211e34289703df7764ae2932b79735e3f8f132c260ff19e12947642a-primary.xml.gz HTTP/1.1" 200 -
"GET /repodata/492d4c19fb07b304d8c8d04340a670fe3b54329e1d3ca14973cfe8602527e9ff-filelists.xml.gz HTTP/1.1" 200 -

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

# tree /var/cache/dnf
/var/cache/dnf
|-- expired_repos.json
|-- oe-packages-1037f2b60ad85686
|   `-- repodata
|       |-- 492d4c19fb07b304d8c8d04340a670fe3b54329e1d3ca14973cfe8602527e9ff-filelists.xml.gz
|       |-- 552855dd211e34289703df7764ae2932b79735e3f8f132c260ff19e12947642a-primary.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.7.2
Release      : r0
....

Install a new package

Let's install bison:

# bison
-sh: bison: command not found

# dnf install bison
timer: config: 10 ms
DNF version: 4.1.0
...
Installed:
  bison-3.0.4-r0.ppc64e5500                                                                                                          

Complete!
Cleaning up.
/var/cache/dnf/oe-packages-1037f2b60ad85686/packages/bison-3.0.4-r0.ppc64e5500.rpm removed

# bison --version
bison (GNU Bison) 3.0.4

This certainly makes working with an embedded system like the T1040RDB a lot easier!

Didn't find an answer to your question? Post your issue below or in our new FORUM, and we'll try our best to help you find a solution.

And please note that we update our site daily with new content related to our open source approach to network security and system design. If you would like to be notified about these changes, then please follow us on Twitter and join our mailing list.

Related articles on this site:

share
subscribe to mailing list:

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

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

your email address will be kept private

to upload an image

previous month
next month
Su
Mo
Tu
Wd
Th
Fr
Sa
loading