:Basic pre-commit configuration

Pre-commit hooks are now included to check for common style violations.
These checks include remains of merge conflict delimiters, trailing whitespaces,
pep8 violations and clang-format.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
This commit is contained in:
Jiri Podivin 2023-03-13 13:15:31 +01:00 committed by Nicola Sella
parent 35ead73ae2
commit 0fdd5f2fb2
90 changed files with 448 additions and 363 deletions

23
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,23 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude:
test/libdnf/iniparser/test_iniparser.cpp
- id: end-of-file-fixer
- id: check-xml
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v15.0.7
hooks:
- id: clang-format
types_or:
- c++
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.2
hooks:
- id: autopep8

View File

@ -1 +1 @@
__init__.py
__init__.py

View File

@ -1 +1 @@
__init__.py
__init__.py

View File

@ -19,21 +19,21 @@ At first I tried to use the glib extension of gettext. But glib is incomplete.
#### `_(msgId)`
This macro wraps gettext/dgettext. The macro attempts to translate a text string into the user's native language, by looking up the translation in a message catalog.
The msgId argument identifies the message to be translated. By convention, it is the English version of the message, with non-ASCII characters replaced by ASCII approximationsUses gettext to get the translation for msgId.
The msgId argument identifies the message to be translated. By convention, it is the English version of the message, with non-ASCII characters replaced by ASCII approximationsUses gettext to get the translation for msgId.
If you are using the `_()` macro, you need to make sure that you pass `--keyword=_` to xgettext when extracting messages. Note that this only works with GNU gettext >= 0.15.
##### Parameters
`msgId` - a message id, must be a string literal
##### Returns
If a translation was found in one of the specified catalogs, it is converted to the locale's codeset and returned. The resulting string is statically allocated and must not be modified or freed. Otherwise msgid is returned.
If a translation was found in one of the specified catalogs, it is converted to the locale's codeset and returned. The resulting string is statically allocated and must not be modified or freed. Otherwise msgid is returned.
##### Example
`label = _("This is text for translation")`
#### `P_(msgId, msgIdPlural, n)`
This macro wraps ngettext/dngettext. It is used for translate message and choose plural form.
Plural forms are grammatical variants depending on the a number. Some languages have two forms, called singular and plural. Other languages have three or more forms.
If you are using the `P_()` macro, you need to make sure that you pass `--keyword=P_:1,2` to xgettext when extracting messages. Note that this only works with GNU gettext >= 0.15.
##### Parameters
`msgId` - a message id, must be a string
`msgId` - a message id, must be a string
`msgIdPlural` - plural form of the message
`n` - the quantity for which translation is needed
##### Returns
@ -58,7 +58,7 @@ This is the most powerfull macro. It supports translation of message with contex
If you are using the `CP_()` macro, you need to make sure that you pass `--keyword=CP_:1c,2,3` to xgettext when extracting messages. Note that this only works with GNU gettext >= 0.15.
##### Parameters
`context` - a message context, must be a string literal
`msgId` - a message id, must be a string
`msgId` - a message id, must be a string
`msgIdPlural` - plural form of the message, must be a string literal
`n` - the quantity for which translation is needed
##### Returns

View File

@ -1,2 +1,2 @@
All files in this directory with the extension ".conf" are loaded as alias definitions
of the dnf5 command line arguments. The files are loaded in alphabetical order.
of the dnf5 command line arguments. The files are loaded in alphabetical order.

View File

@ -8,4 +8,3 @@
<allow send_destination="org.rpm.dnf.v0"/>
</policy>
</busconfig>

View File

@ -6,4 +6,4 @@ Transaction
:members:
.. doxygenclass:: libdnf::base::TransactionError
:members:
:members:

View File

@ -3,4 +3,4 @@ Goal
.. doxygenclass:: libdnf::Goal
:members:
:members:

View File

@ -17,5 +17,3 @@ Goal structures and enums
.. doxygenenum:: libdnf::GoalSetting
.. doxygenenum:: libdnf::GoalUsedSetting

View File

@ -31,7 +31,7 @@ Synopsis
Description
===========
The ``advisory`` command in ``DNF5`` offers several queries for getting information about
The ``advisory`` command in ``DNF5`` offers several queries for getting information about
advisories and packages related to them.
Optional ``advisory-spec`` arguments could be passed to filter only advisories with given names.
@ -83,19 +83,19 @@ Options
| Consider only content contained in newpackage advisories.
``--advisory-severities=ADVISORY_SEVERITY,...``
| Consider only content contained in advisories with specified severity.
| This is a list option.
| Consider only content contained in advisories with specified severity.
| This is a list option.
| Accepted values are: `critical`, `important`, `moderate`, `low`, `none`.
``--bzs=BUGZILLA_ID,...``
| Consider only content contained in advisories that fix a ticket of given Bugzilla ID.
| Consider only content contained in advisories that fix a ticket of given Bugzilla ID.
| This is a list option.
| Expected values are numeric IDs, e.g. `123123`.
``--cves=CVE_ID,...``
| Consider only content contained in advisories that fix a ticket of given CVE (Common Vulnerabilities and Exposures) ID.
| This is a list option.
| Expected values are string IDs in CVE format, e.g. `CVE-2201-0123`.
| Expected values are string IDs in CVE format, e.g. `CVE-2201-0123`.
``--with-bz``
| Show only advisories referencing a Bugzilla ticket.
@ -115,4 +115,3 @@ Examples
``dnf5 advisory list --security --advisory-severities=important``
| Show a list of security advisories or advisories with ``important`` severity.

View File

@ -31,7 +31,7 @@ Synopsis
Description
===========
The ``clean`` command in ``DNF5`` is used to delete temporarily kept repository metadata
The ``clean`` command in ``DNF5`` is used to delete temporarily kept repository metadata
or marking the cache expired.
Arguments in ``cache_types`` specify which types of the cached data to cleanup:
@ -44,15 +44,15 @@ Arguments in ``cache_types`` specify which types of the cached data to cleanup:
`metadata`
| Delete repository metadata.
| This will delete the files which ``DNF5`` uses to determine the remote availability of packages.
| This will delete the files which ``DNF5`` uses to determine the remote availability of packages.
| Using this option will make ``DNF5`` download all the metadata the next time it is run.
`dbcache`
| Delete cache files generated from the repository metadata.
| Delete cache files generated from the repository metadata.
| This forces ``DNF5`` to regenerate the cache files the next time it is run.
`expire-cache`
| Mark the repository metadata expired.
| Mark the repository metadata expired.
| This forces ``DNF5`` to check the validity of the cache the next time it is run.
@ -64,4 +64,3 @@ Examples
``dnf5 clean packages dbcache``
| Cleanup all cached packages and dbcache metadata.

View File

@ -31,8 +31,8 @@ Synopsis
Description
===========
The ``distro-sync`` command in ``DNF5`` serves to synchronize the installed packages
with their latest available version from any enabled repository. It upgrades, downgrades
The ``distro-sync`` command in ``DNF5`` serves to synchronize the installed packages
with their latest available version from any enabled repository. It upgrades, downgrades
or keeps packages as needed.
Optional ``package-spec`` arguments could be passed to select only specific packages to be synced.
@ -59,4 +59,3 @@ See Also
========
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -31,7 +31,7 @@ Synopsis
Description
===========
The ``downgrade`` command in ``DNF5`` is used to downgrade each package specified in ``package-spec`` list to the
The ``downgrade`` command in ``DNF5`` is used to downgrade each package specified in ``package-spec`` list to the
highest installable version of all known lower versions if possible. When the version is explicitly given
in the argument and it is lower than the version of the installed package then it downgrades to this one.
@ -57,4 +57,3 @@ See Also
========
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -31,7 +31,7 @@ Synopsis
Description
===========
The ``download`` command in ``DNF5`` is used for downloading binary and source packages
The ``download`` command in ``DNF5`` is used for downloading binary and source packages
defined in ``package-spec`` arguments.
@ -62,4 +62,3 @@ See Also
========
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -34,7 +34,7 @@ Synopsis
Description
===========
The ``environment`` command in ``DNF5`` offers several queries for getting information
The ``environment`` command in ``DNF5`` offers several queries for getting information
about environments and groups related to them.
Optional ``environment-spec`` arguments could be passed to filter only environments with given names.
@ -75,4 +75,3 @@ See Also
| :manpage:`dnf5-comps(7)`, :ref:`Comps groups and environments <comps_misc_ref-label>`
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -83,4 +83,3 @@ See Also
| :manpage:`dnf5-comps(7)`, :ref:`Comps groups and environments <comps_misc_ref-label>`
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -80,4 +80,3 @@ See Also
========
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -30,4 +30,3 @@ DNF5 Commands
# TODO(jkolarik): module not ready yet
module.8

View File

@ -48,19 +48,19 @@ Options
| Expected values are advisory IDs, e.g. `FEDORA-2201-123`.
``--advisory-severities=ADVISORY_SEVERITY,...``
| Consider only content contained in advisories with specified severity.
| This is a list option.
| Consider only content contained in advisories with specified severity.
| This is a list option.
| Accepted values are: `critical`, `important`, `moderate`, `low`, `none`.
``--bzs=BUGZILLA_ID,...``
| Consider only content contained in advisories that fix a ticket of given Bugzilla ID.
| Consider only content contained in advisories that fix a ticket of given Bugzilla ID.
| This is a list option.
| Expected values are numeric IDs, e.g. `123123`.
``--cves=CVE_ID,...``
| Consider only content contained in advisories that fix a ticket of given CVE (Common Vulnerabilities and Exposures) ID.
| This is a list option.
| Expected values are string IDs in CVE format, e.g. `CVE-2201-0123`.
| Expected values are string IDs in CVE format, e.g. `CVE-2201-0123`.
``--security``
| Consider only content contained in security advisories.
@ -85,7 +85,7 @@ Examples
| Install the local rpm file from the given location.
``dnf5 install tito-0.6.21-1.fc36``
| Install the ``tito`` package in defined version.
| Install the ``tito`` package in defined version.
| If the package is already installed, it will automatically try to downgrade or upgrade to the given version.
``dnf5 install --advisory=FEDORA-2022-07aa56297a \*``
@ -97,4 +97,3 @@ See Also
| :manpage:`dnf5-advisory(8)`, :ref:`Advisory command <advisory_command_ref-label>`
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -34,6 +34,5 @@ Description
The ``makecache`` command in ``DNF5`` is used for creating and downloading metadata
for enabled repositories.
It tries to avoid downloading whenever possible, e.g. when the local metadata hasn't
It tries to avoid downloading whenever possible, e.g. when the local metadata hasn't
expired yet or when the metadata timestamp hasn't changed.

View File

