From a11e3764f1fdd8bf6f192dba2c1bcc7fbb803a01 Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Wed, 23 Jul 2014 14:54:14 +0100 Subject: Make systemd root installation dir appropriate for debian-like systems, else fallback to universally acceptable one. --- setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 9118e5f6..f8566e34 100755 --- a/setup.py +++ b/setup.py @@ -35,6 +35,10 @@ import subprocess def is_f(p): return os.path.isfile(p) +if is_f('/etc/debian_version'): + systemd_root = '/lib/systemd/system/' +else: + systemd_root = '/etc/systemd/system/' INITSYS_FILES = { 'sysvinit': [f for f in glob('sysvinit/redhat/*') if is_f(f)], @@ -45,7 +49,7 @@ INITSYS_FILES = { INITSYS_ROOTS = { 'sysvinit': '/etc/rc.d/init.d', 'sysvinit_deb': '/etc/init.d', - 'systemd': '/etc/systemd/system/', + 'systemd': systemd_root, 'upstart': '/etc/init/', } INITSYS_TYPES = sorted(list(INITSYS_ROOTS.keys())) -- cgit v1.2.3 From 9c6d12b4477b7f36ccdea04310451a84f09e1388 Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Thu, 24 Jul 2014 11:54:10 +0100 Subject: Use pkg-config --- setup.py | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index f8566e34..63562554 100755 --- a/setup.py +++ b/setup.py @@ -35,26 +35,6 @@ import subprocess def is_f(p): return os.path.isfile(p) -if is_f('/etc/debian_version'): - systemd_root = '/lib/systemd/system/' -else: - systemd_root = '/etc/systemd/system/' - -INITSYS_FILES = { - 'sysvinit': [f for f in glob('sysvinit/redhat/*') if is_f(f)], - 'sysvinit_deb': [f for f in glob('sysvinit/debian/*') if is_f(f)], - 'systemd': [f for f in glob('systemd/*') if is_f(f)], - 'upstart': [f for f in glob('upstart/*') if is_f(f)], -} -INITSYS_ROOTS = { - 'sysvinit': '/etc/rc.d/init.d', - 'sysvinit_deb': '/etc/init.d', - 'systemd': systemd_root, - 'upstart': '/etc/init/', -} -INITSYS_TYPES = sorted(list(INITSYS_ROOTS.keys())) - - def tiny_p(cmd, capture=True): # Darn python 2.6 doesn't have check_output (argggg) stdout = subprocess.PIPE @@ -71,6 +51,30 @@ def tiny_p(cmd, capture=True): % (cmd, ret, out, err)) return (out, err) +def systemd_unitdir(): + cmd = ['pkg-config', '--variable=systemdsystemunitdir', 'systemd'] + try: + (path, err) = tiny_p(cmd) + except: + return '/lib/systemd/system' + return str(path).strip() + +systemd_root = systemd_unitdir() + +INITSYS_FILES = { + 'sysvinit': [f for f in glob('sysvinit/redhat/*') if is_f(f)], + 'sysvinit_deb': [f for f in glob('sysvinit/debian/*') if is_f(f)], + 'systemd': [f for f in glob('systemd/*') if is_f(f)], + 'upstart': [f for f in glob('upstart/*') if is_f(f)], +} +INITSYS_ROOTS = { + 'sysvinit': '/etc/rc.d/init.d', + 'sysvinit_deb': '/etc/init.d', + 'systemd': systemd_root, + 'upstart': '/etc/init/', +} +INITSYS_TYPES = sorted(list(INITSYS_ROOTS.keys())) + def get_version(): cmd = ['tools/read-version'] -- cgit v1.2.3 From c0a423ea72b4e9c8e21c07c5ca27dee54133fc19 Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Thu, 24 Jul 2014 11:57:17 +0100 Subject: refactor redundant systemd_root --- setup.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 63562554..9ec038fd 100755 --- a/setup.py +++ b/setup.py @@ -59,8 +59,6 @@ def systemd_unitdir(): return '/lib/systemd/system' return str(path).strip() -systemd_root = systemd_unitdir() - INITSYS_FILES = { 'sysvinit': [f for f in glob('sysvinit/redhat/*') if is_f(f)], 'sysvinit_deb': [f for f in glob('sysvinit/debian/*') if is_f(f)], @@ -70,7 +68,7 @@ INITSYS_FILES = { INITSYS_ROOTS = { 'sysvinit': '/etc/rc.d/init.d', 'sysvinit_deb': '/etc/init.d', - 'systemd': systemd_root, + 'systemd': systemd_unitdir(), 'upstart': '/etc/init/', } INITSYS_TYPES = sorted(list(INITSYS_ROOTS.keys())) -- cgit v1.2.3