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 2018/08/17 22:59:25 UTC

[arrow] branch master updated: ARROW-3067: [Packaging] Support dev/rc/release .deb/.rpm builds

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 c82dfcd  ARROW-3067: [Packaging] Support dev/rc/release .deb/.rpm builds
c82dfcd is described below

commit c82dfcdfac6fd281a8c99fa7a6373103d1ce5874
Author: Kouhei Sutou <ko...@clear-code.com>
AuthorDate: Fri Aug 17 18:59:17 2018 -0400

    ARROW-3067: [Packaging] Support dev/rc/release .deb/.rpm builds
    
    This includes works in #2323 and reverts temporary change in #2288.
    
    Author: Kouhei Sutou <ko...@clear-code.com>
    
    Closes #2441 from kou/linux-package-support-dev-rc-release and squashes the following commits:
    
    1d678f41 <Kouhei Sutou>  Support dev/rc/release .deb/.rpm builds
---
 dev/tasks/linux-packages/Rakefile                  | 77 +++++++---------------
 dev/tasks/linux-packages/apt/build.sh              |  8 ++-
 .../linux-packages/apt/ubuntu-trusty/Dockerfile    |  2 +
 .../linux-packages/debian.ubuntu-trusty/control    |  1 +
 .../linux-packages/debian.ubuntu-trusty/rules      |  5 +-
 dev/tasks/linux-packages/package-task.rb           | 16 +++--
 dev/tasks/linux-packages/yum/arrow.spec.in         |  5 +-
 dev/tasks/linux-packages/yum/build.sh              | 16 ++++-
 dev/tasks/linux-packages/yum/centos-7/Dockerfile   |  1 +
 9 files changed, 68 insertions(+), 63 deletions(-)

diff --git a/dev/tasks/linux-packages/Rakefile b/dev/tasks/linux-packages/Rakefile
index bce23de..d24aa11 100644
--- a/dev/tasks/linux-packages/Rakefile
+++ b/dev/tasks/linux-packages/Rakefile
@@ -21,35 +21,45 @@ require_relative "package-task"
 
 class ApacheArrowPackageTask < PackageTask
   def initialize
-    release_time = latest_commit_time(arrow_source_dir)
+    release_time = detect_release_time
     super("apache-arrow", detect_version(release_time), release_time)
     @rpm_package = "arrow"
   end
 
   private
+  def detect_release_time
+    release_time_env = ENV["ARROW_RELEASE_TIME"]
+    if release_time_env
+      Time.parse(release_time_env).utc
+    else
+      latest_commit_time(arrow_source_dir) || Time.now.utc
+    end
+  end
+
   def arrow_source_dir
     File.join(File.dirname(__FILE__), "..", "..", "..")
   end
 
   def detect_version(release_time)
+    version_env = ENV['ARROW_VERSION']
+    return version_env if version_env
+
     pom_xml_path = File.join(arrow_source_dir, "java", "pom.xml")
     version = File.read(pom_xml_path).scan(/^  <version>(.+?)<\/version>/)[0][0]
-    version = ENV['ARROW_VERSION'] || version  #try to read from env
     formatted_release_time = release_time.strftime("%Y%m%d")
-    version.gsub(/-SNAPSHOT\z/) {".#{formatted_release_time}"}
+    version.gsub(/-SNAPSHOT\z/) {"-dev#{formatted_release_time}"}
   end
 
   def define_archive_task
     file @archive_name do
-      # case @version
-      # when /\A\d+\.\d+\.\d+-rc\d+\z/
-      #   download_rc_archive
-      # when /\A\d+\.\d+\.\d+\z/
-      #   download_released_archive
-      # else
-      #   build_archive
-      # end
-      build_archive
+      case @version
+      when /\A\d+\.\d+\.\d+-rc\d+\z/
+        download_rc_archive
+      when /\A\d+\.\d+\.\d+\z/
+        download_released_archive
+      else
+        build_archive
+      end
     end
   end
 
