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

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