You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2016/03/23 23:53:40 UTC

incubator-kudu git commit: KUDU-1336 (take 2). Add a simple preflight check for thirdparty build

Repository: incubator-kudu
Updated Branches:
  refs/heads/master 3337124e7 -> ef2b64b9f


KUDU-1336 (take 2). 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.

This is a second attempt at committing this patch after the first attempt
was reverted. This revision differs by not requiring 'gdb', since it isn't
actually necessary to build Kudu, despite being recommended in the docs.

Original Change-Id: I93ee4165bd560f9cd3f03877bd3011decc7e1a6f
Reviewed-on: http://gerrit.cloudera.org:8080/2450

Change-Id: If55e6baed692dc1fb3e4c5953506631423666060
Reviewed-on: http://gerrit.cloudera.org:8080/2615
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <ad...@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/ef2b64b9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/ef2b64b9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/ef2b64b9

Branch: refs/heads/master
Commit: ef2b64b9fbddf8bb69926fa61ea691fa509bc3f1
Parents: 3337124
Author: Todd Lipcon <to...@cloudera.com>
Authored: Thu Mar 3 21:05:07 2016 -0800
Committer: Todd Lipcon <to...@apache.org>
Committed: Wed Mar 23 22:53:24 2016 +0000

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


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/ef2b64b9/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/ef2b64b9/thirdparty/preflight.py
----------------------------------------------------------------------
diff --git a/thirdparty/preflight.py b/thirdparty/preflight.py
new file mode 100755
index 0000000..3e00dd2
--- /dev/null
+++ b/thirdparty/preflight.py
@@ -0,0 +1,153 @@
+#!/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",
+  "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())