LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   package-cleanup and circular dependencies (https://www.linuxquestions.org/questions/red-hat-31/package-cleanup-and-circular-dependencies-4175596210/)

leniviy 12-27-2016 07:13 AM

package-cleanup and circular dependencies
 
Hi. I have a shell snippet that takes a list of packages I want to keep and uninstalls all the rest:

Code:

    diff -u ~/my_packs_to_keep.lst ~/my_packs_all.lst | sed '1,3d;/cifs-utils\|samba-client/d;s/^+//;t;d' >~/my_packages-ec-stage-db-1-to-uninst.txt
    while true; do
        package-cleanup --leaves --all | xargs rpm -q --queryformat "%{NAME}.%{ARCH}\n" | LC_ALL=C sort >~/my_packages-ec-stage-db-1-leaves.txt
        b=`LC_ALL=C join ~/my_packages-ec-stage-db-1-to-uninst.txt ~/my_packages-ec-stage-db-1-leaves.txt`
        [ -z "$b" ] && break
        yum erase $b || break
    done

Today I noticed it cannot uninstall this trinity:
- gdm
- pulseaudio-gdm-hooks
- plymouth-gdm-hooks

because they depend on each other and from `package-cleanup` point of view, they're not leaves.

How to change my script? The most important thing is to not accidentally erase a package that needs to be kept.

MensaWater 12-27-2016 08:24 AM

You can use "rpm -e" to remove any RPM and if you specify multiple RPMs after the -e it will check to see if any dependencies it encounters are in the list you specified and if so remove those. This won't remove any rpm you did NOT specify (so long as you didn't provide other options to the rpm command that tell it to do so) so is relatively safe.


All times are GMT -5. The time now is 06:53 AM.