#3 Replace DNF calls by dnf-API
Merged by jkaluza. Opened by jmracek.
jmracek/fm-dnf-plugin dnf-api  into  master

Download 3.patch

This is first step in transformation of modularity into dnf command.

It use dnf-2.0. Unfortunately there should be inserted line DNFBASE.transaction_run() to performe the transaction, but I don't know, where it will be best location. If it will be dnf-plugin it can be done automatically with much better result.

So does it mean I can call DNFBASE.dnf_install multiple times for different modules and then just run that transaction using DNFBASE.transaction_run()? That would be really cool :).

Also, do you mean https://pagure.io/fm-dnf-plugin/blob/master/f/plugins/module.py by "dnf-plugin"? Can you explain what would have to be changed to that code to make transaction running automatically in the end of the "dnf module" subcommand handler?

We certainly can stop supporting "fm" command and support only "dnf module". This is long-term goal anyway and it has been decided we will do that sooner or later. I just have to ask Langdon if that's still valid decision and we can do that.

First of all, the module-plugin is not compatible with dnf-2.0 where important part were changed - like arg-parser, and command registration. The plugin is not set properly: demands are missing, where you can specified if sack needed, resolve and so on, therefore I don't need to use the DnfBase class with dnf.Base() initiation and transaction_run() because it is normally done by plugin confing and following processes after command.run() is finished.

In the presented script, you can add multiple modules, and when you want to run the transaction, you just call DNFBASE.transaction_run() and the transaction is performed. Unfortunately I didn't find proper place where to put it and I was unable to test it. If only dnf-plugin will be used, the transaction will be performed when command run finished and demands.resolving = True. My present code is only work-around.

I've tried to put transaction_run to place where I think it should belong to (see the patch here: http://jkaluza.fedorapeople.org/fm-dnf-api.patch ) and "dnf module disable" seems to work as expected. The problem is with "dnf module enable".

It seems that DnfBase.dnf_install is called with proper data. It does not raise any expection, but when I run transaction_run later, nothing happens and transaction_run prints an empty line.

I have also tried to call transaction_run as last thing in the dnf_install, but the result has been the same. Any ideas?

To reproduce, just do "cmake . -DPYTHON_DESIRED=3", "sudo make install" and create following file in /etc/fm.modules.d/:

[fm_testing_modules]
name = FM project testing modules
url = http://fed-mod.org/dev/modules
enabled = 1

Then do "sudo dnf module enable httpd". It should install "httpd" RPM when enabling httpd module, but does not do that for me.

rebased

Here is working version for fm and dnf commands (the output is different!!!). There is still issue with roll-back. If 'dnf module disable httpd' and you say N it produce an issue because 'repo_file.create()' doesn't serve as rollback. I thing that design that first mark module as deleted or installed and then perform a transaction with unknown result is sensitive to problems. I think that module operation should be only committed when requested operation succeed. I have to mentioned, that I am not going to solve the issue by this PR.

I also incorporate patch (http://jkaluza.fedorapeople.org/fm-dnf-api.patch) into fixup, due to massive reorganization and prevent problems with rebasing. Sorry that it is not a separate commit.

This seems to work. I will do some more tests and eventually merge your PR. Thanks! :)

Pull-Request has been merged by jkaluza

Metadata