-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
60 lines (50 loc) · 1.74 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from distutils.core import setup, Extension
from distutils.command.install import install
import sys
import brand
import re
import os
with open('Makefile.version') as f:
version = f.read().strip()
f.close()
servicefile = 'vcmmd.service'
systemd_unitdir = '/usr/lib/systemd/system'
systemd_unit = systemd_unitdir + "/" + servicefile
setup(name='vcmmd',
description='{} memory management daemon'.format(brand.PRODUCT_NAME_SHORT),
version=version,
license='GPLv2',
packages=['vcmmd',
'vcmmd.util',
'vcmmd.cgroup',
'vcmmd.rpc',
'vcmmd.rpc.dbus',
'vcmmd.ldmgr',
'vcmmd.ldmgr.policies',
'vcmmd.ve'],
data_files=[('/etc/dbus-1/system.d', ['dbus/com.virtuozzo.vcmmd.conf']),
('/etc/logrotate.d', ['logrotate/vcmmd']),
('/etc/vz', ['vcmmd.conf', 'vstorage-limits.conf']),
('/etc/tmpfiles.d/', ['vcmmd-tmpfiles.conf']),
(systemd_unitdir, ['systemd/{}'.format(servicefile)])],
scripts=['bin/vcmmd', 'bin/vcmmdctl'])
if len(sys.argv) < 2 or (len(sys.argv) > 1 and sys.argv[1] != "install"):
sys.exit(0)
def get_tmp_fname(fl):
return fl + "_tmp"
if '--root' in sys.argv:
try:
systemd_unit = sys.argv[sys.argv.index('--root') + 1] + "/" + systemd_unit
except:
pass
try:
with open(systemd_unit, "r") as f:
fw = open(get_tmp_fname(systemd_unit), 'w')
for line in f.readlines():
fw.write(re.sub("@PRODUCT_NAME_SHORT@", brand.PRODUCT_NAME_SHORT, line))
f.close()
fw.close()
os.rename(get_tmp_fname(systemd_unit), systemd_unit)
except:
print("Branding failed")
sys.exit(1)