-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
140 lines (112 loc) · 4.82 KB
/
setup.py
File metadata and controls
140 lines (112 loc) · 4.82 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
from distutils.core import setup, Command
from distutils.command.install import install as _install
import os
here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.md')).read()
class clean(Command):
"""A custom distutils command to clean the development tree."""
user_options = []
def initialize_options(self):
self._dir = os.getcwd()
def finalize_options(self):
pass
def _clean_path(self, endswith, dirname, fnames):
for fname in fnames:
if fname.endswith(endswith):
path = os.path.join(dirname, fname)
print("cleaning %s" % os.path.relpath(path))
os.unlink(path)
def run(self):
import shutil
for path in ["build", "dist", "tests/data/specs/BUILD",
"tests/data/specs/BUILDROOT", "tests/data/specs/RPMS"]:
if os.path.isdir(path):
print("cleaning %s" % path)
shutil.rmtree(path)
for path in ["MANIFEST"]:
if os.path.isfile(path):
print("cleaning %s" % path)
os.unlink(path)
os.path.walk("tests/data/specs", self._clean_path, ".rpm")
os.path.walk(".", self._clean_path, ".pyc")
os.path.walk(".", self._clean_path, ".pyo")
class install(_install):
"""Specialized installer.
The YUM plugins are not installed in the regular Python modules tree.
"""
def initialize_options(self):
_install.initialize_options(self)
# Remove this line and self.root defaults to '.', which is not desired
self.root = '/'
def run(self):
# Install the plugin code
yumplugins_coderoot = os.path.join(self.root, "usr/lib/yum-plugins/")
self.mkpath(yumplugins_coderoot, mode=0755)
self.copy_file("posttrans-triggers.py", yumplugins_coderoot,
preserve_mode=0)
# Install the plugin conf
yumplugins_confroot = os.path.join(self.root, "etc/yum/pluginconf.d/")
self.mkpath(yumplugins_confroot, mode=0755)
self.copy_file("posttrans-triggers.conf", yumplugins_confroot,
preserve_mode=0)
# Install the triggers dir
self.mkpath(os.path.join(yumplugins_confroot,
"posttrans-triggers.conf.d"),
mode=755)
class test(Command):
"""A custom distutils command to run unit tests."""
user_options = []
def initialize_options(self):
self._dir = os.getcwd()
def finalize_options(self):
pass
def run(self):
"""Run all the unit tests found in the `tests/' folder."""
import sys
import unittest
if os.getuid() != 0:
print("Unit tests must unfortunately be run as root")
sys.exit(1)
# FIXME: There has to be a way to run the unit tests against the
# development tree
yumplugins_coderoot = "/usr/lib/yum-plugins/"
if not os.path.exists(os.path.join(yumplugins_coderoot,
"posttrans-triggers.py")):
print("Unit tests require the plugin to be installed")
sys.exit(1)
print("\nWarning:\n--------\n Unit tests are run against the " \
"system-installed version of the plugin\n")
raw_input(" Press any key to continue...\n")
import tests
loader = unittest.TestLoader()
t = unittest.TextTestRunner(verbosity=self.verbose)
result = t.run(loader.loadTestsFromModule(tests))
if result.errors or result.failures:
sys.exit(1)
setup(name='yum-plugin-posttrans-triggers',
version='2.1',
description='Run some file triggers after a yum transaction',
long_description=README,
classifiers=[
"Intended Audience :: System Administrators",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Topic :: System :: Installation/Setup",
"Topic :: System :: Software Distribution",
"Topic :: System :: Systems Administration",
],
author='Mathieu Bridon',
author_email='bochecha@fedoraproject.org',
url='https://gitorious.org/yum-plugin-posttrans-triggers/yum-plugin-posttrans-triggers',
license='GPLv3+',
py_modules=['posttrans-triggers'],
requires = [
# The following are not available as distutils modules, but listing
# them here seems like the nice thing to do for package maintainers
# "yum>=3.2.29", # Not tested with older releases (that means RHEL6)
],
cmdclass={
"clean": clean, 'install': install, 'test': test,
},
)