microdnf icon indicating copy to clipboard operation
microdnf copied to clipboard

Autoremove option?

Open galderz opened this issue 5 years ago • 7 comments

There doesn't appear to be a microdnf autoremove option to remove a package and its dependencies. Any plans to add that?

Any workarounds other than listing dependent packages manually?

galderz avatar Jun 24 '19 12:06 galderz

clean_requirements_on_remove=True also seems ignored

pabelanger avatar May 17 '21 15:05 pabelanger

Terribly ugly solution, but this is what I'm going to do in one my container - might be handy:

RUN rpm -qa | sort >/before.txt \
    && microdnf install -y gcc gcc-c++ kernel-devel python3-devel glew-devel msgpack-devel freeglut-devel libpng-devel freetype-devel libxml2-devel glm-devel mmtf-cpp-devel netcdf-cxx-devel \
    && rpm -qa | sort >/after.txt \
    && echo "Do what I needed to do with the packages installed" \
    && microdnf remove -y $( comm -13 /before.txt /after.txt ) \
    && rm /before.txt /after.txt \
    && microdnf clean all

jhutar avatar Aug 28 '22 13:08 jhutar

I think we will add that functionality to DNF5 project. DNF5 is going to replace microdnf (Fedora 38) and then DNF

j-mracek avatar Aug 29 '22 05:08 j-mracek

I may be mistaken, but could it be comm -23 /before.txt /after.txt? (i.e. -2 remove unique from after.txt because they are NEW, -3 remove lines in both). Also, I observed that when performing microdnf update it removes old packages as default, is this right? With this behavior, I update packages first, and then install any packages. After that rpm does not report old packages. Anyway, package update may not be desirable for some environments and comm .. solution would be a valid workaround for us.

ghost avatar Nov 11 '22 08:11 ghost

I may be mistaken, but could it be comm -23 /before.txt /after.txt? (i.e. -2 remove unique from after.txt because they are NEW, -3 remove lines in both). Also, I observed that when performing microdnf update it removes old packages as default, is this right? With this behavior, I update packages first, and then install any packages. After that rpm does not report old packages. Anyway, package update may not be desirable for some environments and comm .. solution would be a valid workaround for us.

DNF and microdnf during package upgrade always remove the old version of package with one exception - installonly packages. They are identify by provides in configuration option installonlypkgs. Therefore if you want to upgrade package foo and keep old version of foo then just use --setopt=installonlypkgs=foo and it should work. BUT - packages must be ready for such a situation - no file conflict. Also number of installonly packages is limited by installonly_limit configuration option. Please check dnf man pages for further information.

j-mracek avatar Nov 16 '22 10:11 j-mracek

Hello @gbarceloPIB . comm -13 ... worked for me, but I might be missing some use-case:

$ echo -e "one\nthree" | sort >before
$ echo -e "one\ntwo\nthree" | sort >after
$ comm -13 before after 
two

jhutar avatar Jan 02 '23 15:01 jhutar