diff options
author | Hannes Rantzsch <[email protected]> | 2020-11-30 12:30:37 +0100 |
---|---|---|
committer | Hannes Rantzsch <[email protected]> | 2020-12-01 12:26:46 +0100 |
commit | 1e94eeeb8e8df42f9ced77810f63d81383d87149 (patch) | |
tree | e86620c51cdcce575489a0e53526d3a4ebc84a46 | |
parent | a1f6809a5e23a8b92c32ef78bc991947966a2a43 (diff) |
CI: validate installation after running make install
-rwxr-xr-x | src/scripts/ci_build.py | 6 | ||||
-rwxr-xr-x | src/scripts/ci_check_install.py | 48 |
2 files changed, 52 insertions, 2 deletions
diff --git a/src/scripts/ci_build.py b/src/scripts/ci_build.py index 306561b01..3e112da64 100755 --- a/src/scripts/ci_build.py +++ b/src/scripts/ci_build.py @@ -295,7 +295,7 @@ def determine_flags(target, target_os, target_cpu, target_cc, cc_bin, else: run_test_command = test_prefix + test_cmd - return flags, run_test_command, make_prefix + return flags, run_test_command, make_prefix, install_prefix def run_cmd(cmd, root_dir): """ @@ -501,6 +501,7 @@ def main(args=None): 'src/python/botan2.py', 'src/scripts/ci_build.py', 'src/scripts/install.py', + 'src/scripts/ci_check_install.py', 'src/scripts/dist.py', 'src/scripts/cleanup.py', 'src/scripts/check.py', @@ -522,7 +523,7 @@ def main(args=None): cmds.append(['python3', '-m', 'pylint'] + pylint_flags + [py3_flags] + full_paths) else: - config_flags, run_test_command, make_prefix = determine_flags( + config_flags, run_test_command, make_prefix, install_prefix = determine_flags( target, options.os, options.cpu, options.cc, options.cc_bin, options.compiler_cache, root_dir, options.pkcs11_lib, options.use_gdb, options.disable_werror, @@ -606,6 +607,7 @@ def main(args=None): if target in ['shared', 'static', 'bsi', 'nist']: cmds.append(make_cmd + ['install']) + cmds.append([py_interp, os.path.join(root_dir, 'src/scripts/ci_check_install.py'), install_prefix]) if target in ['sonar']: diff --git a/src/scripts/ci_check_install.py b/src/scripts/ci_check_install.py new file mode 100755 index 000000000..816f60a52 --- /dev/null +++ b/src/scripts/ci_check_install.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +"""This script is used to validate the results of `make install`""" + +import os +import sys + +def has_extension(filename, extensions): + for ext in [ext for ext in extensions if ext != ""]: + if filename.endswith(".%s" % ext): + return True + return False + +def is_lib_file(filename): + return has_extension(filename, ["so", "a", "dll", "dylib", "lib"]) + +def is_header_file(filename): + return has_extension(filename, ["h", "hpp", "h++", "hxx", "hh"]) + +def main(): + if len(sys.argv) < 2: + print("Usage: %s <install_prefix>" % sys.argv[0]) + sys.exit(1) + install_prefix = sys.argv[1] + + if not os.path.isdir(install_prefix): + print('Error: install_prefix "%s" is not a directory' % install_prefix) + sys.exit(1) + + found_libs = False + found_headers = False + + for (_, _, filenames) in os.walk(install_prefix): + for filename in filenames: + if is_header_file(filename): + found_headers = True + elif is_lib_file(filename): + found_libs = True + if found_libs and found_headers: + return 0 + + print("Error: installation incomplete. Found headers: %s. Found libs: %s. install_prefix was %s" + % (found_headers, found_libs, install_prefix)) + return 1 + + +if __name__ == '__main__': + sys.exit(main()) |