File: force_arch.py

package info (click to toggle)
dnf5 5.4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,960 kB
  • sloc: cpp: 94,312; python: 3,370; xml: 1,073; ruby: 600; sql: 250; ansic: 232; sh: 104; perl: 62; makefile: 30
file content (24 lines) | stat: -rw-r--r-- 889 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import libdnf5

# Create a new Base object
base = libdnf5.base.Base()

# Optionally load configuration from the config files.
base.load_config()

# Override the detected system architecture, similar to how the
# `--forcearch=aarch64` switch works in the dnf5 command line tool.
vars = base.get_vars().get()
vars.set("arch", "aarch64")

# This is sufficient for loading repositories and querying packages using the
# `aarch64` architecture.
# However, if you also want to run a transaction (e.g., you want to modify a
# foreign system from "outside" using `installroot`), you need to set the
# `ignorearch` option to instruct RPM to permit packages that are incompatible
# with the system architecture.
base.get_config().get_ignorearch_option().set(True)

# The base.setup() call configures the architecture for the solver, so the
# `arch` variable needs to be set beforehand.
base.setup()