aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Rantzsch <[email protected]>2020-11-30 12:30:37 +0100
committerHannes Rantzsch <[email protected]>2020-12-01 14:38:00 +0100
commit03d0465d227b00c6b816dc66d2913c0ae610c752 (patch)
tree5c00f55c00d3cfab5b3694a1a53dd68a641ca50a
parent3a275685a7d2df96266a453818625393b8018210 (diff)
CI: validate installation after running make install
See https://github.com/randombit/botan/pull/2526 for details
-rwxr-xr-xconfigure.py2
-rw-r--r--src/build-data/makefile.in10
-rwxr-xr-xsrc/scripts/ci_build.py6
-rwxr-xr-xsrc/scripts/ci_check_install.py56
4 files changed, 66 insertions, 8 deletions
diff --git a/configure.py b/configure.py
index b18c6390e..3688b153e 100755
--- a/configure.py
+++ b/configure.py
@@ -2001,7 +2001,7 @@ def create_template_vars(source_paths, build_paths, options, modules, cc, arch,
def choose_python_exe():
exe = sys.executable
- if exe[1] == ':': # Windows style paths
+ if options.os == 'mingw': # mingw doesn't handle the backslashes in the absolute path well
return exe.replace('\\', '/')
return exe
diff --git a/src/build-data/makefile.in b/src/build-data/makefile.in
index f651465ea..a10648591 100644
--- a/src/build-data/makefile.in
+++ b/src/build-data/makefile.in
@@ -47,19 +47,19 @@ docs: %{doc_stamp_file}
%{endif}
%{doc_stamp_file}: %{doc_dir}/*.rst %{doc_dir}/api_ref/*.rst %{doc_dir}/dev_ref/*.rst
- $(PYTHON_EXE) $(SCRIPTS_DIR)/build_docs.py --build-dir="%{build_dir}"
+ "$(PYTHON_EXE)" "$(SCRIPTS_DIR)/build_docs.py" --build-dir="%{build_dir}"
clean:
- $(PYTHON_EXE) $(SCRIPTS_DIR)/cleanup.py --build-dir="%{build_dir}"
+ "$(PYTHON_EXE)" "$(SCRIPTS_DIR)/cleanup.py" --build-dir="%{build_dir}"
distclean:
- $(PYTHON_EXE) $(SCRIPTS_DIR)/cleanup.py --build-dir="%{build_dir}" --distclean
+ "$(PYTHON_EXE)" "$(SCRIPTS_DIR)/cleanup.py" --build-dir="%{build_dir}" --distclean
install: %{install_targets}
- $(PYTHON_EXE) $(SCRIPTS_DIR)/install.py --prefix="%{prefix}" --build-dir="%{build_dir}" --bindir=%{bindir} --libdir=%{libdir} --docdir=%{docdir} --includedir=%{includedir}
+ "$(PYTHON_EXE)" "$(SCRIPTS_DIR)/install.py" --prefix="%{prefix}" --build-dir="%{build_dir}" --bindir="%{bindir}" --libdir="%{libdir}" --docdir="%{docdir}" --includedir="%{includedir}"
check: tests
- $(PYTHON_EXE) $(SCRIPTS_DIR)/check.py --build-dir="%{build_dir}"
+ "$(PYTHON_EXE)" "$(SCRIPTS_DIR)/check.py" --build-dir="%{build_dir}"
# Object Files
LIBOBJS = %{join lib_objs}
diff --git a/src/scripts/ci_build.py b/src/scripts/ci_build.py
index f6010c389..50d9d0348 100755
--- a/src/scripts/ci_build.py
+++ b/src/scripts/ci_build.py
@@ -274,7 +274,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):
"""
@@ -467,6 +467,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',
@@ -485,7 +486,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,
@@ -559,6 +560,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 ['coverage']:
if not have_prog('lcov'):
diff --git a/src/scripts/ci_check_install.py b/src/scripts/ci_check_install.py
new file mode 100755
index 000000000..5146e1231
--- /dev/null
+++ b/src/scripts/ci_check_install.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# coding=utf8
+
+"""
+Botan CI check installation script
+This script is used to validate the results of `make install`
+
+(C) 2020 Jack Lloyd, René Meusel, Hannes Rantzsch
+
+Botan is released under the Simplified BSD License (see license.txt)
+"""
+
+import os
+import sys
+
+def has_extension(filename, extensions):
+ for ext in [ext for ext in extensions]:
+ 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])
+ return 1
+ install_prefix = sys.argv[1]
+
+ if not os.path.isdir(install_prefix):
+ print('Error: install_prefix "%s" is not a directory' % install_prefix)
+ return 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())