This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
forked from candlepin/virt-who
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
117 lines (96 loc) · 3.6 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/python2
from __future__ import print_function
import sys
import os
from setuptools import setup, find_packages
from distutils.command.install import install
from shutil import copy, copyfileobj
import gzip
def install_file(filename, destination, file_mode=0o644, dir_mode=0o755):
install_dir = os.path.dirname(destination)
if not os.path.isdir(install_dir):
os.makedirs(install_dir, dir_mode)
copy(filename, destination)
os.chmod(destination, file_mode)
class InstallSystemd(install):
description = 'install systemd service'
def run(self, *args, **kwargs):
root = self.root or ''
if self.prefix != '/usr':
print("systemd service has to be installed to /usr")
sys.exit(1)
install_file('virt-who.service', '{root}/usr/lib/systemd/system/virt-who.service'.format(root=root))
class InstallUpstart(install):
description = 'install upstart service'
def run(self, *args, **kwargs):
root = self.root or ''
install_file('virt-who-initscript', '{root}/etc/rc.d/init.d/virt-who'.format(root=root), file_mode=0o755)
class InstallManPages(install):
description = 'install manual pages'
MAN_PAGES = (
('virt-who', '8'),
('virt-who-config', '5'),
('virt-who-password', '8'),
)
def run(self, *args, **kwargs):
root = self.root or ''
# gzip embeds output filename and it breaks rpmbuild
# we need to use relative name
old_wd = os.getcwd()
os.chdir(root)
for name, number in self.MAN_PAGES:
filename = '{old_wd}/{name}.{number}'.format(old_wd=old_wd, name=name, number=number)
dirname = 'usr/share/man/man{number}'.format(number=number)
if not os.path.isdir(dirname):
os.makedirs(dirname, 0o755)
outfile = '{dirname}/{name}.{number}.gz'.format(
dirname=dirname, name=name, number=number)
with open(filename, 'rb') as f_in:
# gzip in py26 doesn't support contextmanager
f_out = gzip.open(outfile, 'wb')
try:
copyfileobj(f_in, f_out)
finally:
f_out.close()
os.chdir(old_wd)
class InstallConfig(install):
description = 'install configuration files'
FILES = (
('virt-who.conf', '{root}/etc/sysconfig/virt-who'),
('template.conf', '{root}/etc/virt-who.d/template.conf'),
('template-general.conf', '{root}/etc/virt-who.conf'),
)
def run(self, *args, **kwargs):
root = self.root or ''
for origname, output in self.FILES:
install_file(origname, output.format(root=root))
version = {}
with open('virtwho/version.py') as ver_file:
exec(ver_file.read(), version)
setup(
name='virt-who',
version='0.24.4',
description='virt-who is agent for reporting virtual guest IDs to subscription manager.',
# long_description=open('README.md').read(),
author='Radek Novacek',
author_email='[email protected]',
license='LICENSE',
url='https://github.com/virt-who/virt-who',
packages=find_packages(),
entry_points={
'console_scripts': [
'virt-who = virtwho.__main__:main',
'virt-who-password = virtwho.password.__main__:main'
]
},
include_package_data=True,
package_data={
'virtwho.virt.esx': ['vimServiceMinimal.wsdl'],
},
cmdclass={
'install_systemd': InstallSystemd,
'install_upstart': InstallUpstart,
'install_man_pages': InstallManPages,
'install_config': InstallConfig,
},
)