Blame SOURCES/BZ-1357083-clean-all-add-hint-rm-rf.patch

d2a170
commit 01a6780fd310cbf0027e98fad97aca324f952196
d2a170
Author: Michal Domonkos <mdomonko@redhat.com>
d2a170
Date:   Thu Mar 9 14:02:25 2017 +0100
d2a170
d2a170
    Add hint about rm -rf for yum clean all. BZ 1357083
d2a170
d2a170
diff --git a/cli.py b/cli.py
d2a170
index 862992b..5f7c4ae 100755
d2a170
--- a/cli.py
d2a170
+++ b/cli.py
d2a170
@@ -1718,6 +1718,23 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
d2a170
         if 'all' in userlist:
d2a170
             self.verbose_logger.log(yum.logginglevels.INFO_2,
d2a170
                 _('Cleaning up everything'))
d2a170
+
d2a170
+            # Print a "maybe you want rm -rf" hint to compensate for the fact
d2a170
+            # that yum clean all is often misunderstood.  Don't do that,
d2a170
+            # however, if cachedir is non-default as we would have to replace
d2a170
+            # arbitrary yum vars with * and that could produce a harmful
d2a170
+            # command, e.g. for /mydata/$myvar we would say rm -rf /mydata/*
d2a170
+            cachedir = self.conf.cachedir
d2a170
+            if cachedir.startswith(('/var/cache/yum', '/var/tmp/yum-')):
d2a170
+                # Take just the first 3 path components
d2a170
+                rmdir = '/'.join(cachedir.split('/')[:4])
d2a170
+                self.verbose_logger.log(
d2a170
+                    yum.logginglevels.INFO_2,
d2a170
+                    _('Maybe you want: rm -rf %s, to also free up space taken '
d2a170
+                      'by orphaned data from disabled or removed repos'
d2a170
+                      % rmdir),
d2a170
+                )
d2a170
+
d2a170
             pkgcode, pkgresults = self.cleanPackages()
d2a170
             hdrcode, hdrresults = self.cleanHeaders()
d2a170
             xmlcode, xmlresults = self.cleanMetadata()