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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
# Experimental top-level setup.py for rpki CA tools.
#
# This is not yet ready for prime time.
#
# General idea here is that we can use this with Python-aware platform
# packaging systems, and our code here deals with the strange build
# environment required when the system copy of OpenSSL isn't usable.
#
# So yes, you are seeing a setup.py which calls autoconf and make.
# Strange, but so long as it works as Python expects, good enough.
# $Id$
#
# Copyright (C) 2011-2012 Internet Systems Consortium ("ISC")
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
import os
import subprocess
from distutils.core import setup, Extension, Command
from distutils.command.build_ext import build_ext as _build_ext
from distutils.command.sdist import sdist as _sdist
ac = None
class autoconf(Command):
description = "run autoconf if hasn't been run already"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
try:
import ac_rpki
except ImportError:
subprocess.check_call(("./configure",))
import ac_rpki
global ac
ac = ac_rpki.ac
class build_openssl(Command):
description = "build private OpenSSL libraries when needed by POW extension"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
self.run_command("autoconf")
if ac.build_openssl:
subprocess.check_call(("make",), cwd = "openssl")
class build_ext(_build_ext):
def run(self):
self.run_command("autoconf")
self.run_command("build_openssl")
# Non-standard extension build specification: we need to force
# whatever build options our top-level ./configure selected, and we
# have to specify our libraries as extra_link_args because they may be
# complete pathnames to .a files elsewhere in the build tree. Most of
# this insanity is to kludge around pre-existing OpenSSL libraries
# that would screw up our build without these gymnastics.
# Not sure yet, but if we use autoconf to update or override
# options to build_ext, we might need to reinitialize here,
# something like:
#
#self = self.reinitialize_command(self)
#self.ensure_finalized()
# Might end up just whacking the one and only Extension object
# queued up for this build_ext command. Ugly, non-standard, but
# simple.
# For now just try whacking self.extensions and see what happens
assert self.extensions and len(self.extensions) == 1
ext = self.extensions[0]
ext.extra_compile_args = ac.CFLAGS
ext.extra_link_args = ac.LDFLAGS + ac.LIBS
return _build_ext.run(self)
# The following hack uses "svn ls -R" to generate the manifest.
# Haven't decided yet whether that's a good idea or not, commented out
# of cmdclass for now.
class sdist(_sdist):
def add_defaults(self):
try:
self.filelist.extend(subprocess.check_output(("svn", "ls", "-R")).splitlines())
except CalledProcessError:
return _sdist.add_default(self)
# Be careful constructing data_files, empty file lists here appear to
# confuse setup into putting dangerous nonsense into the list of
# installed files.
#
# bdist_rpm seems to get confused by relative names for scripts, so we
# have to prefix source names here with the build directory name.
# Not sure why these are being treated as data files instead of
# scripts, probably historical based on our use of autoconf. More
# distutils commands needed to customize scripts, probably
scripts = ['rpki-sql-backup',
'rpki-sql-setup',
'rpki-start-servers',
'irbe_cli',
'irdbd',
'pubd',
'rootd',
'rpkic',
'rpkid',
'portal-gui/scripts/rpkigui-rcynic',
'portal-gui/scripts/rpkigui-import-routes',
'portal-gui/scripts/rpkigui-check-expired',
'portal-gui/scripts/rpki-manage']
aux_scripts = []
data_files = []
# XXX disable all scripts for now until I get extension build working.
if False:
if ac.sbindir and scripts:
data_files.append((ac.sbindir,
["%s/%s" % (ac.abs_builddir, f) for f in scripts]))
if ac.libexecdir and aux_scripts:
data_files.append((ac.libexecdir,
["%s/%s" % (ac.abs_builddir, f) for f in aux_scripts]))
if not data_files:
data_files = None
setup(name = "rpkitoolkit",
version = "1.0",
description = "RPKI Toolkit",
license = "BSD",
url = "http://www.rpki.net/",
cmdclass = {"autoconf" : autoconf,
"build_ext" : build_ext,
"build_openssl" : build_openssl,
# "sdist" : sdist,
},
package_dir = {"" : "rpkid"},
packages = ["rpki", "rpki.POW", "rpki.irdb",
"rpki.gui", "rpki.gui.app", "rpki.gui.cacheview",
"rpki.gui.api", "rpki.gui.routeview"],
ext_modules = [Extension("rpki.POW._POW", ["rpkid/ext/POW.c"])],
package_data = {
'rpki.gui.app': ['migrations/*.py', 'static/*/*',
'templates/*.html', 'templates/*/*.html',
'templatetags/*.py'],
'rpki.gui.cacheview': ['templates/*/*.html']
},
data_files = data_files)
|