setup.py: add chroot detection

Fixes #471.
This commit is contained in:
Alessio Sergi 2015-01-05 11:33:15 +01:00
parent f4cca40717
commit 8b63d555e3

View File

@ -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