@@ -74,48 +84,7 @@ class ApacheArrowPackageTask < PackageTask
     cd(arrow_source_dir) do
       sh("git", "archive", "HEAD",
          "--prefix", "#{@archive_base_name}/",
-         "--output", @archive_name)
-      rm_f(@archive_base_name)
-      sh("tar", "xf", @archive_name)
-      rm_f(@archive_name)
-
-      c_glib_tmp_dir = "c_glib_tmp"
-      rm_rf(c_glib_tmp_dir)
-      mkdir_p(c_glib_tmp_dir)
-      cp_r(@archive_base_name, c_glib_tmp_dir)
-      c_glib_dir = File.expand_path("#{@archive_base_name}/c_glib")
-      rm_rf(c_glib_dir)
-      cd("#{c_glib_tmp_dir}/#{@archive_base_name}") do
-        build_type = "debug"
-        cpp_dir = File.expand_path("cpp")
-        cpp_build_dir = File.expand_path("cpp_build")
-        mkdir_p(cpp_build_dir)
-        cd(cpp_build_dir) do
-          sh("cmake", cpp_dir,
-             "-DCMAKE_BUILD_TYPE=#{build_type}",
-             "-DARROW_BOOST_USE_SHARED=ON",
-             "-DARROW_BUILD_TESTS=OFF")
-          sh("make", "-j8")
-        end
-        cd("c_glib") do
-          sh("./autogen.sh")
-          sh("./configure",
-             "--with-arrow-cpp-build-dir=#{cpp_build_dir}",
-             "--with-arrow-cpp-build-type=#{build_type}",
-             "--enable-gtk-doc")
-          sh({"LD_LIBRARY_PATH" => "#{cpp_build_dir}/#{build_type}"},
-             "make", "-j8")
-          sh("make", "dist")
-          tar_gz = Dir.glob("*.tar.gz").first
-          sh("tar", "xf", tar_gz)
-          mv(File.basename(tar_gz, ".tar.gz"),
-             c_glib_dir)
-        end
-      end
-      rm_rf(c_glib_tmp_dir)
-
-      sh("tar", "czf", @full_archive_name, @archive_base_name)
-      rm_rf(@archive_base_name)
+         "--output", @full_archive_name)
     end
   end
 end
diff --git a/dev/tasks/linux-packages/apt/build.sh b/dev/tasks/linux-packages/apt/build.sh
index 2e44775..b4a3fd6 100755
--- a/dev/tasks/linux-packages/apt/build.sh
+++ b/dev/tasks/linux-packages/apt/build.sh
@@ -49,9 +49,13 @@ run cp /host/tmp/${PACKAGE}-${VERSION}.tar.gz \
 run cd build
 run tar xfz ${PACKAGE}_${VERSION}.orig.tar.gz
 case "${VERSION}" in
+  *~dev*)
+    run mv ${PACKAGE}-$(echo $VERSION | sed -e 's/~dev/-dev/') \
+        ${PACKAGE}-${VERSION}
+    ;;
   *~rc*)
-    mv ${PACKAGE}-$(echo $VERSION | sed -r -e 's/~rc[0-9]+//') \
-       ${PACKAGE}-${VERSION}
+    run mv ${PACKAGE}-$(echo $VERSION | sed -r -e 's/~rc[0-9]+//') \
+        ${PACKAGE}-${VERSION}
     ;;
 esac
 run cd ${PACKAGE}-${VERSION}/
diff --git a/dev/tasks/linux-packages/apt/ubuntu-trusty/Dockerfile b/dev/tasks/linux-packages/apt/ubuntu-trusty/Dockerfile
index dcb343b..1273287 100644
--- a/dev/tasks/linux-packages/apt/ubuntu-trusty/Dockerfile
+++ b/dev/tasks/linux-packages/apt/ubuntu-trusty/Dockerfile
@@ -25,10 +25,12 @@ RUN \
   quiet=$([ "${DEBUG}" = "yes" ] || echo "-qq") && \
   apt update ${quiet} && \
   apt install -y -V ${quiet} \
+    autoconf-archive \
     build-essential \
     cmake3 \
     debhelper\
     devscripts \
+    dh-autoreconf \
     git \
     gtk-doc-tools \
     libboost-filesystem-dev \
diff --git a/dev/tasks/linux-packages/debian.ubuntu-trusty/control b/dev/tasks/linux-packages/debian.ubuntu-trusty/control
index 298b3c7..6dfceac 100644
--- a/dev/tasks/linux-packages/debian.ubuntu-trusty/control
+++ b/dev/tasks/linux-packages/debian.ubuntu-trusty/control
@@ -4,6 +4,7 @@ Priority: optional
 Maintainer: Kouhei Sutou <ko...@clear-code.com>
 Build-Depends:
   debhelper (>= 9),
+  dh-autoreconf,
   pkg-config,
   cmake,
   git,
diff --git a/dev/tasks/linux-packages/debian.ubuntu-trusty/rules b/dev/tasks/linux-packages/debian.ubuntu-trusty/rules
index 5021f36..5dc873f 100755
--- a/dev/tasks/linux-packages/debian.ubuntu-trusty/rules
+++ b/dev/tasks/linux-packages/debian.ubuntu-trusty/rules
@@ -11,7 +11,10 @@ export DEB_BUILD_MAINT_OPTIONS=reproducible=-timeless
 BUILD_TYPE=release
 
 %:
-	dh $@ --with gir
+	dh $@ --with gir,autoreconf
+
+override_dh_autoreconf:
+	cd c_glib && ./autogen.sh
 
 override_dh_auto_configure:
 	dh_auto_configure \
diff --git a/dev/tasks/linux-packages/package-task.rb b/dev/tasks/linux-packages/package-task.rb
index b8f25ae..cc32db4 100644
--- a/dev/tasks/linux-packages/package-task.rb
+++ b/dev/tasks/linux-packages/package-task.rb
@@ -33,12 +33,12 @@ class PackageTask
 
     @rpm_package = @package
     case @version
-    when /-(rc\d+)\z/
+    when /-((?:dev|rc)\d+)\z/
       base_version = $PREMATCH
-      rc = $1
-      @deb_upstream_version = "#{base_version}~#{rc}"
+      sub_version = $1
+      @deb_upstream_version = "#{base_version}~#{sub_version}"
       @rpm_version = base_version
-      @rpm_release = "0.#{rc}"
+      @rpm_release = "0.#{sub_version}"
     else
       @deb_upstream_version = @version
       @rpm_version = @version
@@ -69,7 +69,15 @@ class PackageTask
     ENV["DEBUG"] != "no"
   end
 
+  def git_directory?(directory)
+    candidate_paths = [".git", "HEAD"]
+    candidate_paths.any? do |candidate_path|
+      File.exist?(File.join(directory, candidate_path))
+    end
+  end
+
   def latest_commit_time(git_directory)
+    return nil unless git_directory?(git_directory)
     cd(git_directory) do
       return Time.iso8601(`git log -n 1 --format=%aI`.chomp).utc
     end
diff --git a/dev/tasks/linux-packages/yum/arrow.spec.in b/dev/tasks/linux-packages/yum/arrow.spec.in
index 9a0956d..791c4eb 100644
--- a/dev/tasks/linux-packages/yum/arrow.spec.in
+++ b/dev/tasks/linux-packages/yum/arrow.spec.in
@@ -44,6 +44,7 @@ BuildRequires:	python34-devel
 BuildRequires:	python34-numpy
 %endif
 %if %{use_glib}
+BuildRequires:	autoconf-archive
 BuildRequires:	gtk-doc
 BuildRequires:	gobject-introspection-devel
 %endif
@@ -75,9 +76,11 @@ cd -
 
 %if %{use_glib}
 cd c_glib
+./autogen.sh
 %configure \
   --with-arrow-cpp-build-dir=$PWD/../cpp/build \
-  --with-arrow-cpp-build-type=$build_type
+  --with-arrow-cpp-build-type=$build_type \
+  --enable-gtk-doc
 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
 LD_LIBRARY_PATH=$PWD/arrow-glib/.libs/:$PWD/../cpp/build/$build_type \
diff --git a/dev/tasks/linux-packages/yum/build.sh b/dev/tasks/linux-packages/yum/build.sh
index fea748b..5f22056 100755
--- a/dev/tasks/linux-packages/yum/build.sh
+++ b/dev/tasks/linux-packages/yum/build.sh
@@ -71,7 +71,21 @@ run mkdir -p "${rpm_dir}" "${srpm_dir}"
 cd
 
 if [ -n "${SOURCE_ARCHIVE}" ]; then
-  run cp /host/tmp/${SOURCE_ARCHIVE} rpmbuild/SOURCES/
+  case "${RELEASE}" in
+    0.dev*)
+      run tar xf /host/tmp/${SOURCE_ARCHIVE}
+      run mv \
+          apache-${PACKAGE}-${VERSION}-$(echo $RELEASE | sed -e 's/^0\.//') \
+          apache-${PACKAGE}-${VERSION}
+      run tar czf \
+          rpmbuild/SOURCES/${SOURCE_ARCHIVE} \
+          apache-${PACKAGE}-${VERSION}
+      run rm -rf apache-${PACKAGE}-${VERSION}
+      ;;
+    *)
+      run cp /host/tmp/${SOURCE_ARCHIVE} rpmbuild/SOURCES/
+      ;;
+  esac
 else
   run cp /host/tmp/${PACKAGE}-${VERSION}.* rpmbuild/SOURCES/
 fi
diff --git a/dev/tasks/linux-packages/yum/centos-7/Dockerfile b/dev/tasks/linux-packages/yum/centos-7/Dockerfile
index 58058ee..1311a45 100644
--- a/dev/tasks/linux-packages/yum/centos-7/Dockerfile
+++ b/dev/tasks/linux-packages/yum/centos-7/Dockerfile
@@ -25,6 +25,7 @@ RUN \
   yum install -y ${quiet} epel-release && \
   yum groupinstall -y ${quiet} "Development Tools" && \
   yum install -y ${quiet} \
+    autoconf-archive \
     boost-devel \
     cmake3 \
     git \