@ -31,7 +31,7 @@ Synopsis
Description
===========
The ``mark`` command in ``DNF5`` is used to change reason of installed packages
The ``mark`` command in ``DNF5`` is used to change reason of installed packages
defined in ``package-spec`` arguments.
@ -41,18 +41,18 @@ Subcommands
``user``
| Mark the package as user-installed.
This can be useful if any package was installed as a dependency and is desired
to stay on the system when ``remove`` command along with ``clean_requirements_on_remove``
This can be useful if any package was installed as a dependency and is desired
to stay on the system when ``remove`` command along with ``clean_requirements_on_remove``
configuration option set to ``True`` is executed.
``dependency``
| Mark the package as a dependency.
This can be useful if you as the user don't need a specific package. The package stays
installed on the system, but will be removed when ``remove`` command along with
This can be useful if you as the user don't need a specific package. The package stays
installed on the system, but will be removed when ``remove`` command along with
``clean_requirements_on_remove`` configuration option set to ``True`` is executed.
You should use this operation instead of ``remove`` command if you're not sure whether
You should use this operation instead of ``remove`` command if you're not sure whether
the package is a requirement of other user installed package on the system.
``weak``
@ -63,8 +63,8 @@ Subcommands
``group``
| Mark the package as installed by the group defined in ``group-id`` argument.
This can be useful if any package was installed as a dependency or the user and
This can be useful if any package was installed as a dependency or the user and
is desired to be protected and handled as a group member like during ``group remove`` command.
@ -83,4 +83,3 @@ See Also
| :manpage:`dnf5-comps(7)`, :ref:`Comps groups and environments <comps_misc_ref-label>`
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -72,4 +72,3 @@ Options
Examples
========

View File

@ -50,4 +50,3 @@ See Also
========
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -47,4 +47,3 @@ See Also
========
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -31,7 +31,7 @@ Synopsis
Description
===========
The ``repo`` command in ``DNF5`` offers several queries for getting information
The ``repo`` command in ``DNF5`` offers several queries for getting information
about repositories configured on the system.
@ -67,4 +67,3 @@ Examples
``dnf5 repo list --disabled *-debuginfo``
| Print disabled repositories related to debugging.

View File

@ -45,19 +45,19 @@ Options
| Expected values are advisory IDs, e.g. `FEDORA-2201-123`.
``--advisory-severities=ADVISORY_SEVERITY,...``
| Consider only content contained in advisories with specified severity.
| This is a list option.
| Consider only content contained in advisories with specified severity.
| This is a list option.
| Accepted values are: `critical`, `important`, `moderate`, `low`, `none`.
``--bzs=BUGZILLA_ID,...``
| Consider only content contained in advisories that fix a ticket of given Bugzilla ID.
| Consider only content contained in advisories that fix a ticket of given Bugzilla ID.
| This is a list option.
| Expected values are numeric IDs, e.g. `123123`.
``--cves=CVE_ID,...``
| Consider only content contained in advisories that fix a ticket of given CVE (Common Vulnerabilities and Exposures) ID.
| This is a list option.
| Expected values are string IDs in CVE format, e.g. `CVE-2201-0123`.
| Expected values are string IDs in CVE format, e.g. `CVE-2201-0123`.
``--security``
| Consider only content contained in security advisories.
@ -105,4 +105,3 @@ See Also
| :manpage:`dnf5-advisory(8)`, :ref:`Advisory command <advisory_command_ref-label>`
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -32,10 +32,10 @@ Description
===========
The ``search`` command in ``DNF5`` is used for searching packages by matching
given keywords from the user against various metadata.
given keywords from the user against various metadata.
By default the command searches for all requested keys (AND operation) in
`Name` or `Summary` fields from the RPM package metadata. Matching is
By default the command searches for all requested keys (AND operation) in
`Name` or `Summary` fields from the RPM package metadata. Matching is
case-insensitive and globs are supported.
@ -64,4 +64,3 @@ See Also
========
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -47,4 +47,3 @@ Examples
``dnf5 swap mlocate plocate``
| Remove the ``mlocate`` package and install the ``plocate`` instead in the single transaction.

View File

@ -39,7 +39,7 @@ Options
=======
``--minimal``
Update packages only to the lowest higher available version that provides a bugfix,
Update packages only to the lowest higher available version that provides a bugfix,
enhancement or a fix for a security issue.
``--allowerasing``
@ -51,19 +51,19 @@ Options
| Expected values are advisory IDs, e.g. `FEDORA-2201-123`.
``--advisory-severities=ADVISORY_SEVERITY,...``
| Consider only content contained in advisories with specified severity.
| This is a list option.
| Consider only content contained in advisories with specified severity.
| This is a list option.
| Accepted values are: `critical`, `important`, `moderate`, `low`, `none`.
``--bzs=BUGZILLA_ID,...``
| Consider only content contained in advisories that fix a ticket of given Bugzilla ID.
| Consider only content contained in advisories that fix a ticket of given Bugzilla ID.
| This is a list option.
| Expected values are numeric IDs, e.g. `123123`.
``--cves=CVE_ID,...``
| Consider only content contained in advisories that fix a ticket of given CVE (Common Vulnerabilities and Exposures) ID.
| This is a list option.
| Expected values are string IDs in CVE format, e.g. `CVE-2201-0123`.
| Expected values are string IDs in CVE format, e.g. `CVE-2201-0123`.
``--security``
| Consider only content contained in security advisories.
@ -93,4 +93,3 @@ See Also
| :manpage:`dnf5-advisory(8)`, :ref:`Advisory command <advisory_command_ref-label>`
| :manpage:`dnf5-specs(7)`, :ref:`Patterns specification <specs_misc_ref-label>`

View File

@ -21,7 +21,7 @@
################################
..
# TODO(jkolarik): unify first man page structure with the help output, especially the commands
# TODO(jkolarik): unify first man page structure with the help output, especially the commands
grouping - think about it, some groups and related commands don't make much sense
# TODO(jkolarik): add notes about mutually exclusive options
# TODO(jkolarik): add crosslinks where possible
@ -37,7 +37,7 @@ Synopsis
Description
===========
`DNF5`_ is the new version of `DNF`_, a package manager for RPM-based Linux distributions. It has been completely
`DNF5`_ is the new version of `DNF`_, a package manager for RPM-based Linux distributions. It has been completely
rewritten in C++ aiming for better performance and reducing external dependencies.
@ -60,10 +60,10 @@ For more details see the separate man page for the specific command, f.e. ``man
| Downgrade packages.
:ref:`download <download_command_ref-label>`
| Download packages.
| Download packages.
:ref:`environment <environment_command_ref-label>`
| Manage comps environments.
| Manage comps environments.
:ref:`group <group_command_ref-label>`
| Manage comps groups.
@ -84,7 +84,7 @@ For more details see the separate man page for the specific command, f.e. ``man
| Remove packages.
:ref:`repo <repo_command_ref-label>`
| Manage repositories.
| Manage repositories.
:ref:`repoquery <repoquery_command_ref-label>`
| Search for packages in repositories.
@ -105,7 +105,7 @@ For more details see the separate man page for the specific command, f.e. ``man
# TODO(jkolarik): Module command is not ready yet
:ref:`module <module_command_ref-label>`
| Manage modules.
| Manage modules.
Options
@ -117,15 +117,15 @@ Following options are applicable in the general context for any ``dnf5`` command
| Automatically answer no for all questions.
``--best``
| Try the best available package versions in transactions.
| Try the best available package versions in transactions.
Specifically during dnf upgrade, which by default skips over updates that can not be
installed for dependency reasons, the switch forces ``DNF5`` to only consider the latest
packages. When running into packages with broken dependencies, ``DNF5`` will fail giving
Specifically during dnf upgrade, which by default skips over updates that can not be
installed for dependency reasons, the switch forces ``DNF5`` to only consider the latest
packages. When running into packages with broken dependencies, ``DNF5`` will fail giving
the reason why the latest version can not be installed.
Note that the use of the newest available version is only guaranteed for the packages
directly requested (e.g. as a command line arguments), and the solver may use older
Note that the use of the newest available version is only guaranteed for the packages
directly requested (e.g. as a command line arguments), and the solver may use older
versions of dependencies to meet their requirements.
``--comment=COMMENT``
@ -180,7 +180,7 @@ Following options are applicable in the general context for any ``dnf5`` command
| Disable all plugins.
``-q, --quiet``
In combination with a non-interactive command, shows just the relevant content.
In combination with a non-interactive command, shows just the relevant content.
Suppresses messages notifying about the current state or actions of ``DNF5``.
``--repo=REPO_ID,...``
@ -189,15 +189,15 @@ Following options are applicable in the general context for any ``dnf5`` command
| Accepted values are ids, or a glob of ids.
``--releasever=RELEASEVER``
| Override the value of the distribution release in configuration files.
| Override the value of the distribution release in configuration files.
| This can affect cache paths, values in configuration files and mirrorlist URLs.
``--setopt=[REPO_ID.]OPTION=VALUE``
| Override a configuration option from the configuration file.
| Override a configuration option from the configuration file.
| The ``REPO_ID`` parameter is used to override options for repositories.
Values for the options like ``excludepkgs``, ``includepkgs``, ``installonlypkgs`` and ``tsflags``
are appended to the original value, they do not override it. However, specifying an empty
Values for the options like ``excludepkgs``, ``includepkgs``, ``installonlypkgs`` and ``tsflags``
are appended to the original value, they do not override it. However, specifying an empty
value (e.g. ``--setopt=tsflags=``) will clear the option.
``--setvar=VAR_NAME=VALUE``
@ -217,32 +217,32 @@ Following options are applicable in the general context for any ``dnf5`` command
Metadata Synchronization
========================
Correct operation of ``DNF5`` depends on having an access to up-to-date data from the all enabled
repositories, but contacting remote mirrors on every operation considerably slows it down and costs
bandwidth for both the client and the repository provider. The ``metadata_expire`` repository configuration
option is used by ``DNF5`` to determine whether a particular local copy of repository data is due
to be re-synced. It is crucial that the repository providers set the option well, namely to a value
where it is guaranteed that if particular metadata was available in time ``T`` on the server,
then all packages it references will still be available for download from the server
Correct operation of ``DNF5`` depends on having an access to up-to-date data from the all enabled
repositories, but contacting remote mirrors on every operation considerably slows it down and costs
bandwidth for both the client and the repository provider. The ``metadata_expire`` repository configuration
option is used by ``DNF5`` to determine whether a particular local copy of repository data is due
to be re-synced. It is crucial that the repository providers set the option well, namely to a value
where it is guaranteed that if particular metadata was available in time ``T`` on the server,
then all packages it references will still be available for download from the server
in time ``T + metadata_expire``.
To further reduce the bandwidth load, some of the commands where having up-to-date metadata
is not critical (e.g. the ``group list`` command) do not look at whether a repository is expired
and whenever any version of it is locally available to the user's account, it will be used.
To further reduce the bandwidth load, some of the commands where having up-to-date metadata
is not critical (e.g. the ``group list`` command) do not look at whether a repository is expired
and whenever any version of it is locally available to the user's account, it will be used.
For non-root usages it can be also useful running entirely from the system cache, don't update the
For non-root usages it can be also useful running entirely from the system cache, don't update the
cache and use it even in case it is expired by setting the ``cacheonly`` configuration option.
``DNF5`` uses a separate cache for each user under which it executes. The cache for the root user
is called the system cache. This option allows a regular user read-only access to the system cache,
``DNF5`` uses a separate cache for each user under which it executes. The cache for the root user
is called the system cache. This option allows a regular user read-only access to the system cache,
which usually is more fresh than the user's and thus he does not have to wait for metadata sync.
Configuration Files Replacement Policy
======================================
The updated packages could replace the old modified configuration files with the new ones or keep
the older files. Neither of the files are actually replaced. To the conflicting ones ``RPM``
gives additional suffix to the origin name. Which file should maintain the true name after
transaction is not controlled by package manager, but is specified by each package itself,
The updated packages could replace the old modified configuration files with the new ones or keep
the older files. Neither of the files are actually replaced. To the conflicting ones ``RPM``
gives additional suffix to the origin name. Which file should maintain the true name after
transaction is not controlled by package manager, but is specified by each package itself,
following packaging guideline.
@ -325,4 +325,3 @@ Miscellaneous:
Project homepage:
| https://github.com/rpm-software-management/dnf5

View File

@ -94,5 +94,3 @@ Interfaces
.. literalinclude:: ../../dnf5daemon-server/dbus/interfaces/org.rpm.dnf.v0.rpm.Rpm.xml
:language: xml

View File

@ -9,4 +9,3 @@ DNF5 Daemon
dnf5daemon_client.8
dnf5daemon_server.8
dnf5daemon_dbus_api.8

View File

@ -26,10 +26,10 @@ Description
===========
Comps files are used for grouping of packages into functional groups. They are stored
in repository metadata files under the ``comps.xml`` filename.
in repository metadata files under the ``comps.xml`` filename.
There are two types of structures that can be used for grouping. The first is a
`group` which is composed of lists of packages. The second one is an `environment`
There are two types of structures that can be used for grouping. The first is a
`group` which is composed of lists of packages. The second one is an `environment`
that is composed from the groups.
Each `environment` is made of mandatory and optional groups. All mandatory groups have
@ -61,4 +61,3 @@ See Also
| :manpage:`dnf5-group(8)`, :ref:`Group command <group_command_ref-label>`
| :manpage:`dnf5-environment(8)`, :ref:`Environment command <environment_command_ref-label>`

View File

@ -38,7 +38,7 @@ Exclude Filtering
Exclude Filtering is a mechanism used by a user or by the ``DNF5`` plugin to modify the set of available
packages. Exclude Filtering can be modified by either ``includepkgs`` or ``excludepkgs`` configuration options in
configuration files. In addition to user-configured excludes, plugins can also extend the set of excluded packages.
configuration files. In addition to user-configured excludes, plugins can also extend the set of excluded packages.
To disable excludes from the ``DNF5`` plugin you can use the ``--disable-plugin`` command line option.
To disable all excludes for e.g. the install command you can use the following combination
@ -67,4 +67,3 @@ To discover the module which contains an excluded package use ``dnf5 module prov
Examples
========

View File

@ -15,4 +15,4 @@ Miscellaneous
filtering.7
# TODO(jkolarik): Modularity is not ready yet
modularity.7
modularity.7

View File

@ -25,9 +25,9 @@
Description
===========
The ``--installroot`` parameter is used to specify an alternative installroot,
relative to where all packages will be installed. Think of it like doing
``chroot <root> dnf``, except using ``--installroot`` allows ``DNF5`` to work
The ``--installroot`` parameter is used to specify an alternative installroot,
relative to where all packages will be installed. Think of it like doing
``chroot <root> dnf``, except using ``--installroot`` allows ``DNF5`` to work
before the chroot is created.
`cachedir`, `log` files, `releasever`, and `gpgkey` are taken from or stored in
@ -45,18 +45,17 @@ Note: When a path is specified within a command line argument
``--setopt=reposdir=/path/to/repodir`` for `reposdir` or
``--setopt=varsdir=/paths/to/varsdir`` for `vars`), then this path is always
relative to the host with no exceptions.
`pluginpath` and `pluginconfpath` are relative to the host.
`pluginpath` and `pluginconfpath` are relative to the host.
Note: You may also want to use the command-line option ``--releasever=RELEASEVER`` when creating
the installroot, otherwise the $releasever value is taken from the rpmdb within the installroot
(and thus it is empty at the time of creation and the transaction will fail). If ``--releasever=/``
is used, the releasever will be detected from the host (/) system. The new installroot path at the
Note: You may also want to use the command-line option ``--releasever=RELEASEVER`` when creating
the installroot, otherwise the $releasever value is taken from the rpmdb within the installroot
(and thus it is empty at the time of creation and the transaction will fail). If ``--releasever=/``
is used, the releasever will be detected from the host (/) system. The new installroot path at the
time of creation does not contain the repository, releasever and dnf.conf files.
On a modular system you may also want to use the ``--setopt=module_platform_id=<module_platform_name:stream>``
command-line option when creating the installroot, otherwise the ``module_platform_id`` value will be
taken from the ``/etc/os-release`` file within the installroot (and thus it will be empty at the time of
On a modular system you may also want to use the ``--setopt=module_platform_id=<module_platform_name:stream>``
command-line option when creating the installroot, otherwise the ``module_platform_id`` value will be
taken from the ``/etc/os-release`` file within the installroot (and thus it will be empty at the time of
creation, the modular dependency could be unsatisfied and modules content could be excluded).
@ -64,10 +63,9 @@ Examples
========
``dnf5 --installroot=INSTALLROOT --releasever=RELEASEVER install system-release``
Permanently sets the ``releasever`` of the system in the ``INSTALLROOT`` directory
Permanently sets the ``releasever`` of the system in the ``INSTALLROOT`` directory
to ``RELEASEVER``.
``dnf5 --installroot=INSTALLROOT --setopt=reposdir=PATH --config /path/dnf.conf upgrade``
Upgrades packages inside the installroot from a repository described by ``--setopt``
Upgrades packages inside the installroot from a repository described by ``--setopt``
using configuration from ``/path/dnf.conf``.

View File

@ -29,4 +29,3 @@ Description
===========
Modularity is a new way of building, organizing and delivering packages.

View File

@ -28,8 +28,8 @@
Description
===========
Different pattern matching rules for arguments in ``*-spec`` form are defined
for operation with each entity type in ``DNF5``. In this section all rules are
Different pattern matching rules for arguments in ``*-spec`` form are defined
for operation with each entity type in ``DNF5``. In this section all rules are
described and explained in detail, with examples.
@ -67,7 +67,7 @@ Each package can be uniquely identified by the `NEVRA` string. It consists of
| Epoch number.
| It is not always included.
The epoch number overrides other version checking, so it can be used to
The epoch number overrides other version checking, so it can be used to
force the package upgrade over some other one.
`Version`
@ -78,14 +78,14 @@ Each package can be uniquely identified by the `NEVRA` string. It consists of
`Release`
| Edition string.
It is an information about the particular package build, usually a number
It is an information about the particular package build, usually a number
increased with the newer build. It is not connected with the upstream software.
`Architecture`
| Target architecture string.
| Defines the processor type the package is intended to be installed on.
It can be also a package containing source files (``src``) or architecture-independent
It can be also a package containing source files (``src``) or architecture-independent
package (``noarch``).
When matching against NEVRAs, partial matching is supported. ``DNF5`` tries to match
@ -175,7 +175,7 @@ Since `NEVRA` matching form is insufficient for modules, they are uniquely ident
| All above combinations with ``/PROFILE`` (e.g. ``NAME/PROFILE``)
|
In case stream is not specified, the enabled or the default stream is used, in this order.
In case stream is not specified, the enabled or the default stream is used, in this order.
In case profile is not specified, the system default profile or the 'default' profile is used.
@ -187,4 +187,3 @@ specifies a transaction ID. Specifying ``last`` is the same as specifying the ID
of the most recent transaction. The last form is ``last-<offset>``, where
``<offset>`` is a positive integer. It specifies offset-th transaction preceding
the most recent transaction.

View File

@ -26,20 +26,25 @@ def configure(src_path, dst_path, substitutions):
def generate_bindings_from_dir(in_dir, out_dir):
swig_options = ["-python", "-DSWIGWORDSIZE64", "-doxygen", "-relativeimport", "-outdir", out_dir, "-c++"]
swig_includes = ["-I" + os.path.join(DIR, "../include"), "-I" + os.path.join(DIR, "../common"), "-I/usr/include/python3.11"]
swig_options = ["-python", "-DSWIGWORDSIZE64", "-doxygen",
"-relativeimport", "-outdir", out_dir, "-c++"]
swig_includes = ["-I" + os.path.join(DIR, "../include"), "-I" + os.path.join(
DIR, "../common"), "-I/usr/include/python3.11"]
for in_file in os.listdir(in_dir):
# exclude shared.i which is not a standalone interface file
# it is included in other files.
if in_file.endswith(".i") and in_file != "shared.i":
print("Generating bindings for: " + in_file)
subprocess.run(["/usr/bin/swig"] + swig_options + ["-interface", "_" + in_file[:-2]] + swig_includes + [os.path.join(in_dir, in_file)], cwd=DIR, check=True)
subprocess.run(["/usr/bin/swig"] + swig_options + ["-interface", "_" + in_file[:-2]
] + swig_includes + [os.path.join(in_dir, in_file)], cwd=DIR, check=True)
# configure the .in files
configure("Doxyfile.in", "Doxyfile", {"@CMAKE_SOURCE_DIR@": os.path.join(DIR, "..")})
configure("conf.py.in", "conf.py", {"@CMAKE_CURRENT_BINARY_DIR@": DIR, "@AUTOAPI_EXTENSION@": "\'autoapi.extension\',"})
configure("Doxyfile.in", "Doxyfile", {
"@CMAKE_SOURCE_DIR@": os.path.join(DIR, "..")})
configure("conf.py.in", "conf.py", {
"@CMAKE_CURRENT_BINARY_DIR@": DIR, "@AUTOAPI_EXTENSION@": "\'autoapi.extension\',"})
# In place replace autodoc directives with autoapidoc directives.
# Our readthedocs workflow uses autoapidoc instead of autodoc because
@ -62,10 +67,12 @@ print("Running SWIG...")
# libdnf5
# Generate bindings outside of doc dir, into their python bindings dir. This has to match with path provided to autoapi_dirs in conf.py.in
generate_bindings_from_dir(os.path.join(DIR + "/../bindings/libdnf5"), os.path.join(DIR + "/../bindings/python3/libdnf5"))
generate_bindings_from_dir(os.path.join(
DIR + "/../bindings/libdnf5"), os.path.join(DIR + "/../bindings/python3/libdnf5"))
# libdnf5-cli
generate_bindings_from_dir(os.path.join(DIR + "/../bindings/libdnf5_cli"), os.path.join(DIR + "/../bindings/python3/libdnf5_cli"))
generate_bindings_from_dir(os.path.join(DIR + "/../bindings/libdnf5_cli"),
os.path.join(DIR + "/../bindings/python3/libdnf5_cli"))
# no setup() is called
# this file only configures files for building docs in Read the Docs

View File

@ -2,4 +2,3 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbusdoc.py ${CMAKE_CURRENT_BINARY_DIR
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbusdomain.py ${CMAKE_CURRENT_BINARY_DIR}/dbusdomain.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbusparser.py ${CMAKE_CURRENT_BINARY_DIR}/dbusparser.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fakedbusdoc.py ${CMAKE_CURRENT_BINARY_DIR}/fakedbusdoc.py COPYONLY)

View File

@ -138,11 +138,13 @@ class DBusDocDirective(SphinxDirective):
reporter = self.state.document.reporter
try:
source, lineno = reporter.get_source_and_line(self.lineno) # type: ignore
source, lineno = reporter.get_source_and_line(
self.lineno) # type: ignore
except AttributeError:
source, lineno = (None, None)
logger.debug("[dbusdoc] %s:%s: input:\n%s", source, lineno, self.block_text)
logger.debug("[dbusdoc] %s:%s: input:\n%s",
source, lineno, self.block_text)
libdnf_docdir = os.path.abspath(".")
qapidoc_srctree = os.path.join(libdnf_docdir, '..')

View File

@ -261,7 +261,7 @@ class DBusXRef(XRefRole):
title = title[1:]
dot = title.rfind(".")
if dot != -1:
title = title[dot + 1 :]
title = title[dot + 1:]
# if the first character is a dot, search more specific namespaces first
# else search builtins first
if target[0:1] == ".":
@ -301,14 +301,15 @@ class DBusIndex(Index):
for ignore in ignores:
if name.startswith(ignore):
name = name[len(ignore) :]
name = name[len(ignore):]
stripped = ignore
break
else:
stripped = ""
entries = content.setdefault(name[0].lower(), [])
entries.append(IndexEntry(stripped + name, 0, docname, node_id, "", "", ""))
entries.append(IndexEntry(stripped + name, 0,
docname, node_id, "", "", ""))
# sort by first letter
sorted_content = sorted(content.items())

View File

@ -150,13 +150,13 @@ class DBusXMLParser:
colon_index = line.find(": ")
if colon_index == -1:
if line.endswith(":"):
symbol = line[0 : len(line) - 1]
symbol = line[0: len(line) - 1]
comment_state = DBusXMLParser.COMMENT_STATE_PARAMS
else:
comment_state = DBusXMLParser.COMMENT_STATE_SKIP
else:
symbol = line[0:colon_index]
rest_of_line = line[colon_index + 2 :].strip()
rest_of_line = line[colon_index + 2:].strip()
if len(rest_of_line) > 0:
body += rest_of_line + "\n"
comment_state = DBusXMLParser.COMMENT_STATE_PARAMS
@ -170,7 +170,7 @@ class DBusXMLParser:
body += orig_line + "\n"
else:
param = line[1:colon_index]
docs = line[colon_index + 2 :]
docs = line[colon_index + 2:]
params[param] = docs
else:
comment_state = DBusXMLParser.COMMENT_STATE_BODY
@ -230,7 +230,8 @@ class DBusXMLParser:
short_description = self.doc_comment_params["short_description"]
self._cur_object.doc_string_brief = short_description
if "since" in self.doc_comment_params:
self._cur_object.since = self.doc_comment_params["since"].strip()
self._cur_object.since = self.doc_comment_params["since"].strip(
)
elif self.state == DBusXMLParser.STATE_INTERFACE:
if name == DBusXMLParser.STATE_METHOD:
@ -262,7 +263,8 @@ class DBusXMLParser:
if "name" in attrs and self.doc_comment_last_symbol == attrs["name"]:
self._cur_object.doc_string = self.doc_comment_body
if "since" in self.doc_comment_params:
self._cur_object.since = self.doc_comment_params["since"].strip()
self._cur_object.since = self.doc_comment_params["since"].strip(
)
elif self.state == DBusXMLParser.STATE_METHOD:
if name == DBusXMLParser.STATE_ARG:
@ -277,7 +279,8 @@ class DBusXMLParser:
elif direction == "out":
self._cur_object.out_args.append(arg)
else:
raise ValueError('Invalid direction "{}"'.format(direction))
raise ValueError(
'Invalid direction "{}"'.format(direction))
self._cur_object = arg
elif name == DBusXMLParser.STATE_ANNOTATION:
self.state = DBusXMLParser.STATE_ANNOTATION

View File

@ -61,4 +61,3 @@ Following this example you should have an output like this.
Options:
--bar print bar
--foo print foo

View File

@ -9,4 +9,3 @@ Tutorial: Language Bindings
perl5/index
python3/index
ruby/index

View File

@ -7,4 +7,3 @@ Creating and configuring a session
.. literalinclude:: ../../tests/bindings/python3/session/create_base.py
:language: python
:linenos:

View File

@ -3,4 +3,3 @@ Ruby
.. note::
Work in progress

View File

@ -11,4 +11,3 @@ Tutorial
repos
queries
transaction

View File

@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
@ -111,7 +111,7 @@ modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@ -158,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
@ -267,7 +267,7 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
@ -422,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
@ -456,7 +456,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest

View File

@ -49,7 +49,8 @@ class Plugin(libdnf.plugin.IPlugin):
if plugin_hook_id == libdnf.plugin.HookId_LOAD_CONFIG_FROM_FILE:
logger = self.base.get_logger()
config = self.base.get_config()
logger.info(self.get_name() + ' - skip_if_unavailable = ' + str(config.skip_if_unavailable))
logger.info(self.get_name() + ' - skip_if_unavailable = ' +
str(config.skip_if_unavailable))
return True
def finish(self):

View File

@ -244,7 +244,7 @@ static std::string getItemIdentifier(CompsEnvironment * env) {
// auto comps_group = dynamic_cast<CompsGroup>(&ti);
// auto rpm = dynamic_cast<Package>(&ti);
std::string name;
if (itemType == TransactionItemType::RPM) {
auto rpm = std::dynamic_pointer_cast< Package >(item);

View File

@ -86,4 +86,4 @@ protected:
#endif // LIBDNF_TRANSACTION_TRANSACTION_HPP
#endif
#endif

View File

@ -80,4 +80,4 @@ private:
#endif
#endif
#endif

View File

@ -16,4 +16,4 @@
<size>1</size>
<open-size>1</open-size>
</data>
</repomd>
</repomd>

View File

@ -15,4 +15,4 @@
<timestamp>1641802880</timestamp>
<size>492</size>
</data>
</repomd>
</repomd>

View File

@ -16,4 +16,4 @@
<size>1</size>
<open-size>1</open-size>
</data>
</repomd>
</repomd>

View File

@ -15,4 +15,4 @@
<timestamp>1641802880</timestamp>
<size>492</size>
</data>
</repomd>
</repomd>

View File

@ -15,4 +15,4 @@
<timestamp>1641802880</timestamp>
<size>492</size>
</data>
</repomd>
</repomd>

View File

@ -15,4 +15,4 @@
<timestamp>1641802880</timestamp>
<size>492</size>
</data>
</repomd>
</repomd>

View File

@ -15,4 +15,4 @@
<timestamp>1641802880</timestamp>
<size>492</size>
</data>
</repomd>
</repomd>

View File

@ -15,4 +15,4 @@
<timestamp>1641802880</timestamp>
<size>492</size>
</data>
</repomd>
</repomd>

View File

@ -15,4 +15,4 @@
<timestamp>1641802880</timestamp>
<size>492</size>
</data>
</repomd>
</repomd>

View File

@ -15,4 +15,4 @@
<timestamp>1641802880</timestamp>
<size>492</size>
</data>
</repomd>
</repomd>

View File

@ -15,4 +15,4 @@
<timestamp>1641802880</timestamp>
<size>492</size>
</data>
</repomd>
</repomd>

View File

@ -32,4 +32,4 @@
<size>646</size>
<open-size>2510</open-size>
</data>
</repomd>
</repomd>

View File

@ -33,7 +33,8 @@ for repoid in os.listdir(TOPDIR):
data_nodes = root.findall('./data', namespaces=NAMESPACES)
for data in data_nodes:
# determine indexed file location
location = data.find("./location", namespaces=NAMESPACES).attrib["href"]
location = data.find(
"./location", namespaces=NAMESPACES).attrib["href"]
location = os.path.join(repo_dir, location)
# compute and store the current checksum

View File

@ -48,14 +48,15 @@ class InstallrootCase(unittest.TestCase):
if "replaces" in trans_item_attrs:
trans_item_attrs.pop("replaces")
def setUp(self):
super(InstallrootCase, self).setUp()
self.maxDiff = None
self.installroot = tempfile.mkdtemp(prefix="dnf5daemon-test-")
self.reposdir = os.path.join(PROJECT_BINARY_DIR, "test/data/repos-rpm-conf.d")
self.config_file_path = os.path.join(self.installroot, 'etc/dnf/dnf.conf')
self.reposdir = os.path.join(
PROJECT_BINARY_DIR, "test/data/repos-rpm-conf.d")
self.config_file_path = os.path.join(
self.installroot, 'etc/dnf/dnf.conf')
os.makedirs(os.path.dirname(self.config_file_path), exist_ok=True)
with open(self.config_file_path, 'w') as f:
f.write('')
@ -82,6 +83,5 @@ class InstallrootCase(unittest.TestCase):
self.bus.get_object(DNFDAEMON_BUS_NAME, self.session),
dbus_interface=IFACE_GOAL)
def tearDown(self):
shutil.rmtree(self.installroot)

View File

@ -21,20 +21,26 @@ import subprocess
import support
class DistroSyncTest(support.InstallrootCase):
def setUp(self):
super(DistroSyncTest, self).setUp()
# install a package inside the installroot
pkg_file = os.path.join(support.PROJECT_BINARY_DIR, "test/data/repos-rpm/rpm-repo1/one-1-1.noarch.rpm")
res = subprocess.run(["rpm", "--root", self.installroot, "-U", pkg_file])
self.assertEqual(res.returncode, 0, "Installation of test package '{}' failed.".format(pkg_file))
pkg_file = os.path.join(
support.PROJECT_BINARY_DIR, "test/data/repos-rpm/rpm-repo1/one-1-1.noarch.rpm")
res = subprocess.run(
["rpm", "--root", self.installroot, "-U", pkg_file])
self.assertEqual(
res.returncode, 0, "Installation of test package '{}' failed.".format(pkg_file))
def test_distro_sync_package(self):
# remove an installed package
self.iface_rpm.distro_sync(['one'], dbus.Dictionary({}, signature='sv'))
self.iface_rpm.distro_sync(
['one'], dbus.Dictionary({}, signature='sv'))
resolved, errors = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
resolved, errors = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.sanitize_transaction(resolved)
self.assertCountEqual(
@ -45,7 +51,7 @@ class DistroSyncTest(support.InstallrootCase):
dbus.String('Upgrade'), # action
dbus.String('External User'), # reason
dbus.Dictionary({ # transaction item attrs
}, signature=dbus.Signature('sv')),
}, signature=dbus.Signature('sv')),
dbus.Dictionary({ # package
dbus.String('evr'): dbus.String('2-1', variant_level=1),
dbus.String('name'): dbus.String('one', variant_level=1),
@ -57,14 +63,14 @@ class DistroSyncTest(support.InstallrootCase):
dbus.String('repo_id'): dbus.String('rpm-repo1', variant_level=1),
dbus.String('from_repo_id'): dbus.String('', variant_level=1),
dbus.String('reason'): dbus.String('External User', variant_level=1),
}, signature=dbus.Signature('sv'))),
}, signature=dbus.Signature('sv'))),
signature=None),
dbus.Struct((
dbus.String('Package'), # object type
dbus.String('Replaced'), # action
dbus.String('External User'), # reason
dbus.Dictionary({ # transaction item attrs
}, signature=dbus.Signature('sv')),
}, signature=dbus.Signature('sv')),
dbus.Dictionary({ # package
dbus.String('evr'): dbus.String('1-1', variant_level=1),
dbus.String('name'): dbus.String('one', variant_level=1),
@ -76,10 +82,10 @@ class DistroSyncTest(support.InstallrootCase):
dbus.String('repo_id'): dbus.String('@System', variant_level=1),
dbus.String('from_repo_id'): dbus.String('<unknown>', variant_level=1),
dbus.String('reason'): dbus.String('External User', variant_level=1),
}, signature=dbus.Signature('sv'))),
}, signature=dbus.Signature('sv'))),
signature=None)
], signature=dbus.Signature('(ua{sv})'))
)
], signature=dbus.Signature('(ua{sv})'))
)
self.iface_goal.do_transaction(dbus.Dictionary({}, signature='sv'))
@ -88,15 +94,17 @@ class DistroSyncTest(support.InstallrootCase):
attempt to distro-sync/upgrade package from repo that does not contain it returns
empty transaction
'''
self.iface_rpm.upgrade(['one'], dbus.Dictionary({'repo_ids': ['rpm-repo2']}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
self.iface_rpm.upgrade(['one'], dbus.Dictionary(
{'repo_ids': ['rpm-repo2']}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.assertEqual(result, 1)
self.assertEqual(
resolved,
dbus.Array([
], signature=dbus.Signature('(ua{sv})'))
)
], signature=dbus.Signature('(ua{sv})'))
)
errors = self.iface_goal.get_transaction_problems_string()
self.assertEqual(errors, dbus.Array([

View File

@ -21,20 +21,25 @@ import subprocess
import support
class DowngradeTest(support.InstallrootCase):
def setUp(self):
super(DowngradeTest, self).setUp()
# install a package inside the installroot
pkg_file = os.path.join(support.PROJECT_BINARY_DIR, "test/data/repos-rpm/rpm-repo1/one-2-1.noarch.rpm")
res = subprocess.run(["rpm", "--root", self.installroot, "-U", pkg_file])
self.assertEqual(res.returncode, 0, "Installation of test package '{}' failed.".format(pkg_file))
pkg_file = os.path.join(
support.PROJECT_BINARY_DIR, "test/data/repos-rpm/rpm-repo1/one-2-1.noarch.rpm")
res = subprocess.run(
["rpm", "--root", self.installroot, "-U", pkg_file])
self.assertEqual(
res.returncode, 0, "Installation of test package '{}' failed.".format(pkg_file))
def test_downgrade_package(self):
# remove an installed package
self.iface_rpm.downgrade(['one'], dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.sanitize_transaction(resolved)
self.assertEqual(result, 0)
@ -46,7 +51,7 @@ class DowngradeTest(support.InstallrootCase):
dbus.String('Downgrade'), # action
dbus.String('External User'), # reason
dbus.Dictionary({ # transaction item attrs
}, signature=dbus.Signature('sv')),
}, signature=dbus.Signature('sv')),
dbus.Dictionary({ # package
dbus.String('evr'): dbus.String('1-1', variant_level=1),
dbus.String('name'): dbus.String('one', variant_level=1),
@ -58,14 +63,14 @@ class DowngradeTest(support.InstallrootCase):
dbus.String('repo_id'): dbus.String('rpm-repo1', variant_level=1),
dbus.String('from_repo_id'): dbus.String('', variant_level=1),
dbus.String('reason'): dbus.String('External User', variant_level=1),
}, signature=dbus.Signature('sv'))),
}, signature=dbus.Signature('sv'))),
signature=None),
dbus.Struct((
dbus.String('Package'), # object type
dbus.String('Replaced'), # action
dbus.String('External User'), # reason
dbus.Dictionary({ # transaction item attrs
}, signature=dbus.Signature('sv')),
}, signature=dbus.Signature('sv')),
dbus.Dictionary({ # package
dbus.String('evr'): dbus.String('2-1', variant_level=1),
dbus.String('name'): dbus.String('one', variant_level=1),
@ -77,10 +82,10 @@ class DowngradeTest(support.InstallrootCase):
dbus.String('repo_id'): dbus.String('@System', variant_level=1),
dbus.String('from_repo_id'): dbus.String('<unknown>', variant_level=1),
dbus.String('reason'): dbus.String('External User', variant_level=1),
}, signature=dbus.Signature('sv'))),
}, signature=dbus.Signature('sv'))),
signature=None)
], signature=dbus.Signature('(ua{sv})'))
)
], signature=dbus.Signature('(ua{sv})'))
)
self.iface_goal.do_transaction(dbus.Dictionary({}, signature='sv'))
@ -89,15 +94,17 @@ class DowngradeTest(support.InstallrootCase):
attempt to upgrade package from repo that does not contain it returns
empty transaction
'''
self.iface_rpm.downgrade(['one'], dbus.Dictionary({'repo_ids': ['rpm-repo2']}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
self.iface_rpm.downgrade(['one'], dbus.Dictionary(
{'repo_ids': ['rpm-repo2']}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.assertEqual(result, 1)
self.assertCountEqual(
resolved,
dbus.Array([
], signature=dbus.Signature('(ua{sv})'))
)
], signature=dbus.Signature('(ua{sv})'))
)
errors = self.iface_goal.get_transaction_problems_string()
self.assertEqual(errors, dbus.Array([

View File

@ -19,13 +19,15 @@ import dbus
import support
class InstallTest(support.InstallrootCase):
def test_install_package(self):
# install a package
self.iface_rpm.install(['one'], dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.sanitize_transaction(resolved)
self.assertEqual(result, 0)
@ -37,7 +39,7 @@ class InstallTest(support.InstallrootCase):
dbus.String('Install'), # action
dbus.String('User'), # reason
dbus.Dictionary({ # transaction item attrs
}, signature=dbus.Signature('sv')),
}, signature=dbus.Signature('sv')),
dbus.Dictionary({ # package
dbus.String('arch'): dbus.String('noarch', variant_level=1),
dbus.String('epoch'): dbus.String('0', variant_level=1),
@ -49,24 +51,26 @@ class InstallTest(support.InstallrootCase):
dbus.String('version'): dbus.String('2', variant_level=1),
dbus.String('from_repo_id'): dbus.String('', variant_level=1),
dbus.String('reason'): dbus.String('None', variant_level=1),
}, signature=dbus.Signature('sv'))),
}, signature=dbus.Signature('sv'))),
signature=None)
], signature=dbus.Signature('(ua{sv})'))
)
], signature=dbus.Signature('(ua{sv})'))
)
self.iface_goal.do_transaction(dbus.Dictionary({}, signature='sv'))
def test_install_no_skip_unavailable(self):
'''with skip_unavailable=False attempt to install nonexistent package returns error'''
self.iface_rpm.install(['no_one'], dbus.Dictionary({'skip_unavailable': False}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
self.iface_rpm.install(['no_one'], dbus.Dictionary(
{'skip_unavailable': False}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.assertEqual(result, 2)
self.assertCountEqual(
resolved,
dbus.Array([
], signature=dbus.Signature('(ua{sv})'))
)
], signature=dbus.Signature('(ua{sv})'))
)
errors = self.iface_goal.get_transaction_problems_string()
self.assertEqual(errors, dbus.Array([
@ -77,16 +81,18 @@ class InstallTest(support.InstallrootCase):
with skip_unavailable=True attempt to install nonexistent package returns empty
transaction
'''
self.iface_rpm.install(['no_one'], dbus.Dictionary({'skip_unavailable': True}, signature='sv'))
self.iface_rpm.install(['no_one'], dbus.Dictionary(
{'skip_unavailable': True}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.assertEqual(result, 1)
self.assertCountEqual(
resolved,
dbus.Array([
], signature=dbus.Signature('(ua{sv})'))
)
], signature=dbus.Signature('(ua{sv})'))
)
errors = self.iface_goal.get_transaction_problems_string()
self.assertEqual(errors, dbus.Array([
@ -96,15 +102,17 @@ class InstallTest(support.InstallrootCase):
'''
attempt to install package from repo that does not contain it return error
'''
self.iface_rpm.install(['one'], dbus.Dictionary({'repo_ids': ['rpm-repo2']}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
self.iface_rpm.install(['one'], dbus.Dictionary(
{'repo_ids': ['rpm-repo2']}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.assertEqual(result, 2)
self.assertCountEqual(
resolved,
dbus.Array([
], signature=dbus.Signature("(ua{sv})")),
)
], signature=dbus.Signature("(ua{sv})")),
)
errors = self.iface_goal.get_transaction_problems_string()
self.assertEqual(errors, dbus.Array([

View File

@ -21,20 +21,25 @@ import subprocess
import support
class ReinstallTest(support.InstallrootCase):
def setUp(self):
super(ReinstallTest, self).setUp()
# install a package inside the installroot
pkg_file = os.path.join(support.PROJECT_BINARY_DIR, "test/data/repos-rpm/rpm-repo1/one-1-1.noarch.rpm")
res = subprocess.run(["rpm", "--root", self.installroot, "-U", pkg_file])
self.assertEqual(res.returncode, 0, "Installation of test package '{}' failed.".format(pkg_file))
pkg_file = os.path.join(
support.PROJECT_BINARY_DIR, "test/data/repos-rpm/rpm-repo1/one-1-1.noarch.rpm")
res = subprocess.run(
["rpm", "--root", self.installroot, "-U", pkg_file])
self.assertEqual(
res.returncode, 0, "Installation of test package '{}' failed.".format(pkg_file))
def test_reinstall_package(self):
# reinstall an installed package
self.iface_rpm.reinstall(['one'], dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.sanitize_transaction(resolved)
self.assertEqual(result, 0)
@ -46,7 +51,7 @@ class ReinstallTest(support.InstallrootCase):
dbus.String('Reinstall'), # action
dbus.String('External User'), # reason
dbus.Dictionary({ # transaction item attrs
}, signature=dbus.Signature('sv')),
}, signature=dbus.Signature('sv')),
dbus.Dictionary({ # package
dbus.String('evr'): dbus.String('1-1', variant_level=1),
dbus.String('name'): dbus.String('one', variant_level=1),
@ -58,14 +63,14 @@ class ReinstallTest(support.InstallrootCase):
dbus.String('repo_id'): dbus.String('rpm-repo1', variant_level=1),
dbus.String('from_repo_id'): dbus.String('', variant_level=1),
dbus.String('reason'): dbus.String('External User', variant_level=1),
}, signature=dbus.Signature('sv'))),
}, signature=dbus.Signature('sv'))),
signature=None),
dbus.Struct((
dbus.String('Package'), # object type
dbus.String('Replaced'), # action
dbus.String('External User'), # reason
dbus.Dictionary({ # transaction item attrs
}, signature=dbus.Signature('sv')),
}, signature=dbus.Signature('sv')),
dbus.Dictionary({ # package
dbus.String('evr'): dbus.String('1-1', variant_level=1),
dbus.String('name'): dbus.String('one', variant_level=1),
@ -77,9 +82,9 @@ class ReinstallTest(support.InstallrootCase):
dbus.String('repo_id'): dbus.String('@System', variant_level=1),
dbus.String('from_repo_id'): dbus.String('<unknown>', variant_level=1),
dbus.String('reason'): dbus.String('External User', variant_level=1),
}, signature=dbus.Signature('sv'))),
}, signature=dbus.Signature('sv'))),
signature=None)
], signature=dbus.Signature('(ua{sv})')),
], signature=dbus.Signature('(ua{sv})')),
)
self.iface_goal.do_transaction(dbus.Dictionary({}, signature='sv'))
@ -89,15 +94,17 @@ class ReinstallTest(support.InstallrootCase):
attempt to reinstall package from repo that does not contain it returns
empty transaction
'''
self.iface_rpm.reinstall(['one'], dbus.Dictionary({'repo_ids': ['rpm-repo2']}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
self.iface_rpm.reinstall(['one'], dbus.Dictionary(
{'repo_ids': ['rpm-repo2']}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.assertEqual(result, 2)
self.assertCountEqual(
resolved,
dbus.Array([
], signature=dbus.Signature('(ua{sv})'))
)
], signature=dbus.Signature('(ua{sv})'))
)
errors = self.iface_goal.get_transaction_problems_string()
self.assertEqual(errors, dbus.Array([
@ -109,15 +116,17 @@ class ReinstallTest(support.InstallrootCase):
attempt to reinstall package available but not installed returns empty
transaction
'''
self.iface_rpm.reinstall(['two'], dbus.Dictionary({'repo_ids': ['rpm-repo2']}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
self.iface_rpm.reinstall(['two'], dbus.Dictionary(
{'repo_ids': ['rpm-repo2']}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.assertEqual(result, 2)
self.assertCountEqual(
resolved,
dbus.Array([
], signature=dbus.Signature('(ua{sv})'))
)
], signature=dbus.Signature('(ua{sv})'))
)
errors = self.iface_goal.get_transaction_problems_string()
self.assertEqual(errors, dbus.Array([
@ -129,15 +138,17 @@ class ReinstallTest(support.InstallrootCase):
attempt to reinstall package from repo that does not exist it returns
empty transaction
'''
self.iface_rpm.reinstall(['three'], dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
self.iface_rpm.reinstall(
['three'], dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.assertEqual(result, 2)
self.assertCountEqual(
resolved,
dbus.Array([
], signature=dbus.Signature('(ua{sv})'))
)
], signature=dbus.Signature('(ua{sv})'))
)
errors = self.iface_goal.get_transaction_problems_string()
self.assertEqual(errors, dbus.Array([

View File

@ -21,20 +21,25 @@ import subprocess
import support
class RemoveTest(support.InstallrootCase):
def setUp(self):
super(RemoveTest, self).setUp()
# install a package inside the installroot
pkg_file = os.path.join(support.PROJECT_BINARY_DIR, "test/data/repos-rpm/rpm-repo1/one-1-1.noarch.rpm")
res = subprocess.run(["rpm", "--root", self.installroot, "-U", pkg_file])
self.assertEqual(res.returncode, 0, "Installation of test package '{}' failed.".format(pkg_file))
pkg_file = os.path.join(
support.PROJECT_BINARY_DIR, "test/data/repos-rpm/rpm-repo1/one-1-1.noarch.rpm")
res = subprocess.run(
["rpm", "--root", self.installroot, "-U", pkg_file])
self.assertEqual(
res.returncode, 0, "Installation of test package '{}' failed.".format(pkg_file))
def test_remove_package(self):
# remove an installed package
self.iface_rpm.remove(['one'], dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.sanitize_transaction(resolved)
self.assertEqual(result, 0)
@ -46,7 +51,7 @@ class RemoveTest(support.InstallrootCase):
dbus.String('Remove'), # action
dbus.String('User'), # reason
dbus.Dictionary({ # transaction item attrs
}, signature=dbus.Signature('sv')),
}, signature=dbus.Signature('sv')),
dbus.Dictionary({ # package
dbus.String('arch'): dbus.String('noarch', variant_level=1),
dbus.String('epoch'): dbus.String('0', variant_level=1),
@ -58,9 +63,9 @@ class RemoveTest(support.InstallrootCase):
dbus.String('version'): dbus.String('1', variant_level=1),
dbus.String('from_repo_id'): dbus.String('<unknown>', variant_level=1),
dbus.String('reason'): dbus.String('External User', variant_level=1),
}, signature=dbus.Signature('sv'))),
}, signature=dbus.Signature('sv'))),
signature=None)
], signature=dbus.Signature('(ua{sv})'))
)
], signature=dbus.Signature('(ua{sv})'))
)
self.iface_goal.do_transaction(dbus.Dictionary({}, signature='sv'))

