DESK-XZ7-L-AN-0006: Package Management with Yocto and DNF

From DAVE Developer's Wiki
Revision as of 16:10, 2 February 2024 by U0028 (talk | contribs)

Jump to: navigation, search
Info Box


200px-Emblem-important.svg.png

This application note has been validated using the kit version in the History table.

History[edit | edit source]

Date Development Kit version
Feb 2024 DESK-XZ7-L 1.0.1

Introduction[edit | edit source]

Since Pyro (2.3) Yocto release, DNF is the default package manager for installing packages in the DUT (target machine).

The Dandified Packaging Tool (DNF) performs runtime package management of RPM packages.

This application note details how to use DNF for installing packages with a Yocto based root file system

DNF[edit | edit source]

DNF is a software package manager that installs, updates, and removes packages on RPM-based Linux distributions. It automatically computes dependencies and determines the actions required to install packages. DNF also makes it easier to maintain groups of machines, eliminating the need to manually update each one using rpm. Introduced in Fedora 18, it has been the default package manager since Fedora 22.

More information can be found on Fedora's wiki DNF page

Pre-configured repositories[edit | edit source]

It is possible to add and configure DNF repositories using additional .repo files: it is recommended to define individual repositories in new or existing .repo files in the /etc/yum.repos.d/ directory.

More information about configuring DNF repositories can be found in the nConfiguring DNF and DNF_Repositories Fedora's page.

Here below is the original configuration defined by Petalinux root file system for the package repositories:

root@bora:~# ls -la /etc/yum.repos.d
total 24
drwxr-xr-x  2 root root 4096 Jan 30 15:15 .
drwxr-xr-x 52 root root 4096 Jan 30 15:18 ..
-rw-r--r--  1 root root 4606 Mar  9  2018 oe-remote-repo-sswreleases-rel-v2021.2-generic-rpm.repo
-rw-r--r--  1 root root 5086 Mar  9  2018 oe-remote-repo-sswreleases-rel-v2021.2-generic-updates-rpm.repo
root@bora:~# 

Installing packages on target[edit | edit source]

We assume that the network interface has been already configured for Internet access. In any case, a simple network configuration can be done according to the How to configure the network interfaces wiki page:

root@bora:~# echo "nameserver 192.168.0.1" > /etc/resolv.conf
root@bora:~# cat /etc/network/interfaces
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback
#
auto eth0
iface eth0 inet static
        address 192.168.0.165
        netmask 255.255.255.0
        gateway 192.168.0.254
root@bora:~#
root@bora:~#

Then, for installing a package, it is enough to invoke dnf with the install parameter, for example:

root@bora:~# dnf install lighttpd
Last metadata expiration check: 0:00:16 ago on Tue Mar 13 12:15:23 2018.
Dependencies resolved.
=============================================================================================================================================================================================================================================================================
 Package                                                      Architecture                                        Version                                       Repository                                                                                              Size
=============================================================================================================================================================================================================================================================================
Installing:
 lighttpd                                                     cortexa9t2hf_neon                                   1.4.55-r0.0                                   oe-remote-repo-sswreleases-rel-v2021.2-generic-rpm-cortexa9t2hf_neon                                   120 k
Installing dependencies:
 lighttpd-module-dirlisting                                   cortexa9t2hf_neon                                   1.4.55-r0.0                                   oe-remote-repo-sswreleases-rel-v2021.2-generic-rpm-cortexa9t2hf_neon                                    15 k
 lighttpd-module-indexfile                                    cortexa9t2hf_neon                                   1.4.55-r0.0                                   oe-remote-repo-sswreleases-rel-v2021.2-generic-rpm-cortexa9t2hf_neon                                   9.3 k
 lighttpd-module-staticfile                                   cortexa9t2hf_neon                                   1.4.55-r0.0                                   oe-remote-repo-sswreleases-rel-v2021.2-generic-rpm-cortexa9t2hf_neon                                   9.0 k
Installing weak dependencies:
 lighttpd-lic                                                 cortexa9t2hf_neon                                   1.4.55-r0.0                                   oe-remote-repo-sswreleases-rel-v2021.2-generic-rpm-cortexa9t2hf_neon                                   7.6 k
 lighttpd-module-access                                       cortexa9t2hf_neon                                   1.4.55-r0.0                                   oe-remote-repo-sswreleases-rel-v2021.2-generic-rpm-cortexa9t2hf_neon                                   9.0 k
 lighttpd-module-accesslog                                    cortexa9t2hf_neon                                   1.4.55-r0.0                                   oe-remote-repo-sswreleases-rel-v2021.2-generic-rpm-cortexa9t2hf_neon                                    14 k

Transaction Summary
=============================================================================================================================================================================================================================================================================
Install  7 Packages

Total download size: 184 k
Installed size: 270 k
Is this ok [y/N]: y
Downloading Packages:
(1/7): lighttpd-module-access-1.4.55-r0.0.cortexa9t2hf_neon.rpm                                                                                                                                                                               58 kB/s | 9.0 kB     00:00
(2/7): lighttpd-lic-1.4.55-r0.0.cortexa9t2hf_neon.rpm                                                                                                                                                                                         31 kB/s | 7.6 kB     00:00
(3/7): lighttpd-module-accesslog-1.4.55-r0.0.cortexa9t2hf_neon.rpm                                                                                                                                                                           101 kB/s |  14 kB     00:00
(4/7): lighttpd-1.4.55-r0.0.cortexa9t2hf_neon.rpm                                                                                                                                                                                            295 kB/s | 120 kB     00:00
(5/7): lighttpd-module-indexfile-1.4.55-r0.0.cortexa9t2hf_neon.rpm                                                                                                                                                                            84 kB/s | 9.3 kB     00:00
(6/7): lighttpd-module-dirlisting-1.4.55-r0.0.cortexa9t2hf_neon.rpm                                                                                                                                                                           63 kB/s |  15 kB     00:00
(7/7): lighttpd-module-staticfile-1.4.55-r0.0.cortexa9t2hf_neon.rpm                                                                                                                                                                           35 kB/s | 9.0 kB     00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                                                        271 kB/s | 184 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                                                     1/1
  Installing       : lighttpd-module-staticfile-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                            1/7
  Running scriptlet: lighttpd-module-staticfile-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                            1/7
%post(lighttpd-module-staticfile-1.4.55-r0.0.cortexa9t2hf_neon): scriptlet start
%post(lighttpd-module-staticfile-1.4.55-r0.0.cortexa9t2hf_neon): execv(/bin/sh) pid 417
+ set -e
+ '[' x = x ']'
+ '[' -x /sbin/ldconfig ']'
+ /sbin/ldconfig
%post(lighttpd-module-staticfile-1.4.55-r0.0.cortexa9t2hf_neon): waitpid(417) rc 417 status 0

  Installing       : lighttpd-module-indexfile-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                             2/7
  Running scriptlet: lighttpd-module-indexfile-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                             2/7
%post(lighttpd-module-indexfile-1.4.55-r0.0.cortexa9t2hf_neon): scriptlet start
%post(lighttpd-module-indexfile-1.4.55-r0.0.cortexa9t2hf_neon): execv(/bin/sh) pid 419
+ set -e
+ '[' x = x ']'
+ '[' -x /sbin/ldconfig ']'
+ /sbin/ldconfig
%post(lighttpd-module-indexfile-1.4.55-r0.0.cortexa9t2hf_neon): waitpid(419) rc 419 status 0

  Installing       : lighttpd-module-dirlisting-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                            3/7
  Running scriptlet: lighttpd-module-dirlisting-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                            3/7
%post(lighttpd-module-dirlisting-1.4.55-r0.0.cortexa9t2hf_neon): scriptlet start
%post(lighttpd-module-dirlisting-1.4.55-r0.0.cortexa9t2hf_neon): execv(/bin/sh) pid 421
+ set -e
+ '[' x = x ']'
+ '[' -x /sbin/ldconfig ']'
+ /sbin/ldconfig
%post(lighttpd-module-dirlisting-1.4.55-r0.0.cortexa9t2hf_neon): waitpid(421) rc 421 status 0

  Installing       : lighttpd-module-accesslog-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                             4/7
  Running scriptlet: lighttpd-module-accesslog-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                             4/7
%post(lighttpd-module-accesslog-1.4.55-r0.0.cortexa9t2hf_neon): scriptlet start
%post(lighttpd-module-accesslog-1.4.55-r0.0.cortexa9t2hf_neon): execv(/bin/sh) pid 423
+ set -e
+ '[' x = x ']'
+ '[' -x /sbin/ldconfig ']'
+ /sbin/ldconfig
%post(lighttpd-module-accesslog-1.4.55-r0.0.cortexa9t2hf_neon): waitpid(423) rc 423 status 0

  Installing       : lighttpd-module-access-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                                5/7
  Running scriptlet: lighttpd-module-access-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                                5/7
%post(lighttpd-module-access-1.4.55-r0.0.cortexa9t2hf_neon): scriptlet start
%post(lighttpd-module-access-1.4.55-r0.0.cortexa9t2hf_neon): execv(/bin/sh) pid 425
+ set -e
+ '[' x = x ']'
+ '[' -x /sbin/ldconfig ']'
+ /sbin/ldconfig
%post(lighttpd-module-access-1.4.55-r0.0.cortexa9t2hf_neon): waitpid(425) rc 425 status 0

  Installing       : lighttpd-lic-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                                          6/7
  Installing       : lighttpd-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                                              7/7
  Running scriptlet: lighttpd-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                                              7/7
%post(lighttpd-1.4.55-r0.0.cortexa9t2hf_neon): scriptlet start
%post(lighttpd-1.4.55-r0.0.cortexa9t2hf_neon): execv(/bin/sh) pid 427
+ set -e
+ true
+ type update-rc.d
+ '[' -n '' ']'
+ OPT=-s
+ update-rc.d -s lighttpd defaults 70
 Adding system startup for /etc/init.d/lighttpd.
Starting Lighttpd Web Server: lighttpd.
%post(lighttpd-1.4.55-r0.0.cortexa9t2hf_neon): waitpid(427) rc 427 status 0

  Verifying        : lighttpd-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                                              1/7
  Verifying        : lighttpd-lic-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                                          2/7
  Verifying        : lighttpd-module-access-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                                3/7
  Verifying        : lighttpd-module-accesslog-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                             4/7
  Verifying        : lighttpd-module-dirlisting-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                            5/7
  Verifying        : lighttpd-module-indexfile-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                             6/7
  Verifying        : lighttpd-module-staticfile-1.4.55-r0.0.cortexa9t2hf_neon                                                                                                                                                                                            7/7

Installed:
  lighttpd-1.4.55-r0.0.cortexa9t2hf_neon                             lighttpd-lic-1.4.55-r0.0.cortexa9t2hf_neon                        lighttpd-module-access-1.4.55-r0.0.cortexa9t2hf_neon               lighttpd-module-accesslog-1.4.55-r0.0.cortexa9t2hf_neon
  lighttpd-module-dirlisting-1.4.55-r0.0.cortexa9t2hf_neon           lighttpd-module-indexfile-1.4.55-r0.0.cortexa9t2hf_neon           lighttpd-module-staticfile-1.4.55-r0.0.cortexa9t2hf_neon

Complete!
root@bora:~#

Search for packages[edit | edit source]

To search for an available package in the current configured channels use dnf repoquery

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

