From bdeb5a0939b889674f3591ace697e9e99bd423c1 Mon Sep 17 00:00:00 2001 From: Alessio Sergi Date: Mon, 5 Jan 2015 11:33:15 +0100 Subject: [PATCH] setup.py: add chroot detection Fixes #471. --- setup.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index cf1d40a8..d066869c 100755 --- a/setup.py +++ b/setup.py @@ -6,6 +6,8 @@ import sys from setuptools import setup +is_chroot = os.stat('/').st_ino != 2 + def get_data_files(): data_files = [ @@ -15,15 +17,16 @@ def get_data_files(): ('share/man/man1', ['man/glances.1']) ] - if os.name == 'posix' and os.getuid() == 0: # Unix-like + root privileges + if hasattr(sys, 'real_prefix'): # virtualenv + conf_path = os.path.join(sys.prefix, 'etc', 'glances') + elif os.name == 'posix' and (os.getuid() == 0 or is_chroot): + # Unix-like + root privileges/chroot environment if 'bsd' in sys.platform: conf_path = os.path.join(sys.prefix, 'etc', 'glances') elif 'linux' in sys.platform: conf_path = os.path.join('/etc', 'glances') elif 'darwin' in sys.platform: conf_path = os.path.join('/usr/local', 'etc', 'glances') - elif hasattr(sys, 'real_prefix'): # virtualenv - conf_path = os.path.join(sys.prefix, 'etc', 'glances') elif 'win32' in sys.platform: # windows conf_path = os.path.join(os.environ.get('APPDATA'), 'glances') else: # Unix-like + per-user install