View File

@ -75,7 +75,7 @@ class RepoConfTest(support.InstallrootCase):
dbus.String('name'): dbus.String('Repository 2', variant_level=1),
dbus.String('repoid'): dbus.String('rpm-repo2', variant_level=1)},
signature=dbus.Signature('sv'))
], signature=dbus.Signature('a{sv}'))
], signature=dbus.Signature('a{sv}'))
)
# filter several repositories
self.assertEqual(
@ -99,13 +99,13 @@ class RepoConfTest(support.InstallrootCase):
dbus.String('name'): dbus.String('Repository 2', variant_level=1),
dbus.String('repoid'): dbus.String('rpm-repo2', variant_level=1)},
signature=dbus.Signature('sv'))
], signature=dbus.Signature('a{sv}'))
], signature=dbus.Signature('a{sv}'))
)
# filter non-existent repositories
self.assertEqual(
self.iface_repoconf.list({'ids': ['nonrepo-1', 'nonrepo-2']}),
dbus.Array([
], signature=dbus.Signature('a{sv}')))
], signature=dbus.Signature('a{sv}')))
def test_get_repository(self):
self.assertEqual(
@ -127,7 +127,8 @@ class RepoConfTest(support.InstallrootCase):
# disable repo
self.assertEqual(
self.iface_repoconf.disable(['main_repo']),
dbus.Array([dbus.String('main_repo')], signature=dbus.Signature('s'))
dbus.Array([dbus.String('main_repo')],
signature=dbus.Signature('s'))
)
self.assertEqual(
self.iface_repoconf.get('main_repo'),
@ -141,7 +142,8 @@ class RepoConfTest(support.InstallrootCase):
# enable repo
self.assertEqual(
self.iface_repoconf.enable(['main_repo']),
dbus.Array([dbus.String('main_repo')], signature=dbus.Signature('s'))
dbus.Array([dbus.String('main_repo')],
signature=dbus.Signature('s'))
)
self.assertEqual(
self.iface_repoconf.get('main_repo'),

View File

@ -20,6 +20,7 @@ import os
import support
class RepoTest(support.InstallrootCase):
def test_list_repos(self):
@ -37,22 +38,21 @@ class RepoTest(support.InstallrootCase):
dbus.String('enabled'): dbus.Boolean(True, variant_level=1),
dbus.String('id'): dbus.String('rpm-repo2', variant_level=1)},
signature=dbus.Signature('sv')),
],
],
signature=dbus.Signature('a{sv}'))
)
def test_list_repos_spec(self):
# get list of specified repositories
self.assertEqual(
self.iface_repo.list(
{"repo_attrs": ["name", "enabled"], "patterns": ['rpm-repo1']}),
{"repo_attrs": ["name", "enabled"], "patterns": ['rpm-repo1']}),
dbus.Array([
dbus.Dictionary({
dbus.String('name'): dbus.String('Repository 1', variant_level=1),
dbus.String('enabled'): dbus.Boolean(True, variant_level=1),
dbus.String('id'): dbus.String('rpm-repo1', variant_level=1)},
signature=dbus.Signature('sv')),
],
],
signature=dbus.Signature('a{sv}'))
)

View File

@ -20,11 +20,13 @@ import os
import support
class RepoTest(support.InstallrootCase):
def test_repoquery_all(self):
# get list of all available packages
pkglist = self.iface_rpm.list({"package_attrs": ["full_nevra", "repo_id"]})
pkglist = self.iface_rpm.list(
{"package_attrs": ["full_nevra", "repo_id"]})
# id of package depends on order of the repos in the sack which varies
# between runs so we can't rely on the value
for pkg in pkglist:
@ -57,7 +59,7 @@ class RepoTest(support.InstallrootCase):
dbus.String('full_nevra'): dbus.String('two-0:2-2.src', variant_level=1),
dbus.String('repo_id'): dbus.String('rpm-repo2', variant_level=1)},
signature=dbus.Signature('sv')),
],
],
signature=dbus.Signature('a{sv}'))
)
@ -65,7 +67,7 @@ class RepoTest(support.InstallrootCase):
# get list of all available packages
pkglist = self.iface_rpm.list({
"package_attrs": ["full_nevra", "repo_id"],
"patterns":["one"]})
"patterns": ["one"]})
# id of package depends on order of the repos in the sack which varies
# between runs so we can't rely on the value
for pkg in pkglist:
@ -91,5 +93,5 @@ class RepoTest(support.InstallrootCase):
dbus.String('repo_id'): dbus.String('rpm-repo1', variant_level=1)},
signature=dbus.Signature('sv')),
],
signature=dbus.Signature('a{sv}'))
signature=dbus.Signature('a{sv}'))
)

View File

@ -20,6 +20,7 @@ import unittest
import support
class SessionTest(unittest.TestCase):
def setUp(self):
@ -35,8 +36,10 @@ class SessionTest(unittest.TestCase):
def test_session(self):
session = self.iface.open_session({})
# session address has expected format
self.assertRegex(session, r'^%s/[0-9a-f]{32}$' % support.DNFDAEMON_OBJECT_PATH)
self.assertRegex(
session, r'^%s/[0-9a-f]{32}$' % support.DNFDAEMON_OBJECT_PATH)
# close the session
self.assertEqual(dbus.Boolean(True), self.iface.close_session(session))
# closing non-existent session returns False
self.assertEqual(dbus.Boolean(False), self.iface.close_session(session))
self.assertEqual(dbus.Boolean(False),
self.iface.close_session(session))

View File

