Skip to content
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

Run transaction.test() before downloading and installing packages #1458

Closed

Conversation

krydos
Copy link

@krydos krydos commented Apr 27, 2024

Hi,
I recently faced the issue described in #849 and here on bugzilla about "too late" permissions check while installing/upgrading packages.

I've solved it by calling Transaction::test() in the beginning of Context::Impl::download_and_run().
It is clearly stated in the test() definition that it is redundant to call test() before run() but without calling it we should wait for download process to finish.

Another possible inconvenience is when Transaction::test() returns non TransactionRunResult::SUCCESS I do not customize the error message. Let me know if you think I should check for error types and maybe customize the error message based on that.

Please let me know if you think it can/should be implemented in a different way and share your recommendations.
Thanks!

@@ -363,6 +363,12 @@ void Context::Impl::download_and_run(libdnf5::base::Transaction & transaction) {
base.get_config().get_tsflags_option().set(libdnf5::Option::Priority::RUNTIME, "test");
}

if (transaction.test() != libdnf5::base::Transaction::TransactionRunResult::SUCCESS) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to perform the test before download, but I don't think it is a good idea to call transaction.test() before RPMs are downloaded, because they are required for the test. The code also does not consider use case with downloadonly option.

Copy link
Author

@krydos krydos May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please help me to figure out where exactly the downloaded RPMs are required for the test to run?
It isn't really clear for me unfortunately. I don't see anything related to it in libdnf5::base::Transaction::Impl::_run()

Also the downloadonly option is apparently unaltered because Context::Impl::download_and_run() isn't called for dnf5 download package_name. I'm not that fluent in DNF though... feel free to correct me here.

Should we rather have something like transaction.lock_test() that only check for permissions and don't rely on the whole transaction.test() functionality (which as you said requires RPMs to be downloaded).

P.S.
Rebased on top of main as download_and_run just got some updates.
Also closed/reopened the PR due to miss click

@krydos krydos closed this May 2, 2024
This should help to spot the permissions issue early in the process
@krydos krydos reopened this May 2, 2024
@jan-kolarik
Copy link
Member

jan-kolarik commented May 20, 2024

Hi, thanks for your PR. I've reviewed it as I've just started working on issue #849. Based on the discussion there, I'm considering a more robust solution that would take place after parsing the command line but before downloading any metadata. I plan to check if the command and options provided by the user would cause any system state changes (including downloadonly, assumeno, etc.). If so, we'll verify write access to the RPM database before proceeding. I should have a prototype PR ready this week. Let me know if you have any concerns with this approach. 🙂

@krydos
Copy link
Author

krydos commented May 21, 2024

@jan-kolarik, It definitely sounds way better than what I have here. Thanks!
If it's possible please let me know when you have your PR available and I'll close this one then.

@jan-kolarik
Copy link
Member

@jan-kolarik, It definitely sounds way better than what I have here. Thanks! If it's possible please let me know when you have your PR available and I'll close this one then.

Here it is: #1504.

@krydos krydos closed this May 22, 2024
@jan-kolarik
Copy link
Member

@krydos Anyway, thanks for your effort. It is greatly appreciated! Looking forward to any future contributions. 🙂

@krydos
Copy link
Author

krydos commented May 22, 2024

@jan-kolarik thank you for taking it further! I really miss this dnf5's behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants