Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
157 lines (139 loc) · 6.56 KB
/
Copy pathsetup.py
File metadata and controls
157 lines (139 loc) · 6.56 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env python
import glob
from setuptools import setup
import distutils.log as log
from distutils.core import Extension
from distutils.cmd import Command
from distutils.unixccompiler import UnixCCompiler
from setuptools.command.build_ext import build_ext
import subprocess
import sys
import os
from os.path import join
class YaccCommand(Command):
description = "Build yacc parsers."
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
command = ['bison', '-y', '-d', 'libqpol/policy_parse.y',
'-o', 'libqpol/policy_parse.c']
self.announce("Generating parser", level=log.INFO)
self.announce(' '.join(command), level=log.INFO)
subprocess.check_call(command)
class LexCommand(Command):
description = "Build lex scanners."
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
command = [
'flex', '-o', 'libqpol/policy_scan.c', 'libqpol/policy_scan.l']
self.announce("Generating scanner", level=log.INFO)
self.announce(' '.join(command), level=log.INFO)
subprocess.check_call(command)
class BuildExtCommand(build_ext):
def run(self):
self.run_command('build_yacc')
self.run_command('build_lex')
build_ext.run(self)
try:
static_sepol = os.environ['SEPOL']
except KeyError:
# try to find libsepol.a. The find_library_file function
# chooses dynamic libraries over static ones, so
# this assumes that the static lib is in the same directory
# as the dynamic lib.
dynamic_sepol = UnixCCompiler().find_library_file(['/usr/lib64', '/usr/lib'], 'sepol')
static_sepol = dynamic_sepol.replace(".so", ".a")
ext_py_mods = [Extension('setools.policyrep._qpol',
['setools/policyrep/qpol.i',
'libqpol/avrule_query.c',
'libqpol/bool_query.c',
'libqpol/bounds_query.c',
'libqpol/class_perm_query.c',
'libqpol/cond_query.c',
'libqpol/constraint_query.c',
'libqpol/context_query.c',
'libqpol/default_object_query.c',
'libqpol/expand.c',
'libqpol/fs_use_query.c',
'libqpol/ftrule_query.c',
'libqpol/genfscon_query.c',
'libqpol/isid_query.c',
'libqpol/iterator.c',
'libqpol/mls_query.c',
'libqpol/mlsrule_query.c',
'libqpol/module.c',
'libqpol/module_compiler.c',
'libqpol/netifcon_query.c',
'libqpol/nodecon_query.c',
'libqpol/permissive_query.c',
'libqpol/polcap_query.c',
'libqpol/policy.c',
'libqpol/policy_define.c',
'libqpol/policy_extend.c',
'libqpol/portcon_query.c',
'libqpol/queue.c',
'libqpol/rbacrule_query.c',
'libqpol/role_query.c',
'libqpol/syn_rule_query.c',
'libqpol/terule_query.c',
'libqpol/type_query.c',
'libqpol/user_query.c',
'libqpol/util.c',
'libqpol/policy_parse.c',
'libqpol/policy_scan.c'],
include_dirs=['libqpol', 'libqpol/include'],
libraries=['bz2', 'selinux', 'sepol'],
extra_compile_args=['-Werror', '-Wextra',
'-Waggregate-return',
'-Wcast-align',
'-Wfloat-equal',
'-Wformat', '-Wformat=2',
'-Winit-self', '-Winline',
'-Wmissing-format-attribute',
'-Wmissing-include-dirs',
'-Wnested-externs',
'-Wold-style-definition',
'-Wpointer-arith',
'-Wredundant-decls',
'-Wstrict-prototypes',
'-Wunknown-pragmas',
'-Wwrite-strings',
'-Wno-missing-field-initializers', # SWIG 3.0.2 generates partially-initialized structs
'-Wno-unused-parameter', # SWIG generates functions with unused parameters
'-Wno-cast-qual', # libsepol/libselinux uses const-to-nonconst casts
'-Wno-shadow', # SWIG generates shadow variables
'-fno-exceptions'],
extra_objects=[static_sepol],
extra_link_args=['-Wl,--version-script=libqpol/libqpol.map'],
swig_opts=['-Ilibqpol/include'])]
setup(name='setools',
version='4.0.0-alpha3',
description='SELinux Policy tools.',
author='Tresys Technology, LLC',
author_email='setools@tresys.com',
url='https://github.com/TresysTechnology/setools',
cmdclass={'build_yacc': YaccCommand,
'build_lex': LexCommand,
'build_ext': BuildExtCommand},
packages=['setools', 'setools.policyrep', 'setoolsgui', 'setoolsgui.apol'],
scripts=['apol', 'seinfo', 'seinfoflow', 'sesearch', 'sedta'],
data_files=[(join(sys.prefix, 'share/setools'), glob.glob("data/*.ui") + ["data/perm_map"] ),
(join(sys.prefix, 'share/setools/icons'), glob.glob("data/icons/*.png"))],
ext_modules=ext_py_mods,
test_suite='tests',
license='GPLv2+, LGPLv2.1+',
classifiers=[
'Environment :: Console',
'Environment :: X11 Applications :: Qt',
'Intended Audience :: Information Technology',
'Topic :: Security',
'Topic :: Utilities',
],
)