microdnf
microdnf copied to clipboard
Autoremove option?
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?
clean_requirements_on_remove=True also seems ignored
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
I think we will add that functionality to DNF5 project. DNF5 is going to replace microdnf (Fedora 38) and then DNF
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.
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 performingmicrodnf update
it removes old packages as default, is this right? With this behavior, I update packages first, and then install any packages. After thatrpm
does not report old packages. Anyway, package update may not be desirable for some environments andcomm ..
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.
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