|
41 | 41 | log = logging.getLogger("multissl")
|
42 | 42 |
|
43 | 43 | OPENSSL_OLD_VERSIONS = [
|
44 |
| - "0.9.8zc", |
45 |
| - "0.9.8zh", |
46 | 44 | "1.0.1u",
|
| 45 | + "1.0.2o", |
47 | 46 | ]
|
48 | 47 |
|
49 | 48 | OPENSSL_RECENT_VERSIONS = [
|
50 |
| - "1.0.2", |
51 |
| - "1.0.2l", |
52 |
| - "1.1.0f", |
| 49 | + "1.0.2p", |
| 50 | + "1.1.0i", |
| 51 | +# "1.1.1", |
53 | 52 | ]
|
54 | 53 |
|
55 | 54 | LIBRESSL_OLD_VERSIONS = [
|
|
59 | 58 |
|
60 | 59 | LIBRESSL_RECENT_VERSIONS = [
|
61 | 60 | "2.5.5",
|
62 |
| - "2.6.4", |
63 |
| - "2.7.1", |
| 61 | + "2.6.5", |
| 62 | + "2.7.4", |
64 | 63 | ]
|
65 | 64 |
|
66 | 65 | # store files in ../multissl
|
67 |
| -HERE = os.path.abspath(os.getcwd()) |
68 |
| -MULTISSL_DIR = os.path.abspath(os.path.join(HERE, '..', 'multissl')) |
| 66 | +HERE = os.path.dirname(os.path.abspath(__file__)) |
| 67 | +PYTHONROOT = os.path.abspath(os.path.join(HERE, '..', '..')) |
| 68 | +MULTISSL_DIR = os.path.abspath(os.path.join(PYTHONROOT, '..', 'multissl')) |
| 69 | + |
69 | 70 |
|
70 | 71 | parser = argparse.ArgumentParser(
|
71 | 72 | prog='multissl',
|
|
77 | 78 | parser.add_argument(
|
78 | 79 | '--debug',
|
79 | 80 | action='store_true',
|
80 |
| - help="Enable debug mode", |
| 81 | + help="Enable debug logging", |
81 | 82 | )
|
82 | 83 | parser.add_argument(
|
83 | 84 | '--disable-ancient',
|
|
120 | 121 | help="Disable network tests."
|
121 | 122 | )
|
122 | 123 | parser.add_argument(
|
123 |
| - '--compile-only', |
124 |
| - action='store_true', |
125 |
| - help="Don't run tests, only compile _ssl.c and _hashopenssl.c." |
| 124 | + '--steps', |
| 125 | + choices=['library', 'modules', 'tests'], |
| 126 | + default='tests', |
| 127 | + help=( |
| 128 | + "Which steps to perform. 'library' downloads and compiles OpenSSL " |
| 129 | + "or LibreSSL. 'module' also compiles Python modules. 'tests' builds " |
| 130 | + "all and runs the test suite." |
| 131 | + ) |
126 | 132 | )
|
127 | 133 |
|
| 134 | +parser.add_argument( |
| 135 | + '--force', |
| 136 | + action='store_true', |
| 137 | + dest='force', |
| 138 | + help="Force build and installation." |
| 139 | +) |
| 140 | +parser.add_argument( |
| 141 | + '--keep-sources', |
| 142 | + action='store_true', |
| 143 | + dest='keep_sources', |
| 144 | + help="Keep original sources for debugging." |
| 145 | +) |
128 | 146 |
|
129 | 147 | class AbstractBuilder(object):
|
130 | 148 | library = None
|
131 | 149 | url_template = None
|
132 | 150 | src_template = None
|
133 | 151 | build_template = None
|
| 152 | + install_target = 'install' |
134 | 153 |
|
135 | 154 | module_files = ("Modules/_ssl.c",
|
136 | 155 | "Modules/_hashopenssl.c")
|
137 | 156 | module_libs = ("_ssl", "_hashlib")
|
138 | 157 |
|
139 |
| - def __init__(self, version, compile_args=(), |
140 |
| - basedir=MULTISSL_DIR): |
| 158 | + def __init__(self, version, args): |
141 | 159 | self.version = version
|
142 |
| - self.compile_args = compile_args |
| 160 | + self.args = args |
143 | 161 | # installation directory
|
144 | 162 | self.install_dir = os.path.join(
|
145 |
| - os.path.join(basedir, self.library.lower()), version |
| 163 | + os.path.join(args.base_directory, self.library.lower()), version |
146 | 164 | )
|
147 | 165 | # source file
|
148 |
| - self.src_dir = os.path.join(basedir, 'src') |
| 166 | + self.src_dir = os.path.join(args.base_directory, 'src') |
149 | 167 | self.src_file = os.path.join(
|
150 | 168 | self.src_dir, self.src_template.format(version))
|
151 | 169 | # build directory (removed after install)
|
@@ -252,21 +270,29 @@ def _unpack_src(self):
|
252 | 270 | def _build_src(self):
|
253 | 271 | """Now build openssl"""
|
254 | 272 | log.info("Running build in {}".format(self.build_dir))
|
255 |
| - cwd = self.build_dir |
256 |
| - cmd = ["./config", "shared", "--prefix={}".format(self.install_dir)] |
257 |
| - cmd.extend(self.compile_args) |
| 273 | + cmd = [ |
| 274 | + "./config", |
| 275 | + "shared", "--debug", |
| 276 | + "--prefix={}".format(self.install_dir) |
| 277 | + ] |
| 278 | + env = os.environ.copy() |
| 279 | + # set rpath |
| 280 | + env["LD_RUN_PATH"] = self.lib_dir |
258 | 281 | self._subprocess_call(cmd, cwd=cwd)
|
259 | 282 | # Old OpenSSL versions do not support parallel builds.
|
260 | 283 | self._subprocess_call(["make", "-j1"], cwd=cwd)
|
261 | 284 |
|
262 |
| - def _make_install(self, remove=True): |
263 |
| - self._subprocess_call(["make", "-j1", "install"], cwd=self.build_dir) |
264 |
| - if remove: |
| 285 | + def _make_install(self): |
| 286 | + self._subprocess_call( |
| 287 | + ["make", "-j1", self.install_target], |
| 288 | + cwd=self.build_dir |
| 289 | + ) |
| 290 | + if not self.args.keep_sources: |
265 | 291 | shutil.rmtree(self.build_dir)
|
266 | 292 |
|
267 | 293 | def install(self):
|
268 | 294 | log.info(self.openssl_cli)
|
269 |
| - if not self.has_openssl: |
| 295 | + if not self.has_openssl or self.args.force: |
270 | 296 | if not self.has_src:
|
271 | 297 | self._download_src()
|
272 | 298 | else:
|
@@ -332,6 +358,8 @@ class BuildOpenSSL(AbstractBuilder):
|
332 | 358 | url_template = "https://www.openssl.org/source/openssl-{}.tar.gz"
|
333 | 359 | src_template = "openssl-{}.tar.gz"
|
334 | 360 | build_template = "openssl-{}"
|
| 361 | + # only install software, skip docs |
| 362 | + install_target = 'install_sw' |
335 | 363 |
|
336 | 364 |
|
337 | 365 | class BuildLibreSSL(AbstractBuilder):
|
@@ -370,57 +398,64 @@ def main():
|
370 | 398 |
|
371 | 399 | start = datetime.now()
|
372 | 400 |
|
373 |
| - for name in ['python', 'setup.py', 'Modules/_ssl.c']: |
374 |
| - if not os.path.isfile(name): |
| 401 | + if args.steps in {'modules', 'tests'}: |
| 402 | + for name in ['setup.py', 'Modules/_ssl.c']: |
| 403 | + if not os.path.isfile(os.path.join(PYTHONROOT, name)): |
| 404 | + parser.error( |
| 405 | + "Must be executed with ./python from CPython build dir" |
| 406 | + ) |
| 407 | + if not os.path.samefile('python', sys.executable): |
375 | 408 | parser.error(
|
376 |
| - "Must be executed from CPython build dir" |
377 |
| - ) |
378 |
| - if not os.path.samefile('python', sys.executable): |
379 |
| - parser.error( |
380 | 409 | "Must be executed with ./python from CPython build dir"
|
381 | 410 | )
|
382 | 411 |
|
383 |
| - # check for configure and run make |
384 |
| - configure_make() |
| 412 | + # check for configure and run make |
| 413 | + configure_make() |
385 | 414 |
|
386 | 415 | # download and register builder
|
387 | 416 | builds = []
|
388 | 417 |
|
389 | 418 | for version in args.openssl:
|
390 |
| - build = BuildOpenSSL(version) |
| 419 | + build = BuildOpenSSL( |
| 420 | + version, |
| 421 | + args |
| 422 | + ) |
391 | 423 | build.install()
|
392 | 424 | builds.append(build)
|
393 | 425 |
|
394 | 426 | for version in args.libressl:
|
395 |
| - build = BuildLibreSSL(version) |
| 427 | + build = BuildLibreSSL( |
| 428 | + version, |
| 429 | + args |
| 430 | + ) |
396 | 431 | build.install()
|
397 | 432 | builds.append(build)
|
398 | 433 |
|
399 |
| - for build in builds: |
400 |
| - try: |
401 |
| - build.recompile_pymods() |
402 |
| - build.check_pyssl() |
403 |
| - if not args.compile_only: |
404 |
| - build.run_python_tests( |
405 |
| - tests=args.tests, |
406 |
| - network=args.network, |
407 |
| - ) |
408 |
| - except Exception as e: |
409 |
| - log.exception("%s failed", build) |
410 |
| - print("{} failed: {}".format(build, e), file=sys.stderr) |
411 |
| - sys.exit(2) |
412 |
| - |
413 |
| - print("\n{} finished in {}".format( |
414 |
| - "Tests" if not args.compile_only else "Builds", |
415 |
| - datetime.now() - start |
416 |
| - )) |
| 434 | + if args.steps in {'modules', 'tests'}: |
| 435 | + for build in builds: |
| 436 | + try: |
| 437 | + build.recompile_pymods() |
| 438 | + build.check_pyssl() |
| 439 | + if args.steps == 'tests': |
| 440 | + build.run_python_tests( |
| 441 | + tests=args.tests, |
| 442 | + network=args.network, |
| 443 | + ) |
| 444 | + except Exception as e: |
| 445 | + log.exception("%s failed", build) |
| 446 | + print("{} failed: {}".format(build, e), file=sys.stderr) |
| 447 | + sys.exit(2) |
| 448 | + |
| 449 | + log.info("\n{} finished in {}".format( |
| 450 | + args.steps.capitalize(), |
| 451 | + datetime.now() - start |
| 452 | + )) |
417 | 453 | print('Python: ', sys.version)
|
418 |
| - if args.compile_only: |
419 |
| - print('Build only') |
420 |
| - elif args.tests: |
421 |
| - print('Executed Tests:', ' '.join(args.tests)) |
422 |
| - else: |
423 |
| - print('Executed all SSL tests.') |
| 454 | + if args.steps == 'tests': |
| 455 | + if args.tests: |
| 456 | + print('Executed Tests:', ' '.join(args.tests)) |
| 457 | + else: |
| 458 | + print('Executed all SSL tests.') |
424 | 459 |
|
425 | 460 | print('OpenSSL / LibreSSL versions:')
|
426 | 461 | for build in builds:
|
|
0 commit comments