-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: Document arch override for API users
We have documentation for CLI users (dnf5-forcearch(7)), but it's not clear how to do the same thing through API. This patch fills the gap.
- Loading branch information
Showing
8 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* includes; won't compile in tests, in the docs we leave out the comment lines to show them | ||
#include <libdnf5/base/base.hpp> | ||
*/ | ||
|
||
// Create a new Base object. | ||
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. | ||
base.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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters