Private Island Networks Inc.

Use DNF Package Manager on a Yocto Linux LS1046A Freeway Development System

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


We develop and test with Yocto and use DNF (Dandified YUM) for runtime package management. Provided below is an example of the use of DNF with our NXP LS1046A Freeway Board along with various notes that are intended to support the existing Yocto documentation. You can read more about our Yocto image for the FRWY board here.

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 FRWY-LS1046A. There is also a dnf script under /usr/bin.

Note that we're currently working with the Yocto kirkstone LTS branch.

# uname -a

Linux ls1046afrwy 5.10.52+ga11753a89ec6 #1 SMP PREEMPT Wed Sep 8 10:41:11 UTC 2021 aarch64 GNU/Linux
# which 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.10.12

# ls /usr/lib/python3.10/site-packages/dnf        cli           
automatic           db                       conf              yum               module             rpm      

Next we set up the configuration on our target:

# more /etc/dnf/dnf.conf

# mkdir /etc/yum.repos.d
# touch /etc/yum.repos.d/oe-packages.repo
Edit oe-packages.repo
baseurl=http://<build machine IP address>
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 under our deploy folder

$ more tmp/deploy/images/ls1046afrwy/core-image-minimal-ls1046afrwy.manifest
base-files ls1046afrwy 3.0.14
base-passwd aarch64 3.5.29
bash aarch64 5.1.16
busybox aarch64 1.35.0
busybox-hwclock aarch64 1.35.0
busybox-syslog aarch64 1.35.0

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

# ls /var/cache/dnf/
expired_repos.json        oe-repo-032079af171dd1fe  tempfiles.json
# dnf makecache
timer: config: 3 ms
DNF version: 4.11.1
Command: dnf makecache 
Installroot: /
Releasever: kirkstone
cachedir: /var/cache/dnf
Base command: makecache
Extra commands: ['makecache']
Repository 'oe-packages' is missing name in configuration, using id.
Making cache files for all metadata files.
oe-packages: has expired and will be refreshed.
repo: downloading from remote: oe-packages
oe-packages                                                                                                                                          13 MB/s | 1.7 MB     00:00    
oe-packages: using metadata from Tue Aug 15 16:10:37 2023.
Last metadata expiration check: 0:00:01 ago on Fri Mar  9 12:46:42 2018.
os-release file not found
User-Agent: falling back to 'libdnf': missing NAME or VERSION_ID
timer: sack setup: 1321 ms
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/aa8485f90691f561b18f52c8a6abadcdfefc053c63d87342cc426be001c30463-primary.xml.gz HTTP/1.1" 200 -
"GET /repodata/8848f636f811628ae28527e906f38350a2f00a51c1576c03fffffbaf91358190-filelists.xml.gz HTTP/1.1" 200 -

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

ls /var/cache/dnf/
expired_repos.json            oe-packages-62f674e92beba674  oe-packages.solv              tempfiles.json
oe-packages-3adc71bdd5ad4720  oe-packages-filenames.solvx   oe-repo-032079af171dd1fe

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-* 
installroot: /
Releasever: kirkstone
cachedir: /var/cache/dnf
Base command: info
Extra commands: ['info', 'python3-*']
Repository 'oe-packages' is missing name in configuration, using id.
os-release file not found
User-Agent: falling back to 'libdnf': missing NAME or VERSION_ID
repo: using cache for: oe-packages
oe-packages: using metadata from Tue Aug 15 16:10:37 2023.
Last metadata expiration check: 0:01:32 ago on Fri Mar  9 12:46:42 2018.
timer: sack setup: 260 ms
Installed Packages
Name         : python3-audio
Version      : 3.10.12
Release      : r0
Architecture : aarch64
Size         : 167 k
Source       : python3-3.10.12-r0.src.rpm
Repository   : @System
From repo    : oe-repo

As can be seen above that there is some more configuration work to be done.

Install a new package

Let's install cmake:

# cmake
-sh: cmake: command not found

Go back to our build server and bitbake cmake.

# dnf install cmake
timer: config: 3 ms
DNF version: 4.11.1
Command: dnf install cmake 
Installroot: /
Releasever: kirkstone
cachedir: /var/cache/dnf
Base command: install
Extra commands: ['install', 'cmake']
Repository 'oe-packages' is missing name in configuration, using id.
os-release file not found
User-Agent: falling back to 'libdnf': missing NAME or VERSION_ID
repo: using cache for: oe-packages
oe-packages: using metadata from Tue Aug 15 16:42:57 2023.
Last metadata expiration check: 0:00:19 ago on Fri Mar  9 12:56:58 2018.
timer: sack setup: 60 ms
--> Starting dependency resolution
---> Package cmake.aarch64 3.22.3-r0 will be installed
---> Package libacl1.aarch64 2.3.1-r0 will be installed
---> Package libarchive.aarch64 3.6.2-r0 will be installed
---> Package liblzo2-2.aarch64 2.10-r0 will be installed
--> Finished dependency resolution
timer: depsolve: 51 ms
Dependencies resolved.
 Package                                     Architecture                             Version                                    Repository                                    Size
 cmake                                       aarch64                                  3.22.3-r0                                  oe-packages                                  5.9 M
