particle-os-modules/modules/dnf
2025-05-21 17:54:46 +02:00
..
bluebuild-optfix.service feat: dnf module (#377) 2025-04-27 14:49:39 +00:00
dnf-repoinfo feat: dnf module (#377) 2025-04-27 14:49:39 +00:00
dnf-repolist feat: dnf module (#377) 2025-04-27 14:49:39 +00:00
dnf.nu chore(dnf): Use /usr/lib/ directory for optfix service instead of /etc/ 2025-05-21 17:54:46 +02:00
dnf.tsp feat: dnf module (#377) 2025-04-27 14:49:39 +00:00
dnf_interface.nu chore: Add list size checks 2025-05-02 09:40:16 -04:00
module.yml feat: dnf module (#377) 2025-04-27 14:49:39 +00:00
optfix.sh feat: dnf module (#377) 2025-04-27 14:49:39 +00:00
README.md docs(dnf): Fix whitespace 2025-04-27 17:30:03 +02:00

dnf Module

The dnf module offers pseudo-declarative package and repository management using dnf5.

Features

This module is capable of:

  • Repository Management
    • Enabling/disabling COPR repos
    • Adding repo files via url or local files
    • Removing repos by specifying the repo name
    • Automatically cleaning up any repos added in the module
    • Adding keys for repos via url or local files
    • Adding non-free repos like rpmfusion and negativo17
  • Package Management
    • Installing packages from RPM urls, local RPM files, or package repositories
    • Installing packages from a specific repository
    • Removing packages
    • Replacing installed packages with versions from another repository
  • Optfix
    • Setup symlinks to /opt/ to allow certain packages to install

Repository Management

Add Repository Files

  • Add repos from
    • any https:// or http:// URL
    • any .repo files located in ./files/dnf/ of your image repo
  • If the OS version is included in the file name or URL, you can substitute it with the %OS_VERSION% magic string
    • The version is gathered from the VERSION_ID field of /usr/lib/os-release
type: dnf
repos:
  files:
    - https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
    - custom-file.repo # file path for /files/dnf/custom-file.repo

Add COPR Repositories

  • COPR contains software repositories maintained by fellow Fedora users
type: dnf
repos:
  copr:
    - atim/starship
    - trixieua/mutter-patched

Disable/Enable Repositories

type: dnf
repos:
  files:
    add:
      - repo1
      - repo2
    remove:
      - repo3
  copr:
    enable:
      - ryanabx/cosmic-epoch
    disable:
      - kylegospo/oversteer

Add Repository Keys

type: dnf
repos:
  keys:
    - https://example.com/repo-1.asc
    - key2.asc

Add Non-free Repositories

This allows you to add a commonly used non-free repository. You can choose between negativo17 and rpmfusion. Your choice will also disable the opposite repository if it was already enabled.

type: dnf
repos:
  nonfree: negativo17

Options

There is currently only one option that can be specified in the repository management section.

  • cleanup automatically cleans up repositories added in this section
    • Disabled by default
type: dnf
repos:
  cleanup: true

Package Management

Installing

Packages from Any Repository

type: dnf
install:
  packages:
    - package-1
    - package-2

Packages from URL or File

  • If the OS version is included in the file name or URL, you can substitute it with the %OS_VERSION% magic string
    • The version is gathered from the VERSION_ID field of /usr/lib/os-release
type: dnf
install:
  packages:
    - https://example.com/package-%OS_VERSION%.rpm
    - custom-file.rpm # install files/dnf/custom-file.rpm from the image repository

Packages from Specific Repositories

  • Set repo to the name of the RPM repository, not the name or URL of the repo file
type: dnf
install:
  packages:
    - repo: copr:copr.fedorainfracloud.org:custom-user:custom-repo
      packages:
        - package-1

Package Groups

  • See list of all package groups by running dnf5 group list --hidden on a live system
  • Set the option with-optional to true to enable installation of optional packages in package groups
type: dnf
group-install:
  with-optional: true
  packages:
    - de-package-1
    - wm-package-2

Replace Packages

  • You can specify one or more packages that will be swapped from another repo
  • This process uses distro-sync to perform this operation
  • All packages not specifying old: and new: will be swapped in a single transaction
type: dnf
replace:
  - from-repo: copr:copr.fedorainfracloud.org:custom-user:custom-repo
    packages:
      - package-1
  • If a package has a different name in another repo, you can use the old: and new: properties
  • This process uses swap to perform this operation for each set
  • This process is ran before distro-sync
type: dnf
replace:
  - from-repo: repo-1
    packages:
      - old: old-package-2
        new: new-package-2

Options

The following options can specified in the package installation, group installation, and package replacement sections.

  • install-weak-deps enables installation of the weak dependencies of RPMs
  • skip-unavailable enables skipping packages unavailable in repositories without erroring out
  • skip-broken enables skipping broken packages without erroring out
  • allow-erasing allows removing packages in case of dependency problems during package installation
type: dnf
install:
  skip-unavailable: true
  packages:
    ...
group-install:
  skip-broken: true
  packages:
    ...
replace:
  - from-repo: repo-1
    allow-erasing: true
    packages:
      ...

Removing

Packages

  • You can set the auto-remove option to false to only remove the specific package and leave unused dependencies
type: dnf
remove:
  auto-remove: false
  packages:
    - package-1
    - package-2

Package Groups

type: dnf
group-remove:
  packages:
    - de-package-2

Optfix

  • Optfix is a script used to work around problems with certain packages that install into /opt/
    • These issues are caused by Fedora Atomic storing /opt/ at the location /var/opt/ by default, while /var/ is only writeable on a live system
    • The script works around these issues by moving the folder to /usr/lib/opt/ and creating the proper symlinks at runtime
  • Specify a list of folders inside /opt/
type: dnf
optfix:
  - brave.com
  - foldername

Note

This documentation page uses the installation of the Brave Browser as an example of a package that required a custom repository, with a custom key, and an optfix configuration to install properly. This is not an official endorsement of the Brave Browser by the BlueBuild project.