kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [5/5] incubator-kudu git commit: KUDU-1336. Add a simple preflight check for thirdparty build
Date Sun, 20 Mar 2016 20:45:38 GMT
KUDU-1336. Add a simple preflight check for thirdparty build

We've had a lot of users hit common build problems like not using a new enough
C++11 compiler on RHEL6. This commit adds a simple set of pre-flight checks
that will hopefully make it easier for new users to build Kudu.

I tested this by running an ubuntu:14.04 docker image, running preflight.py and
installing whatever it asked me to until it passed. This seemed to cover all
of the packages mentioned in the install docs.

I also verified that this passed on a RHEL6 system with devtoolset.

Change-Id: I93ee4165bd560f9cd3f03877bd3011decc7e1a6f
Reviewed-on: http://gerrit.cloudera.org:8080/2450
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <adar@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/90be132b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/90be132b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/90be132b

Branch: refs/heads/master
Commit: 90be132b9fdf8fc898a69186ca80d1fcce9ba109
Parents: 570611b
Author: Todd Lipcon <todd@cloudera.com>
Authored: Thu Mar 3 21:05:07 2016 -0800
Committer: Todd Lipcon <todd@apache.org>
Committed: Sun Mar 20 20:43:14 2016 +0000

----------------------------------------------------------------------
 thirdparty/build-thirdparty.sh |   5 ++
 thirdparty/preflight.py        | 154 ++++++++++++++++++++++++++++++++++++
 2 files changed, 159 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/90be132b/thirdparty/build-thirdparty.sh
----------------------------------------------------------------------
diff --git a/thirdparty/build-thirdparty.sh b/thirdparty/build-thirdparty.sh
index 9febc2d..e6dace7 100755
--- a/thirdparty/build-thirdparty.sh
+++ b/thirdparty/build-thirdparty.sh
@@ -39,6 +39,11 @@ set -ex
 
 TP_DIR=$(cd "$(dirname "$BASH_SOURCE")"; pwd)
 
+# Before doing anything, run the pre-flight check for missing dependencies.
+# This avoids the most common issues people have with building (if they don't
+# read the docs)
+$TP_DIR/preflight.py
+
 source $TP_DIR/vars.sh
 source $TP_DIR/build-definitions.sh
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/90be132b/thirdparty/preflight.py
----------------------------------------------------------------------
diff --git a/thirdparty/preflight.py b/thirdparty/preflight.py
new file mode 100755
index 0000000..5d1a0ec
--- /dev/null
+++ b/thirdparty/preflight.py
@@ -0,0 +1,154 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Simple script which checks that the build system has the main
+dependencies necessary for building thirdparty/.
+
+This is not meant to be exhaustive. For example, it doesn't check specific
+version numbers of software. Nor is it meant to be a replacement for
+more complicated config tests using something like autoconf or cmake.
+But, it's simple enough that it runs with no dependencies and tells
+users if they're missing anything obvious.
+"""
+
+import os
+import sys
+import subprocess
+
+DEV_NULL = file("/dev/null", "wb")
+CC = os.environ.get("CC", "cc")
+CXX = os.environ.get("CXX", "c++")
+
+REQUIRED_TOOLS = [
+  "autoconf",
+  "automake",
+  "curl",
+  "gdb",
+  "git",
+  "libtool",
+  "make",
+  "patch",
+  "pkg-config",
+  "rsync",
+  "unzip",
+  "xxd"]
+
+def log_failure_and_exit(error_msg, exc=None):
+  print "***", error_msg
+  if exc:
+    print exc.message
+    print
+  print "Please refer to docs/installation.adoc for complete installation "
+  print "instructions for your platform."
+  sys.exit(1)
+
+
+def try_do(status_msg, error_msg, func):
+  print status_msg, "..."
+  try:
+    func()
+  except Exception as e:
+    log_failure_and_exit(error_msg, e)
+
+
+def compile(script, flags=None):
+  if flags is None:
+    flags = []
+
+  p = subprocess.Popen([CXX, '-o', '/dev/null', '-c', '-x', 'c++', '-'] + flags,
+      stderr=subprocess.PIPE,
+      stdout=subprocess.PIPE,
+      stdin=subprocess.PIPE)
+  print >>p.stdin, script
+  stdout, stderr = p.communicate()
+  if p.returncode != 0:
+    raise Exception("Compilation failed: " + stderr)
+
+
+def check_tools():
+  """ Check that basic build tools are installed. """
+  missing = []
+  for tool in REQUIRED_TOOLS:
+    print "Checking for " + tool
+    if subprocess.call(["which", tool], stdout=DEV_NULL, stderr=DEV_NULL) != 0:
+      missing.append(tool)
+  if missing:
+    log_failure_and_exit("Missing required tools:\n" +
+      "\n".join("  " + tool for tool in missing))
+
+
+def check_cxx11():
+  # Check that the compiler is new enough.
+  try_do(
+    "Checking for C++11 compiler support",
+    ("Unable to compile a simple c++11 program. " +
+     "Please use g++ 4.8 or higher. On CentOS 6 or RHEL 6 " +
+     "you must use the devtoolset. See docs/installation.adoc " +
+     "for more info."),
+    lambda: compile("""
+      #include <atomic>
+      int f() {
+        std::atomic<int> i;
+        return i.load();
+      }""",
+      flags=['--std=c++11']))
+
+
+def check_boost():
+  try_do(
+    "Checking for boost_thread and boost_system headers",
+    ("Unable to compile a simple program that uses boost. " +
+     "Please check the boost dependencies are installed."),
+    lambda: compile("""
+      #include <boost/thread/locks.hpp>
+      #include <boost/system/config.hpp>
+      """,
+      flags=["-E"]))
+
+
+def check_sasl():
+  try_do(
+    "Checking for cyrus-sasl headers",
+    ("Unable to compile a simple program that uses sasl. " +
+     "Please check that cyrus-sasl-devel (RPM) or libsasl2-dev (deb) " +
+     "dependencies are installed."),
+    lambda: compile("""
+      #include <sasl/sasl.h>
+      """,
+      flags=["-E"]))
+
+
+def main():
+  print "Running pre-flight checks"
+  print "-------------------------"
+  print "Using C compiler:", CXX
+  print "Using C++ compiler:", CXX
+  print ""
+  print "  (Set $CC and $CXX to change compiler)"
+  print "-------------------------"
+  check_tools()
+  check_cxx11()
+  check_boost()
+  check_sasl()
+  print "-------------"
+  print "Pre-flight checks succeeded."
+  return 0
+
+if __name__ == "__main__":
+  sys.exit(main())


Mime
View raw message