@ -21,20 +21,25 @@ import subprocess
import support
class UpgradeTest(support.InstallrootCase):
def setUp(self):
super(UpgradeTest, self).setUp()
# install a package inside the installroot
pkg_file = os.path.join(support.PROJECT_BINARY_DIR, "test/data/repos-rpm/rpm-repo1/one-1-1.noarch.rpm")
res = subprocess.run(["rpm", "--root", self.installroot, "-U", pkg_file])
self.assertEqual(res.returncode, 0, "Installation of test package '{}' failed.".format(pkg_file))
pkg_file = os.path.join(
support.PROJECT_BINARY_DIR, "test/data/repos-rpm/rpm-repo1/one-1-1.noarch.rpm")
res = subprocess.run(
["rpm", "--root", self.installroot, "-U", pkg_file])
self.assertEqual(
res.returncode, 0, "Installation of test package '{}' failed.".format(pkg_file))
def test_upgrade_package(self):
# remove an installed package
self.iface_rpm.upgrade(['one'], dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.sanitize_transaction(resolved)
self.assertEqual(result, 0)
@ -46,7 +51,7 @@ class UpgradeTest(support.InstallrootCase):
dbus.String('Upgrade'), # action
dbus.String('External User'), # reason
dbus.Dictionary({ # transaction item attrs
}, signature=dbus.Signature('sv')),
}, signature=dbus.Signature('sv')),
dbus.Dictionary({ # package
dbus.String('evr'): dbus.String('2-1', variant_level=1),
dbus.String('name'): dbus.String('one', variant_level=1),
@ -58,14 +63,14 @@ class UpgradeTest(support.InstallrootCase):
dbus.String('repo_id'): dbus.String('rpm-repo1', variant_level=1),
dbus.String('from_repo_id'): dbus.String('', variant_level=1),
dbus.String('reason'): dbus.String('External User', variant_level=1),
}, signature=dbus.Signature('sv'))),
}, signature=dbus.Signature('sv'))),
signature=None),
dbus.Struct((
dbus.String('Package'), # object type
dbus.String('Replaced'), # action
dbus.String('External User'), # reason
dbus.Dictionary({ # transaction item attrs
}, signature=dbus.Signature('sv')),
}, signature=dbus.Signature('sv')),
dbus.Dictionary({ # package
dbus.String('evr'): dbus.String('1-1', variant_level=1),
dbus.String('name'): dbus.String('one', variant_level=1),
@ -77,10 +82,10 @@ class UpgradeTest(support.InstallrootCase):
dbus.String('repo_id'): dbus.String('@System', variant_level=1),
dbus.String('from_repo_id'): dbus.String('<unknown>', variant_level=1),
dbus.String('reason'): dbus.String('External User', variant_level=1),
}, signature=dbus.Signature('sv'))),
}, signature=dbus.Signature('sv'))),
signature=None)
], signature=dbus.Signature('(ua{sv})'))
)
], signature=dbus.Signature('(ua{sv})'))
)
self.iface_goal.do_transaction(dbus.Dictionary({}, signature='sv'))
@ -89,15 +94,17 @@ class UpgradeTest(support.InstallrootCase):
attempt to upgrade package from repo that does not contain it returns
empty transaction
'''
self.iface_rpm.upgrade(['one'], dbus.Dictionary({'repo_ids': ['rpm-repo2']}, signature='sv'))
resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv'))
self.iface_rpm.upgrade(['one'], dbus.Dictionary(
{'repo_ids': ['rpm-repo2']}, signature='sv'))
resolved, result = self.iface_goal.resolve(
dbus.Dictionary({}, signature='sv'))
self.assertEqual(result, 1)
self.assertCountEqual(
resolved,
dbus.Array([
], signature=dbus.Signature('(ua{sv})')),
)
], signature=dbus.Signature('(ua{sv})')),
)
errors = self.iface_goal.get_transaction_problems_string()
self.assertEqual(errors, dbus.Array([

View File

@ -49,9 +49,9 @@ class TestBase(unittest.TestCase):
# Base object is invalid. -> Both WeakPtr are invalid. The code must throw an exception.
# Raises an AssertionError that is not caught by the SWIG binding.
#with self.assertRaisesRegex(RuntimeError, 'Dereferencing an invalidated WeakPtr'):
# with self.assertRaisesRegex(RuntimeError, 'Dereferencing an invalidated WeakPtr'):
# vars.get_value("test_variable")
#with self.assertRaisesRegex(RuntimeError, 'Dereferencing an invalidated WeakPtr'):
# with self.assertRaisesRegex(RuntimeError, 'Dereferencing an invalidated WeakPtr'):
# vars2.get_value("test_variable")
def test_missing_setup_goal_resolve(self):

View File

@ -64,20 +64,22 @@ class BaseTestCase(unittest.TestCase):
"""
Add a repo from PROJECT_SOURCE_DIR/test/data/repos-repomd/<repoid>/repodata
"""
repo_path = os.path.join(PROJECT_SOURCE_DIR, "test/data/repos-repomd", repoid)
repo_path = os.path.join(
PROJECT_SOURCE_DIR, "test/data/repos-repomd", repoid)
return self._add_repo(repoid, repo_path, load)
def add_repo_rpm(self, repoid, load=True):
"""
Add a repo from PROJECT_BINARY_DIR/test/data/repos-rpm/<repoid>/repodata
"""
repo_path = os.path.join(PROJECT_BINARY_DIR, "test/data/repos-rpm", repoid)
repo_path = os.path.join(
PROJECT_BINARY_DIR, "test/data/repos-rpm", repoid)
return self._add_repo(repoid, repo_path, load)
def add_repo_solv(self, repoid):
"""
Add a repo from PROJECT_SOURCE_DIR/test/data/repos-solv/<repoid>.repo
"""
repo_path = os.path.join(PROJECT_SOURCE_DIR, "test/data/repos-solv", repoid + ".repo")
repo_path = os.path.join(
PROJECT_SOURCE_DIR, "test/data/repos-solv", repoid + ".repo")
return self.repo_sack.create_repo_from_libsolv_testcase(repoid, repo_path)

View File

@ -25,7 +25,7 @@ class TestCompsIterators(base_test_case.BaseTestCase):
def test_group_query_iterable(self):
query = libdnf5.comps.GroupQuery(self.base)
_ = [grp.get_groupid() for grp in query]
def test_environment_query_iterable(self):
query = libdnf5.comps.EnvironmentQuery(self.base)
_ = [env.get_environmentid() for env in query]

View File

@ -23,11 +23,13 @@ import base_test_case
class TestConfigurationOptions(base_test_case.BaseTestCase):
def test_set_with_runtime_priority(self):
proxy = self.base.get_config().get_proxy_option()
self.assertEqual(proxy.get_priority(), libdnf5.conf.Option.Priority_DEFAULT)
self.assertEqual(proxy.get_priority(),
libdnf5.conf.Option.Priority_DEFAULT)
proxy.set('abcd')
self.assertEqual(proxy.get_value(), 'abcd')
self.assertEqual(proxy.get_priority(), libdnf5.conf.Option.Priority_RUNTIME)
self.assertEqual(proxy.get_priority(),
libdnf5.conf.Option.Priority_RUNTIME)
def test_container_add_item(self):
auths_config = self.base.get_config().get_proxy_auth_method_option()
@ -38,15 +40,18 @@ class TestConfigurationOptions(base_test_case.BaseTestCase):
def test_container_add(self):
types_config = self.base.get_config().get_optional_metadata_types_option()
types_config.set((libdnf5.conf.METADATA_TYPE_FILELISTS,))
types_config.add((libdnf5.conf.METADATA_TYPE_COMPS, libdnf5.conf.METADATA_TYPE_UPDATEINFO))
self.assertEqual(types_config.get_value(), (libdnf5.conf.METADATA_TYPE_COMPS, libdnf5.conf.METADATA_TYPE_FILELISTS, libdnf5.conf.METADATA_TYPE_UPDATEINFO))
types_config.add((libdnf5.conf.METADATA_TYPE_COMPS,
libdnf5.conf.METADATA_TYPE_UPDATEINFO))
self.assertEqual(types_config.get_value(), (libdnf5.conf.METADATA_TYPE_COMPS,
libdnf5.conf.METADATA_TYPE_FILELISTS, libdnf5.conf.METADATA_TYPE_UPDATEINFO))
def test_set_by_attribute(self):
config = self.base.get_config()
config.comment = 'some comment'
comment_option = config.get_comment_option()
self.assertEqual(comment_option.get_value(), 'some comment')
self.assertEqual(comment_option.get_priority(), libdnf5.conf.Option.Priority_RUNTIME)
self.assertEqual(comment_option.get_priority(),
libdnf5.conf.Option.Priority_RUNTIME)
def test_get_by_attribute(self):
config = self.base.get_config()

View File

@ -28,7 +28,8 @@ class libdnf5LoggerCB1(libdnf5.logger.Logger):
self._stream = stream
def log_line(self, level, message):
self._stream.write("{}: {}\n".format(self.level_to_cstr(level), message))
self._stream.write("{}: {}\n".format(
self.level_to_cstr(level), message))
def write(self, time, pid, level, message):
self._stream.write("Bad message\n")
@ -41,7 +42,8 @@ class libdnf5LoggerCB2(libdnf5.logger.Logger):
self._stream = stream
def write(self, time, pid, level, message):
self._stream.write("{}: {}\n".format(self.level_to_cstr(level), message))
self._stream.write("{}: {}\n".format(
self.level_to_cstr(level), message))
class TestLoggers(unittest.TestCase):
@ -92,7 +94,8 @@ class TestLoggers(unittest.TestCase):
# Create circular memory buffer logger with capacity 10 messages (4 pre-allocated from start).
max_items_to_keep = 10
reserve = 4
memory_buffer_logger = libdnf5.logger.MemoryBufferLogger(max_items_to_keep, reserve)
memory_buffer_logger = libdnf5.logger.MemoryBufferLogger(
max_items_to_keep, reserve)
logger_uniq_ptr = libdnf5.logger.LoggerUniquePtr(memory_buffer_logger)
log_router.add_logger(logger_uniq_ptr)
@ -103,10 +106,13 @@ class TestLoggers(unittest.TestCase):
# 2. Write messages into log_router. They will be routed into memory_buffer_logger.
# ====================
for i in range(2):
log_router.log(libdnf5.logger.Logger.Level_CRITICAL, "Critical message")
log_router.log(libdnf5.logger.Logger.Level_CRITICAL,
"Critical message")
log_router.log(libdnf5.logger.Logger.Level_ERROR, "Error message")
log_router.log(libdnf5.logger.Logger.Level_WARNING, "Warning message")
log_router.log(libdnf5.logger.Logger.Level_NOTICE, "Notice message")
log_router.log(libdnf5.logger.Logger.Level_WARNING,
"Warning message")
log_router.log(libdnf5.logger.Logger.Level_NOTICE,
"Notice message")
log_router.log(libdnf5.logger.Logger.Level_INFO, "Info message")
log_router.log(libdnf5.logger.Logger.Level_DEBUG, "Debug message")
log_router.log(libdnf5.logger.Logger.Level_TRACE, "Trace message")
@ -144,7 +150,8 @@ class TestLoggers(unittest.TestCase):
# ====================
# 5. Write aditional message into LogRouter instance.
# ====================
log_router.log(libdnf5.logger.Logger.Level_INFO, "Info additional message")
log_router.log(libdnf5.logger.Logger.Level_INFO,
"Info additional message")
# ====================
# 6. Check content of streams of both StreamLogger instances.

View File

@ -58,7 +58,8 @@ class TestPackageDownloader(base_test_case.BaseTestCase):
return 0
cbs = PackageDownloadCallbacks()
self.base.set_download_callbacks(libdnf5.repo.DownloadCallbacksUniquePtr(cbs))
self.base.set_download_callbacks(
libdnf5.repo.DownloadCallbacksUniquePtr(cbs))
downloader.add(query.begin().value())
@ -69,7 +70,8 @@ class TestPackageDownloader(base_test_case.BaseTestCase):
gc.collect()
self.assertEqual(cbs.end_cnt, 1)
self.assertEqual(cbs.end_status, PackageDownloadCallbacks.TransferStatus_SUCCESSFUL)
self.assertEqual(
cbs.end_status, PackageDownloadCallbacks.TransferStatus_SUCCESSFUL)
self.assertEqual(cbs.end_msg, None)
self.assertGreaterEqual(cbs.progress_cnt, 1)

View File

@ -27,7 +27,6 @@ class TestRepo(base_test_case.BaseTestCase):
# TODO(lukash) there's no rpmdb in the installroot, create data for the test
self.repo_sack.get_system_repo().load()
def test_load_repo(self):
repoid = "repomd-repo1"
repo = self.add_repo_repomd(repoid, load=False)

View File

@ -26,44 +26,47 @@ class TestRepoQuery(base_test_case.BaseTestCase):
def test_repo_query(self):
# Creates new repositories in the repo_sack
repo1 = self.repo_sack.create_repo("repo1")
repo1.enable();
repo1.enable()
repo1.get_config().baseurl = "file:///path/to/repo1"
repo2 = self.repo_sack.create_repo("repo2")
repo2.disable();
repo2.disable()
repo2.get_config().baseurl = "https://host/path/to/repo2"
repo1_updates = self.repo_sack.create_repo("repo1_updates")
repo1_updates.disable();
repo1_updates.disable()
repo1_updates.get_config().baseurl = "https://host/path/to/repo1_updates"
repo2_updates = self.repo_sack.create_repo("repo2_updates")
repo2_updates.enable();
repo2_updates.enable()
repo2_updates.get_config().baseurl = "https://host/path/to/repo2_updates"
# create a RepoQuery and test that it contains expected repos
repo_query = libdnf5.repo.RepoQuery(self.base)
self.assertEqual(repo_query.size(), 4)
self.assertEqual(len(repo_query), 4)
self.assertEqual(set(repo_query), {repo1, repo2, repo1_updates, repo2_updates})
self.assertEqual(set(repo_query), {
repo1, repo2, repo1_updates, repo2_updates})
# Tests filter_enabled method
repo_query.filter_enabled(True);
repo_query.filter_enabled(True)
self.assertEqual(set(repo_query), {repo1, repo2_updates})
# Tests filter_id method
repo_query1 = libdnf5.repo.RepoQuery(self.base)
repo_query1.filter_id("*updates", libdnf5.common.QueryCmp_GLOB);
repo_query1.filter_id("*updates", libdnf5.common.QueryCmp_GLOB)
self.assertEqual(set(repo_query1), {repo1_updates, repo2_updates})
# Tests filter_local method
repo_query2 = libdnf5.repo.RepoQuery(self.base)
repo_query2.filter_local(False);
self.assertEqual(set(repo_query2), {repo2, repo1_updates, repo2_updates})
repo_query2.filter_local(False)
self.assertEqual(set(repo_query2), {
repo2, repo1_updates, repo2_updates})
# Tests iteration over RepoQuery object
repo_query3 = libdnf5.repo.RepoQuery(self.base)
result = set()
for repo in repo_query3:
result.add(repo.get_id())
self.assertEqual(result, {"repo1", "repo2", "repo1_updates", "repo2_updates"})
self.assertEqual(
result, {"repo1", "repo2", "repo1_updates", "repo2_updates"})

View File

@ -68,7 +68,8 @@ class TestPackageQuery(base_test_case.BaseTestCase):
self.assertGreater(id, prev_id)
prev_id = id
self.assertLess(prev_id, self.package_sack.get_nsolvables())
self.assertGreaterEqual(prev_id, libdnf5.rpm.PackageQuery(self.base).size())
self.assertGreaterEqual(
prev_id, libdnf5.rpm.PackageQuery(self.base).size())
# Another test. The iterator is created from the "query" reference, but the reference
# is removed (set to "None") before starting the iteration.
@ -85,7 +86,8 @@ class TestPackageQuery(base_test_case.BaseTestCase):
except StopIteration:
break
self.assertLess(prev_id, self.package_sack.get_nsolvables())
self.assertGreaterEqual(prev_id, libdnf5.rpm.PackageQuery(self.base).size())
self.assertGreaterEqual(
prev_id, libdnf5.rpm.PackageQuery(self.base).size())
def test_filter_name(self):
# Test QueryCmp::EQ
@ -102,7 +104,8 @@ class TestPackageQuery(base_test_case.BaseTestCase):
query.filter_name(["pk*"], libdnf5.common.QueryCmp_GLOB)
self.assertEqual(query.size(), 2)
# TODO(dmach): implement __str__()
self.assertEqual([i.get_nevra() for i in query], ["pkg-1.2-3.x86_64", "pkg-libs-1:1.3-4.x86_64"])
self.assertEqual([i.get_nevra() for i in query], [
"pkg-1.2-3.x86_64", "pkg-libs-1:1.3-4.x86_64"])
def test_resolve_pkg_spec(self):
# Test passing empty forms
@ -112,13 +115,14 @@ class TestPackageQuery(base_test_case.BaseTestCase):
match, nevra = query.resolve_pkg_spec("pkg*", settings, True)
self.assertEqual(query.size(), 2)
self.assertEqual([i.get_nevra() for i in query], ["pkg-1.2-3.x86_64", "pkg-libs-1:1.3-4.x86_64"])
self.assertEqual([i.get_nevra() for i in query], [
"pkg-1.2-3.x86_64", "pkg-libs-1:1.3-4.x86_64"])
self.assertTrue(match)
self.assertEqual(nevra.get_name(), "pkg*")
self.assertTrue(nevra.has_just_name())
# Test passing an explicit list of forms
query = libdnf5.rpm.PackageQuery(self.base)
query = libdnf5.rpm.PackageQuery(self.base)
settings = libdnf5.base.ResolveSpecSettings()
settings.nevra_forms.append(libdnf5.rpm.Nevra.Form_NA)
@ -136,7 +140,8 @@ class TestPackageQuery(base_test_case.BaseTestCase):
query = libdnf5.rpm.PackageQuery(self.base)
query.filter_name(["pkg"])
package = next(iter(query))
self.assertEqual(package.get_reason(), libdnf5.transaction.TransactionItemReason_NONE)
self.assertEqual(package.get_reason(),
libdnf5.transaction.TransactionItemReason_NONE)
def test_pkg_query_without_setup(self):
# Create a new Base object

View File

@ -50,7 +50,8 @@ class TestReldepList(base_test_case.BaseTestCase):
list1.add(c)
self.assertEqual(list1.get(0), a)
self.assertEqual(list1.get(1).to_string(), "(lab-list if labirinto.txt)")
self.assertEqual(list1.get(1).to_string(),
"(lab-list if labirinto.txt)")
self.assertEqual(list1.get_id(2).id, c.get_id().id)
def test_compare(self):
@ -130,7 +131,8 @@ class TestReldepList(base_test_case.BaseTestCase):
list1 = libdnf5.rpm.ReldepList(self.base)
list1.add_reldep_with_glob("pkg*")
expected = ["pkg", "pkg.conf", "pkg.conf.d", "pkg-libs", "pkg", "pkg", "pkg", "pkg", "pkg", "pkg"]
expected = ["pkg", "pkg.conf", "pkg.conf.d", "pkg-libs",
"pkg", "pkg", "pkg", "pkg", "pkg", "pkg"]
# TODO(dmach): implement __str__()
result = [reldep.to_string() for reldep in list1]
self.assertEqual(expected, result)

View File

@ -24,19 +24,21 @@ import base_test_case
PROJECT_BINARY_DIR = os.environ["PROJECT_BINARY_DIR"]
PROJECT_SOURCE_DIR = os.environ["PROJECT_SOURCE_DIR"]
class TestTutorial(base_test_case.BaseTestCase):
def setUp(self):
super().setUp()
self.installroot = self.base.get_config().installroot
self.cachedir = self.base.get_config().cachedir
self.baseurl = pathlib.Path(os.path.join(PROJECT_BINARY_DIR, "test/data/repos-rpm/rpm-repo1/")).as_uri()
self.baseurl = pathlib.Path(os.path.join(
PROJECT_BINARY_DIR, "test/data/repos-rpm/rpm-repo1/")).as_uri()
def test_create_base(self):
file = ""
with open("tutorial/session/create_base.py", "r") as f:
file += f.read()
exec(file, { 'installroot': self.installroot })
exec(file, {'installroot': self.installroot})
def test_load_repo(self):
file = ""
@ -46,7 +48,7 @@ class TestTutorial(base_test_case.BaseTestCase):
with open("tutorial/repo/load_repo.py", "r") as f:
file += f.read()
exec(file, { 'installroot': self.installroot, 'baseurl': self.baseurl })
exec(file, {'installroot': self.installroot, 'baseurl': self.baseurl})
def test_load_system_repo(self):
# TODO(nsella) This example does not 'compile' yet
@ -71,7 +73,7 @@ class TestTutorial(base_test_case.BaseTestCase):
with open("tutorial/query/query.py", "r") as f:
file += f.read()
exec(file, { 'installroot': self.installroot, 'baseurl': self.baseurl })
exec(file, {'installroot': self.installroot, 'baseurl': self.baseurl})
def test_transaction(self):
file = ""
@ -84,5 +86,4 @@ class TestTutorial(base_test_case.BaseTestCase):
with open("tutorial/transaction/transaction.py", "r") as f:
file += f.read()
exec(file, { 'installroot': self.installroot, 'baseurl': self.baseurl })
exec(file, {'installroot': self.installroot, 'baseurl': self.baseurl})

View File

@ -24,13 +24,17 @@ for tspkg in transaction.get_transaction_packages():
#
# We only override one of the callbacks here, see
# `libdnf.repo.DownloadCallbacks` documentation for a complete list.
class PackageDownloadCallbacks(libdnf5.repo.DownloadCallbacks):
def mirror_failure(self, user_cb_data, msg, url=""):
print("Mirror failure: ", msg)
return 0
downloader_callbacks = PackageDownloadCallbacks()
base.set_download_callbacks(libdnf5.repo.DownloadCallbacksUniquePtr(downloader_callbacks))
base.set_download_callbacks(
libdnf5.repo.DownloadCallbacksUniquePtr(downloader_callbacks))
# Download the packages.
transaction.download()
@ -40,13 +44,17 @@ transaction.download()
# Again, only a callback for when an RPM package installation starts, for a
# complete list of the callbacks see `libdnf.rpm.TransactionCallbacks`
# documentation.
class TransactionCallbacks(libdnf5.rpm.TransactionCallbacks):
def install_start(self, item, total=0):
print(libdnf5.base.transaction.transaction_item_action_to_string(item.get_action()), " ",
item.get_package().get_nevra())
transaction_callbacks = TransactionCallbacks()
transaction_callbacks_ptr = libdnf5.rpm.TransactionCallbacksUniquePtr(transaction_callbacks)
transaction_callbacks_ptr = libdnf5.rpm.TransactionCallbacksUniquePtr(
transaction_callbacks)
transaction.set_callbacks(transaction_callbacks_ptr)
# Add transaction metadata to be stored in the history database.

View File

@ -36,48 +36,47 @@ void TutorialTest::setUp() {
}
void TutorialTest::tearDown() {
}
void TutorialTest::tearDown() {}
void TutorialTest::test_create_base() {
#include "session/create_base.cpp"
#include "session/create_base.cpp"
}
void TutorialTest::test_load_repo() {
#include "session/create_base.cpp"
#include "session/create_base.cpp"
base.get_config().get_cachedir_option().set(cachedir);
#include "repo/load_repo.cpp"
#include "repo/load_repo.cpp"
}
void TutorialTest::test_load_system_repos() {
#include "session/create_base.cpp"
#include "session/create_base.cpp"
base.get_config().get_cachedir_option().set(cachedir);
#include "repo/load_system_repos.cpp"
#include "repo/load_system_repos.cpp"
}
void TutorialTest::test_query() {
#include "session/create_base.cpp"
#include "session/create_base.cpp"
base.get_config().get_cachedir_option().set(cachedir);
#include "repo/load_repo.cpp"
#include "query/query.cpp"
#include "query/query.cpp"
#include "repo/load_repo.cpp"
}
void TutorialTest::test_transaction() {
#include "session/create_base.cpp"
#include "session/create_base.cpp"
base.get_config().get_cachedir_option().set(cachedir);
#include "repo/load_repo.cpp"
#include "transaction/transaction.cpp"
#include "repo/load_repo.cpp"
#include "transaction/transaction.cpp"
}