You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2019/06/14 18:28:16 UTC

[arrow] branch master updated: ARROW-5576: [C++] Query ASF mirror system for URL and use when downloading Thrift

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 38b019d  ARROW-5576: [C++] Query ASF mirror system for URL and use when downloading Thrift
38b019d is described below

commit 38b019df4e7a7da45ee0002c3161d87426561eac
Author: Wes McKinney <we...@apache.org>
AuthorDate: Fri Jun 14 13:27:58 2019 -0500

    ARROW-5576: [C++] Query ASF mirror system for URL and use when downloading Thrift
    
    This also allows CHECKSUM values to be put in cpp/thirdparty/versions.txt for security purposes. Apache Thrift is still using MD5 for some reason, so we will need to fix that once they get their next release out (hopefully with SHA256 checksums)
    
    Author: Wes McKinney <we...@apache.org>
    
    Closes #4558 from wesm/ARROW-5576 and squashes the following commits:
    
    4700af407 <Wes McKinney> Disable log suppression in thrift_ep
    bfbfbec8d <Wes McKinney> Query ASF mirror system for URL and use when downloading Thrift
---
 cpp/build-support/get_apache_mirror.py      | 31 +++++++++++++++++++++++
 cpp/cmake_modules/ThirdpartyToolchain.cmake | 39 ++++++++++++++++++++++++-----
 cpp/thirdparty/versions.txt                 |  1 +
 3 files changed, 65 insertions(+), 6 deletions(-)

diff --git a/cpp/build-support/get_apache_mirror.py b/cpp/build-support/get_apache_mirror.py
new file mode 100644
index 0000000..07186e0
--- /dev/null
+++ b/cpp/build-support/get_apache_mirror.py
@@ -0,0 +1,31 @@
+#!/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.
+
+# This script queries the ASF mirror system to obtain a suggested
+# mirror for downloading dependencies, e.g. in CMake
+
+import json
+try:
+    from urllib2 import urlopen
+except ImportError:
+    # py3
+    from urllib.request import urlopen
+
+suggested_mirror = urlopen('https://www.apache.org/dyn/'
+                           'closer.cgi?as_json=1').read()
+print(json.loads(suggested_mirror)['preferred'])
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 89f5200..90c6d5e 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -34,6 +34,21 @@ else()
 endif()
 
 # ----------------------------------------------------------------------
+# We should not use the Apache dist server for build dependencies
+
+set(APACHE_MIRROR "")
+
+macro(get_apache_mirror)
+  if(APACHE_MIRROR STREQUAL "")
+    exec_program(${PYTHON_EXECUTABLE}
+                 ARGS
+                 ${CMAKE_SOURCE_DIR}/build-support/get_apache_mirror.py
+                 OUTPUT_VARIABLE
+                 APACHE_MIRROR)
+  endif()
+endmacro()
+
+# ----------------------------------------------------------------------
 # Resolve the dependencies
 
 # TODO: add uriparser here when it gets a conda package
@@ -200,7 +215,9 @@ endif()
 file(STRINGS "${THIRDPARTY_DIR}/versions.txt" TOOLCHAIN_VERSIONS_TXT)
 foreach(_VERSION_ENTRY ${TOOLCHAIN_VERSIONS_TXT})
   # Exclude comments
-  if(NOT _VERSION_ENTRY MATCHES "^[^#][A-Za-z0-9-_]+_VERSION=")
+  if(NOT
+     ((_VERSION_ENTRY MATCHES "^[^#][A-Za-z0-9-_]+_VERSION=")
+      OR (_VERSION_ENTRY MATCHES "^[^#][A-Za-z0-9-_]+_CHECKSUM=")))
     continue()
   endif()
 
@@ -344,10 +361,7 @@ endif()
 if(DEFINED ENV{ARROW_THRIFT_URL})
   set(THRIFT_SOURCE_URL "$ENV{ARROW_THRIFT_URL}")
 else()
-  set(
-    THRIFT_SOURCE_URL
-    "https://archive.apache.org/dist/thrift/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}.tar.gz"
-    )
+  set(THRIFT_SOURCE_URL "FROM-APACHE-MIRROR")
 endif()
 
 if(DEFINED ENV{ARROW_URIPARSER_URL})
@@ -996,11 +1010,24 @@ macro(build_thrift)
                           ${THRIFT_CMAKE_ARGS})
   endif()
 
+  if("${THRIFT_SOURCE_URL}" STREQUAL "FROM-APACHE-MIRROR")
+    get_apache_mirror()
+    set(THRIFT_SOURCE_URL
+        "${APACHE_MIRROR}/thrift/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}.tar.gz")
+  endif()
+
+  message("Downloading Apache Thrift from ${THRIFT_SOURCE_URL}")
+
   externalproject_add(thrift_ep
                       URL ${THRIFT_SOURCE_URL}
+                      URL_HASH "MD5=${THRIFT_MD5_CHECKSUM}"
                       BUILD_BYPRODUCTS "${THRIFT_STATIC_LIB}" "${THRIFT_COMPILER}"
                       CMAKE_ARGS ${THRIFT_CMAKE_ARGS}
-                      DEPENDS ${THRIFT_DEPENDENCIES} ${EP_LOG_OPTIONS})
+                      DEPENDS ${THRIFT_DEPENDENCIES}
+                              # ARROW-5576 showing verbose logs until we know
+                              # what is wrong
+                              # ${EP_LOG_OPTIONS}
+                      )
 
   add_library(Thrift::thrift STATIC IMPORTED)
   # The include directory must exist before it is referenced by a target.
diff --git a/cpp/thirdparty/versions.txt b/cpp/thirdparty/versions.txt
index 23001d0..d960cb0 100644
--- a/cpp/thirdparty/versions.txt
+++ b/cpp/thirdparty/versions.txt
@@ -45,6 +45,7 @@ RAPIDJSON_VERSION=2bbd33b33217ff4a73434ebf10cdac41e2ef5e34
 RE2_VERSION=2019-04-01
 SNAPPY_VERSION=1.1.7
 THRIFT_VERSION=0.12.0
+THRIFT_MD5_CHECKSUM=3deebbb4d1ca77dd9c9e009a1ea02183
 URIPARSER_VERSION=0.9.2
 ZLIB_VERSION=1.2.11
 ZSTD_VERSION=v1.4.0