Installing dependencies:
 libacl1                                     aarch64                                  2.3.1-r0                                   oe-packages                                   21 k
 libarchive                                  aarch64                                  3.6.2-r0                                   oe-packages                                  318 k
 liblzo2-2                                   aarch64                                  2.10-r0                                    oe-packages                                   47 k

Transaction Summary
Install  4 Packages

Total download size: 6.2 M
Installed size: 29 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): libacl1-2.3.1-r0.aarch64.rpm                                                                                                                 211 kB/s |  21 kB     00:00    
(2/4): liblzo2-2-2.10-r0.aarch64.rpm                                                                                                                3.6 MB/s |  47 kB     00:00    
(3/4): libarchive-3.6.2-r0.aarch64.rpm                                                                                                              2.2 MB/s | 318 kB     00:00    
(4/4): cmake-3.22.3-r0.aarch64.rpm                                                                                                                   13 MB/s | 5.9 MB     00:00    
Total                                                                                                                                                14 MB/s | 6.2 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
timer: transaction test: 297 ms
Running transaction
RPM transaction start.
  Preparing        :                                                                                                                                                            1/1 
Installed: liblzo2-2-2.10-r0.aarch64
  Installing       : liblzo2-2-2.10-r0.aarch64                                                                                                                                  1/4 
  Running scriptlet: liblzo2-2-2.10-r0.aarch64                                                                                                                                  1/4 
%post(liblzo2-2-2.10-r0.aarch64): scriptlet start
%post(liblzo2-2-2.10-r0.aarch64): execv(/bin/sh) pid 521
+ set -e
+ '[' x = x ']'
+ '[' -x /sbin/ldconfig ']'
+ /sbin/ldconfig
%post(liblzo2-2-2.10-r0.aarch64): waitpid(521) rc 521 status 0

Installed: libacl1-2.3.1-r0.aarch64
  Installing       : libacl1-2.3.1-r0.aarch64                                                                                                                                   2/4 
  Running scriptlet: libacl1-2.3.1-r0.aarch64                                                                                                                                   2/4 
%post(libacl1-2.3.1-r0.aarch64): scriptlet start
%post(libacl1-2.3.1-r0.aarch64): execv(/bin/sh) pid 523
+ set -e
+ '[' x = x ']'
+ '[' -x /sbin/ldconfig ']'
+ /sbin/ldconfig
%post(libacl1-2.3.1-r0.aarch64): waitpid(523) rc 523 status 0

Installed: libarchive-3.6.2-r0.aarch64
  Installing       : libarchive-3.6.2-r0.aarch64                                                                                                                                3/4 
  Running scriptlet: libarchive-3.6.2-r0.aarch64                                                                                                                                3/4 
%post(libarchive-3.6.2-r0.aarch64): scriptlet start
%post(libarchive-3.6.2-r0.aarch64): execv(/bin/sh) pid 525
+ set -e
+ '[' x = x ']'
+ '[' -x /sbin/ldconfig ']'
+ /sbin/ldconfig
%post(libarchive-3.6.2-r0.aarch64): waitpid(525) rc 525 status 0

Installed: cmake-3.22.3-r0.aarch64
  Installing       : cmake-3.22.3-r0.aarch64                                                                                                                                    4/4 
RPM transaction over.
  Verifying        : cmake-3.22.3-r0.aarch64                                                                                                                                    1/4 
  Verifying        : libacl1-2.3.1-r0.aarch64                                                                                                                                   2/4 
  Verifying        : libarchive-3.6.2-r0.aarch64                                                                                                                                3/4 
  Verifying        : liblzo2-2-2.10-r0.aarch64                                                                                                                                  4/4 
timer: verify transaction: 194 ms
timer: transaction: 5398 ms
Installed: cmake-3.22.3-r0.aarch64
Installed: libacl1-2.3.1-r0.aarch64
Installed: libarchive-3.6.2-r0.aarch64
Installed: liblzo2-2-2.10-r0.aarch64

  cmake-3.22.3-r0.aarch64                    libacl1-2.3.1-r0.aarch64                    libarchive-3.6.2-r0.aarch64                    liblzo2-2-2.10-r0.aarch64                   

Cleaning up.
/var/cache/dnf/oe-packages-62f674e92beba674/packages/libarchive-3.6.2-r0.aarch64.rpm removed
/var/cache/dnf/oe-packages-62f674e92beba674/packages/cmake-3.22.3-r0.aarch64.rpm removed
/var/cache/dnf/oe-packages-62f674e92beba674/packages/liblzo2-2-2.10-r0.aarch64.rpm removed
/var/cache/dnf/oe-packages-62f674e92beba674/packages/libacl1-2.3.1-r0.aarch64.rpm removed
root@ls1046afrwy:~# cmake

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>
  cmake [options] -S <path-to-source> -B <path-to-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

This certainly makes working with an embedded system like the NXP LS1046A Freeway Board 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 join our mailing list.

subscribe to mailing list:

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

your email address will be kept private
authenticate with a 3rd party for enhanced features, such as image upload
previous month
next month