If a user tries "emerge -C gcc", he gets the warning !!! 'sys-devel/gcc' is part of your system profile. !!! Unmerging it may be damaging to your system. If he tries "emerge -C gmp" no warning is issued. The problem is that removing gmp is almost as good as removing gcc itself (bug 268601). Another example is python. No warning is given for it, but removing it breaks portage (bug 232721). To make it harder for users to accidentally break their system, I propose the following change. When ever a user tries to remove a package (which is not in the system set)*, emerge should check if this package is a dependency of a package in the system set**. If this is the case the following warning should be issued. !!! '<cat/package>' is a dependency of a package which is part of your system profile. !!! Unmerging it may be damaging to your system. Additionally some further explanation might be added: Proposal A) A dependency chain ending at a system package for this package should be displayed. For example: [nomerge ] net-misc/openssh-5.2_p1-r1 USE="X ldap pam tcpd -X509 -hpn -kerberos -libedit -pkcs11 (-selinux) -skey -smartcard -static" [ebuild R ] x11-apps/xauth-1.0.3 USE="-debug -ipv6" [ebuild R ] x11-libs/libXmu-1.0.4 USE="-debug -ipv6" [ebuild R ] x11-libs/libXt-1.0.5 USE="-debug" [ebuild R ] x11-libs/libSM-1.1.0 USE="-debug -ipv6" [ebuild R ] sys-libs/e2fsprogs-libs-1.41.3-r1 USE="nls" [ebuild R ] sys-devel/bc-1.06.95 USE="readline -libedit -static" Proposal B***) !!! Use "equery depends <cat/package>" to check for reverse dependencies. !!! equery is part of app-portage/gentoolkit. * The behavior for packages in the system set should remain unchanged. ** One could use the output of emerge -e system for example. *** The problem with this one is, that it might be hard to track which system package depends on the package in question, if it is not a direct dependency. Reproducible: Always Steps to Reproduce:
Consider the case of gcc with USE="gtk", should the warning occur there too when removing gtk?
(In reply to comment #1) > Consider the case of gcc with USE="gtk", should the warning occur there too > when removing gtk? > I think yes. I can't see how emerge should be able to decide if a given package is really going to break a system package. The only other option would be to maintain a list of such packages, which I consider a bad idea. If A) would be added the user would immediately see where this warning comes from.
I have to add 2 points. emerge -e system is not the right method to determine if a package is a dependency of a system package since build-time-only dependencies are pulled in. There is some logic needed to exclude them. If you don't want a warning for gtk and the other x11 stuff, a category blacklist could be added to exclude them. This might be the better way since people tend to ignore warnings, if they here/see it too often and at places where they are not really needed.
I think --unmerge should just have an unconditional "be careful" warning (except it won't be shown in --quiet mode). It should advise you to use --depclean <atom> if you want something safer.
Other package managers (apt-get is all I have handy) seem to have access to extra metadata to determine whether or not a package is 'essential' or not. sudo apt-get remove -s libc6 yields: WARNING: The following essential packages will be removed. This should NOT be done unless you know exactly what you are doing! apt libc6 (due to apt) libgcc1 (due to apt) libstdc++6 (due to apt) base-files base-passwd (due to base-files) libpam-modules (due to base-files) bash debianutils (due to bash) libncurses5 (due to bash) bsdutils coreutils libacl1 (due to coreutils) libselinux1 (due to coreutils) dash mktemp (due to debianutils) diff dpkg lzma (due to dpkg) e2fsprogs e2fslibs (due to e2fsprogs) libblkid1 (due to e2fsprogs) libcomerr2 (due to e2fsprogs) libss2 (due to e2fsprogs) libuuid1 (due to e2fsprogs) findutils grep gzip hostname login libpam0g (due to login) mount ncurses-base ncurses-bin perl-base python-minimal python2.5-minimal (due to python-minimal) sed sysvutils libsepol1 (due to sysvutils) tar util-linux lsb-base (due to util-linux) tzdata (due to util-linux) libslang2 (due to util-linux) zlib1g (due to util-linux) 0 upgraded, 0 newly installed, 2063 to remove and 0 not upgraded. I'm not sure how useful this metadata is for a distribution like Gentoo (how are Gentoo developers to know what packages are essential for you the end user?). There is some quote from years ago that a UNIX-like tool should do what the operator tells it to do, even if the Op should know better (eg. emerge -C glibc) Otherwise I appreciate of the generic "removing stuff is dangerous" approach proposed by Zac, generic approaches are good.
*** Bug 279810 has been marked as a duplicate of this bug. ***
Bug #278840 is a duplicate.
*** Bug 278840 has been marked as a duplicate of this bug. ***
In svn r15393 I've added a message that looks like this: * This action can remove important packages! In order to be safer, use * `emerge -pv --depclean <atom>` to check for reverse dependencies before * removing packages.
This is fixed in 2.1.8 and 2.2_rc64. If the new message annoys you, there's a --quiet-unmerge-warn option that you can add to EMERGE_DEFAULT_OPTS in /etc/make.conf.