dnf icon indicating copy to clipboard operation
dnf copied to clipboard

Add detection for ostree-based systems and warn users about losing changes

Open dcantrell opened this issue 1 year ago • 1 comments

On ostree-based systems, users can use dnf to customize the environment but those changes will be lost at the next ostree-based image update. If you want to retain changes between ostree-updates you need to make use of rpm-ostree right now.

All this patch does is add a function to detect systems managed this way and present warnings before dnf operations that modify the system. I display the warning at the beginning of the output, but maybe that should be after any other output is on the display.

dcantrell avatar Feb 15 '24 19:02 dcantrell

I have two proposals regarding the code I've reviewed.

Firstly, as you suggested, I'd go with displaying the warning text to the user during the transaction confirmation, which involves moving the logic before this specific line. This approach eliminates the need to handle individual commands, as it addresses any transactional operation.

Secondly, in util.py, I'd retain only the logic related to detecting container presence. After confirming that is_container returns True, we can relocate the logging of the ostree message to the previously mentioned location. What do you think about that?

jan-kolarik avatar Feb 19 '24 09:02 jan-kolarik

I have two proposals regarding the code I've reviewed.

Firstly, as you suggested, I'd go with displaying the warning text to the user during the transaction confirmation, which involves moving the logic before this specific line. This approach eliminates the need to handle individual commands, as it addresses any transactional operation.

Secondly, in util.py, I'd retain only the logic related to detecting container presence. After confirming that is_container returns True, we can relocate the logging of the ostree message to the previously mentioned location. What do you think about that?

I like these suggestions, thanks! I will get the PR updated. I've also got an additional method for reliably detecting an ostree system, so I'm going to try to rework is_container() a bit too.

dcantrell avatar Apr 18 '24 13:04 dcantrell

LGTM, thanks!

jan-kolarik avatar Apr 24 '24 12:04 jan-kolarik

xref https://issues.redhat.com/browse/SWM-1313 related to this

cgwalters avatar Jul 11 '24 17:07 cgwalters

This should test for /run/ostree-booted instead and only that. bootc or rpm-ostree being installed on the system does not mean that we are using a Image Based system.

travier avatar Jul 11 '24 17:07 travier