Skip to content
Oliver Kurth edited this page Jun 28, 2022 · 11 revisions

Tiny DNF for Package Management

On Photon OS, Tiny DNF is the default package manager for installing new packages. This document explains how to use tdnf when it is running on Photon OS.

If, however, you have installed tdnf on a Linux distribution other than Photon OS, most of the commands and options should work in the same way, with the exception of the repository locations. You will have to set up your own repository; see Adding a New Repository on adding a new repository. A quick solution is to download the Photon OS repository package--named photon-repos--from the Photon OS packages site and install it.

Tdnf is a C implementation of DNF package manager. The standard syntax for tdnf commands is the same as that for DNF:

tdnf [options] <command> [<arguments>...]

You can view its help information like this:

tdnf --help
tdnf -h

Configuration Files and Repositories

The main configuration files reside in /etc/tdnf/tdnf.conf. The configuration file looks like this:

cat /etc/tdnf/tdnf.conf
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=true
repodir=/etc/yum.repos.d
cachedir=/var/cache/tdnf

The cache files for data and metadata reside in /var/cache/tdnf.

The repositories appear in /etc/yum.repos.d/ with .repo file extensions:

ls /etc/yum.repos.d/
lightwave.repo
photon-extras.repo
photon-iso.repo
photon-updates.repo
photon.repo 

You can list the the repositories by using the tdnf repolist command. Tdnf filters the results with enabled, disabled, and all. Running the command without specifying an argument returns the enabled repositories:

tdnf repolist
repo id             repo name                               status
lightwave           VMware Lightwave 1.0(x86_64)            enabled
photon-updates      VMware Photon Linux 1.0(x86_64)Updates  enabled
photon-extras       VMware Photon Extras 1.0(x86_64)        enabled
photon              VMware Photon Linux 1.0(x86_64)         enabled

The photon-iso.repo, however, does not appear in the list of repositories because it is unavailable on the virtual machine from which these examples are taken. Photon-iso.repo is the default repository; it points to /media/cdrom. The contents of photon-iso.repo look like this:

cat /etc/yum.repos.d/photon-iso.repo
[photon-iso]
name=VMWare Photon Linux 1.0(x86_64)
baseurl=file:///mnt/cdrom/RPMS
gpgkey=file:///etc/pki/rpm-gpg/VMWARE-RPM-GPG-KEY
gpgcheck=1
enabled=0
skip_if_unavailable=True

The local cache is populated with data from the repository:

ls -l /var/cache/tdnf/photon
total 8
drwxr-xr-x 2 root root 4096 May 18 22:52 repodata
d-wxr----t 3 root root 4096 May  3 22:51 rpms

You can clear the cache to help troubleshoot a problem, but keep in mind that doing so might slow the performance of tdnf until the cache becomes repopulated with data. Here is how to clear the cache:

tdnf clean all
Cleaning repos: photon photon-extras photon-updates lightwave
Cleaning up everything

The command purges the repository data from the cache:

ls -l /var/cache/tdnf/photon
total 4
d-wxr----t 3 root root 4096 May  3 22:51 rpms

Options for Commands

See Common Command Line Options for more detailed and complete documentation.

You can add the following options to tdnf commands. If the option to override a configuration is unavailable in a command, consider adding it to the configuration file, /etc/tdnf/tdnf.conf.

OPTION 					DESCRIPTION
--allowerasing 			Allow erasing of installed packages to resolve dependencies
--assumeno 				Answer no for all questions
--best 					Try the best available package versions in transactions
--debugsolver 			Dump data aiding in dependency solver debugging info.
--disablerepo=<repoid> 	Disable specific repositories by an id or a glob.
--enablerepo=<repoid> 	Enable specific repositories
-h, --help 				Display help
--refresh 				Set metadata as expired before running command
--nogpgcheck 			Skip gpg check on packages
--rpmverbosity=<debug level name> 	Debug level for rpm
--version 				Print version and exit
-y, --assumeyes 		Answer yes to all questions

Here is an example that adds the short form of the assumeyes option to the install command:

tdnf -y install gcc
Upgrading:
gcc 	x86_64	5.3.0-1.ph1 	91.35 M