root@bora:~# dnf repoquery *fb*
OE Remote Repo: sswreleases rel-v2021.2 generic rpm all                                                                                                                                                                                      2.0 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm any                                                                                                                                                                                      2.9 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm noarch                                                                                                                                                                                   1.2 MB/s | 139 kB     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm armv5hf_vfp                                                                                                                                                                              3.5 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm armv5thf_vfp                                                                                                                                                                             4.0 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm armv5ehf_vfp                                                                                                                                                                             3.7 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm armv5tehf_vfp                                                                                                                                                                            3.0 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm armv6hf_vfp                                                                                                                                                                              3.2 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm armv6thf_vfp                                                                                                                                                                             3.4 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm armv7ahf_vfp                                                                                                                                                                             3.6 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm armv7at2hf_vfp                                                                                                                                                                           1.9 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm armv7ahf_neon                                                                                                                                                                            3.2 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm armv7at2hf_neon                                                                                                                                                                          3.8 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm cortexa9hf_vfp                                                                                                                                                                           3.7 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm cortexa9hf_neon                                                                                                                                                                          107 kB/s | 8.0 kB     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm cortexa9t2hf_vfp                                                                                                                                                                         3.4 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm cortexa9t2hf_neon                                                                                                                                                                        9.3 MB/s | 3.5 MB     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm zynq                                                                                                                                                                                      37 kB/s | 4.6 kB     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm zynq_7z                                                                                                                                                                                   23 kB/s | 1.6 kB     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic rpm zynq_generic                                                                                                                                                                             1.2 MB/s | 141 kB     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm all                                                                                                                                                                              4.0 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm any                                                                                                                                                                              2.3 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm noarch                                                                                                                                                                           4.1 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm armv5hf_vfp                                                                                                                                                                      2.8 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm armv5thf_vfp                                                                                                                                                                     3.2 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm armv5ehf_vfp                                                                                                                                                                     3.7 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm armv5tehf_vfp                                                                                                                                                                    2.2 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm armv6hf_vfp                                                                                                                                                                      3.2 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm armv6thf_vfp                                                                                                                                                                     3.2 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm armv7ahf_vfp                                                                                                                                                                     3.5 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm armv7at2hf_vfp                                                                                                                                                                   3.8 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm armv7ahf_neon                                                                                                                                                                    2.9 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm armv7at2hf_neon                                                                                                                                                                  2.4 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm cortexa9hf_vfp                                                                                                                                                                   810  B/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm cortexa9hf_neon                                                                                                                                                                  3.1 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm cortexa9t2hf_vfp                                                                                                                                                                 3.7 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm cortexa9t2hf_neon                                                                                                                                                                3.8 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm zynq                                                                                                                                                                             2.5 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm zynq_7z                                                                                                                                                                          3.7 kB/s | 257  B     00:00
OE Remote Repo: sswreleases rel-v2021.2 generic-updates rpm zynq_generic                                                                                                                                                                     2.6 kB/s | 257  B     00:00
gstreamer1.0-plugins-bad-fbdevsink-0:1.16.3+git0+a3487d4884-r0.0.cortexa9t2hf_neon
gstreamer1.0-plugins-bad-rfbsrc-0:1.16.3+git0+a3487d4884-r0.0.cortexa9t2hf_neon
libharfbuzz-bin-0:2.7.2-r0.0.cortexa9t2hf_neon
libharfbuzz-dbg-0:2.7.2-r0.0.cortexa9t2hf_neon
libharfbuzz-dev-0:2.7.2-r0.0.cortexa9t2hf_neon
libharfbuzz-icu-dev-0:2.7.2-r0.0.cortexa9t2hf_neon
libharfbuzz-icu0-0:2.7.2-r0.0.cortexa9t2hf_neon
libharfbuzz-lic-0:2.7.2-r0.0.cortexa9t2hf_neon
libharfbuzz-src-0:2.7.2-r0.0.cortexa9t2hf_neon
libharfbuzz-subset0-0:2.7.2-r0.0.cortexa9t2hf_neon
libharfbuzz0-0:2.7.2-r0.0.cortexa9t2hf_neon
xf86-video-fbdev-2:0.5.0-r0.0.cortexa9t2hf_neon
xf86-video-fbdev-dbg-2:0.5.0-r0.0.cortexa9t2hf_neon
xf86-video-fbdev-dev-2:0.5.0-r0.0.cortexa9t2hf_neon
xf86-video-fbdev-doc-2:0.5.0-r0.0.cortexa9t2hf_neon
xf86-video-fbdev-lic-2:0.5.0-r0.0.cortexa9t2hf_neon
xf86-video-fbdev-src-2:0.5.0-r0.0.cortexa9t2hf_neon
xserver-xorg-module-libwfb-2:1.20.9-r0.0.cortexa9t2hf_neon
xserver-xorg-xvfb-2:1.20.9-r0.0.cortexa9t2hf_neon

List of installed packages[edit | edit source]

User can see the list of installed packages with dnf repoquery --installed

root@bora:~# dnf repoquery --installed

DNF activity history[edit | edit source]

User can see the activity on packages with dnf history

root@bora:~# dnf history
ID     | Command line      | Date and time    | Action(s)      | Altered
--------------------------------------------------------------------
2      | install lighttpd  | 2024-01-17 16:23 | Install        |    7 EE     
...
root@bora:~#

References[edit | edit source]