-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for repos configuration overrides #820
Add support for repos configuration overrides #820
Conversation
fede15a
to
b18dd05
Compare
b18dd05
to
b691c56
Compare
fcc3657
to
72cb511
Compare
I added CI tests rpm-software-management/ci-dnf-stack#1368 |
We need to be able to move packaged repos out of |
72cb511
to
d219818
Compare
I rebased the code to resolve conflicts and deduplicate |
Otherwise it looks good for my eye untrained for C++. |
d219818
to
1ff5a3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any mistake. Yet I did not test the code.
include/libdnf5/repo/repo_sack.hpp
Outdated
void create_repos_from_system_configuration(); | ||
|
||
/// Loads repositories configuration overrides from drop-in directories. No new repositories are created. | ||
/// Only the configuration of the coresponding existing repositories is modified. | ||
void load_repos_configuration_overrides(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about to make it private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Good idea.
@@ -38,45 +39,6 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>. | |||
|
|||
namespace fs = std::filesystem; | |||
|
|||
namespace { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not 100% sure but the commit might be merged with previous commit or is there any reason why you would prefer the split?
libdnf5/utils/iniparser.cpp
Outdated
|
||
// Returns the input string with the undoubled characters ']'. | ||
// A sequence of two chars ']' is returned as a single char ']'. | ||
std::string section_name_decode_bracket(const std::string & section_name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is required for glob support in section header like [fedora[2-8]]. @jrohel Is it correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about to use the sema logic like we have in NEVRA parser - when the second [
then the parser skips everything until the next ]
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@j-mracek OK. I changed the logic to be compatible with the NEVRA parser.
After the repositories configuration is loaded, new code is run that loads the override files from the "/usr/share/dnf5/repos.override.d" and "/etc/dnf/repos.overide.d" directories. The format of override files is the same as regular ".repo" files. However, override files can modify the settings of already existing repositories. They cannot create new repositories. Overide files support glob in the repository ID (in the configuration file section name) to support bulk modification of repositories parameters. The order of processing the files with overrides: 1. Creates an alphabetically sorted list of all filenames with overrides in the distribution override directory ("/usr/share/dnf5/repos.override.d") and the user override directory ("/etc/dnf/repos.overide.d"). If a file with the same name is present in both override directories, only the file from the user override directory is added to the sorted list. So, the distribution override file can be simply masked by creating a file with the same name in the user override directory. 2. Retrieves the overrides from the files in the sorted list. Follows the order. The override from the next file overrides the previous one - the last override value wins. ------------------------------------------------- Example of the repos configuration override file: [*] skip_if_unavailable = true [fedora*] skip_if_unavailable = false ------------------------------------------------------------------- An example showing the order in which override files are processed: Files with user repos overrides: /etc/dnf/repos.overide.d/20-user-overrides.repo /etc/dnf/repos.overide.d/60-something2.repo /etc/dnf/repos.overide.d/80-user-overrides.repo /etc/dnf/repos.overide.d/99-config-manager.repo Files with distribution repos overrides: /usr/share/dnf5/repos.overide.d/50-something2.repo /usr/share/dnf5/repos.overide.d/60-something2.repo /usr/share/dnf5/repos.overide.d/90-something2.repo Resulting file processing order: 1. /etc/dnf/repos.overide.d/20-user-overrides.repo 2. /usr/share/dnf5/repos.overide.d/50-something2.repo 3. /etc/dnf/repos.overide.d/60-something2.repo 4. /etc/dnf/repos.overide.d/80-user-overrides.repo 5. /usr/share/dnf5/repos.overide.d/90-something2.repo 6. /etc/dnf/repos.overide.d/99-config-manager.repo
Older changes (Use utils::fs::File instead of streams) caused part of the code to become unreachable (dead).
The section header name is between '[', ']' characters. So the ']' character is interpreted as the end of the section name. This patch adds support for the ']' character in the section name. Doubling the character ']' - the sequence "]]" - means inserting a single character ']' into the section name.
Some lines in the raw strings ended with spaces. And some editors remove trailing spaces during code reformatting. Using a normal string is more robust.
1ff5a3a
to
cfc03e9
Compare
There is one problem - PR does not contain documentation, but it can be delivered later, but it requires to create an issue. |
I've created an issue to track this as #883 |
LGTM |
1ce386d
After the repositories configuration is loaded, new code is run that loads the override files from the
/usr/share/dnf5/repos.override.d
and/etc/dnf/repos.overide.d
directories.The format of override files is the same as regular ".repo" files. However, override files can modify the settings of already existing repositories. They cannot create new repositories.
Overide files support glob in the repository ID (in the configuration file section name) to support bulk modification of repositories parameters.
The order of processing the files with overrides:
The PR also includes a commit that adds support for the ']' character in the section header name in
IniParser
. Allows to use more complex glob patterns for repository IDs.Example of the repos configuration override file:
An example showing the order in which override files are processed:
Files with user repos overrides:
/etc/dnf/repos.overide.d/20-user-overrides.repo
/etc/dnf/repos.overide.d/60-something2.repo
/etc/dnf/repos.overide.d/80-user-overrides.repo
/etc/dnf/repos.overide.d/99-config-manager.repo
Files with distribution repos overrides:
/usr/share/dnf5/repos.overide.d/50-something2.repo
/usr/share/dnf5/repos.overide.d/60-something2.repo
/usr/share/dnf5/repos.overide.d/90-something2.repo
Resulting file processing order: