Blame SOURCES/0080-sosreport-set-SYSROOT-by-policy.patch

0cd6dc
From bd32d57c8a946b2dc1acbdfa4ded62d6840f8e73 Mon Sep 17 00:00:00 2001
0cd6dc
From: "Bryn M. Reeves" <bmr@redhat.com>
0cd6dc
Date: Mon, 26 Jan 2015 15:39:16 -0500
0cd6dc
Subject: [PATCH 80/93] [sosreport] set SYSROOT by policy
0cd6dc
0cd6dc
If --sysroot is not given on the command line and
0cd6dc
Policy.in_container() is True set sysroot automatically if
0cd6dc
Policy.get_host_sysroot() is not '/'.
0cd6dc
0cd6dc
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
0cd6dc
---
0cd6dc
 sos/sosreport.py | 13 ++++++++++---
0cd6dc
 1 file changed, 10 insertions(+), 3 deletions(-)
0cd6dc
0cd6dc
diff --git a/sos/sosreport.py b/sos/sosreport.py
0cd6dc
index 1dce5f9..90be4ca 100644
0cd6dc
--- a/sos/sosreport.py
0cd6dc
+++ b/sos/sosreport.py
0cd6dc
@@ -630,7 +630,7 @@ class SoSOptions(object):
0cd6dc
                           help="Disable HTML/XML reporting", default=False)
0cd6dc
         parser.add_option("-s", "--sysroot", action="store", dest="sysroot",
0cd6dc
                           help="system root directory path (default='/')",
0cd6dc
-                          default="/")
0cd6dc
+                          default=None)
0cd6dc
         parser.add_option("-c", "--chroot", action="store", dest="chroot",
0cd6dc
                           help="chroot executed commands to SYSROOT "
0cd6dc
                                "[auto, always, never] (default=auto)",
0cd6dc
@@ -685,11 +685,18 @@ class SoSReport(object):
0cd6dc
         self.tempfile_util = TempFileUtil(self.tmpdir)
0cd6dc
         self._set_directories()
0cd6dc
 
0cd6dc
+        self._setup_logging()
0cd6dc
+
0cd6dc
+        msg = "default"
0cd6dc
+        host_sysroot = self.policy.host_sysroot()
0cd6dc
         # set alternate system root directory
0cd6dc
         if self.opts.sysroot:
0cd6dc
+            msg = "cmdline"
0cd6dc
             self.sysroot = self.opts.sysroot
0cd6dc
-
0cd6dc
-        self._setup_logging()
0cd6dc
+        elif self.policy.in_container() and host_sysroot != os.sep:
0cd6dc
+            msg = "policy"
0cd6dc
+            self.sysroot = host_sysroot
0cd6dc
+        self.soslog.debug("set sysroot to '%s' (%s)" % (self.sysroot, msg))
0cd6dc
 
0cd6dc
         if self.opts.chroot not in chroot_modes:
0cd6dc
             self.soslog.error("invalid chroot mode: %s" % self.opts.chroot)
0cd6dc
-- 
0cd6dc
1.9.3
0cd6dc