File: transaction.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 (27 lines) | stat: -rw-r--r-- 768 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
25
26
27
# Create a goal.
goal = libdnf5.base.Goal(base)

# Add an RPM package named "one" for installation into the goal.
goal.add_rpm_install("one")

# Resolve the goal, create a transaction object.
transaction = goal.resolve()

if transaction.get_problems() != libdnf5.base.GoalProblem_NO_PROBLEM:
    for message in transaction.get_resolve_logs_as_strings():
        print(message)

# We can iterate over the resolved transaction and inspect the packages.
for tspkg in transaction.get_transaction_packages():
    print(
        tspkg.get_package().get_nevra(), ": ",
        libdnf5.base.transaction.transaction_item_action_to_string(
            tspkg.get_action()
        )
    )

# Download the packages.
transaction.download()

# Run the transaction.
transaction.run()