Apache DataFusion SQL Query Engine
ARROW-7682: [Packaging] Add support for arm64 APT/Yum repositories
Sutou Kouhei45cbce642ad5
diff --git a/dev/release/.env.example b/dev/release/.env.examplenew file mode 100644index 0000000000..0126cdd3f2--- /dev/null+++ b/dev/release/.env.example@@ -0,0 +1,48 @@+# 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.++# The GPG key ID to sign artifacts. The GPG key ID must be registered+# to both of the followings:+#+# * https://dist.apache.org/repos/dist/dev/arrow/KEYS+# * https://dist.apache.org/repos/dist/release/arrow/KEYS+#+# See these files how to import your GPG key ID to these files.+#+# You must set this.+#GPG_KEY_ID=08D3564B7C6A9CAFBFF6A66791D18FCF079F8007++# The Bintray repository where artifacts are uploaded.+# You can use your Bintray repository such as kou/arrow for test.+BINTRAY_REPOSITORY=apache/arrow++# The Bintray repository where released artifacts exist.+# The released artifacts are used to build APT/Yum repository.+# The Bintray repository isn't changed. (Download only. No upload.)+#+# Normally, you don't need to change this.+SOURCE_BINTRAY_REPOSITORY=apache/arrow++# The Bintray user name to upload artifacts to Bintray.+#+# You must set this.+#BINTRAY_USER=kou++# The Bintray API key to upload artifacts to Bintray.+#+# You must set this.+#BINTRAY_API_KEY=secretdiff --git a/dev/release/.gitignore b/dev/release/.gitignorenew file mode 100644index 0000000000..f32fcb03c6--- /dev/null+++ b/dev/release/.gitignore@@ -0,0 +1,19 @@+# 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.++/.env+/binary/tmp/diff --git a/dev/release/03-binary.sh b/dev/release/03-binary.shindex 400ddcd0bf..696790c7a0 100755--- a/dev/release/03-binary.sh+++ b/dev/release/03-binary.sh@@ -1,5 +1,4 @@#!/bin/bash-# -*- indent-tabs-mode: nil; sh-indentation: 2; sh-basic-offset: 2 -*-## Licensed to the Apache Software Foundation (ASF) under one# or more contributor license agreements. See the NOTICE file@@ -17,33 +16,21 @@# KIND, either express or implied. See the License for the# specific language governing permissions and limitations# under the License.-#+set -eset -uset -o pipefail-SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"+SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"-if [ "$#" -ne 4 ]; then- echo "Usage: $0 <version> <rc-num> <gpg-key-id> <artifact-dir>"+if [ "$#" -ne 3 ]; then+ echo "Usage: $0 <version> <rc-num> <artifact-dir>"exitfiversion=$1rc=$2-gpg_key_id=$3-artifact_dir=$4--docker_image_name=apache-arrow/release-binary-gpg_agent_extra_socket="$(gpgconf --list-dirs agent-extra-socket)"-if [ $(uname) = "Darwin" ]; then- docker_uid=10000- docker_gid=10000-else- docker_uid=$(id -u)- docker_gid=$(id -g)-fi-docker_ssh_key="${SOURCE_DIR}/binary/id_rsa"+artifact_dir=$3if [ -z "$artifact_dir" ]; thenecho "artifact_dir is empty"@@ -60,474 +47,29 @@ if [ ! -d "$artifact_dir" ]; thenexit 1fi-if [ -z "${BINTRAY_PASSWORD}" ]; then- echo "BINTRAY_PASSWORD is empty"- exit 1-fi+artifact_dir="$(pwd)/${artifact_dir}"-if ! jq --help > /dev/null 2>&1; then- echo "jq is required"- exit 1-fi+cd "${SOURCE_DIR}"-: ${BINTRAY_REPOSITORY:=apache/arrow}-: ${SOURCE_BINTRAY_REPOSITORY:=${BINTRAY_REPOSITORY}}+: ${BINTRAY_REPOSITORY_CUSTOM:=${BINTRAY_REPOSITORY:-}}+: ${SOURCE_BINTRAY_REPOSITORY_CUSTOM:=${SOURCE_BINTRAY_REPOSITORY:-}}}-BINTRAY_DOWNLOAD_URL_BASE=https://dl.bintray.com--docker_run() {- docker \- run \- --rm \- --tty \- --interactive \- --user ${docker_uid}:${docker_gid} \- --volume "$PWD":/host \- ${docker_image_name} \- bash -c "cd /host && $*"-}--docker_gpg_ssh() {- local ssh_port=$1- shift- local known_hosts_file=$(mktemp -t "arrow-binary-gpg-ssh-known-hosts.XXXXX")- local exit_code=- if ssh \- -o StrictHostKeyChecking=no \- -o UserKnownHostsFile=${known_hosts_file} \- -i "${docker_ssh_key}" \- -p ${ssh_port} \- -R "/home/arrow/.gnupg/S.gpg-agent:${gpg_agent_extra_socket}" \- "$@"; then- exit_code=$?;- else- exit_code=$?;- fi- rm -f ${known_hosts_file}- return ${exit_code}-}--docker_run_gpg_ready() {- local container_id_dir=$(mktemp -d -t "arrow-binary-gpg-container.XXXXX")- local container_id_file=${container_id_dir}/id- docker \- run \- --rm \- --detach \- --cidfile ${container_id_file} \- --publish-all \- --volume "$PWD":/host \- ${docker_image_name} \- bash -c "-if [ \$(id -u) -ne ${docker_uid} ]; then- usermod --uid ${docker_uid} arrow- chown -R arrow: ~arrow+if [ ! -f .env ]; then+ echo "You must create $(pwd)/.env"+ echo "You can use $(pwd)/.env.example as template"+ exit 1fi-/usr/sbin/sshd -D-"- local container_id=$(cat ${container_id_file})- local ssh_port=$(docker port ${container_id} | grep -E -o '[0-9]+$')- # Wait for sshd available- while ! docker_gpg_ssh ${ssh_port} : > /dev/null 2>&1; do- sleep 0.1- done- gpg --export ${gpg_key_id} | docker_gpg_ssh ${ssh_port} gpg --import- docker_gpg_ssh ${ssh_port} "cd /host && $@"- docker kill ${container_id}- rm -rf ${container_id_dir}-}--bintray() {- local command=$1- shift- local path=$1- shift- local url=https://bintray.com/api/v1${path}- echo "${command} ${url}" 1>&2- curl \- --fail \- --basic \- --user "${BINTRAY_USER:-$USER}:${BINTRAY_PASSWORD}" \- --header "Content-Type: application/json" \- --request ${command} \- ${url} \- "$@" | \- jq .-}--ensure_version() {- local version=$1- local rc=$2- local target=$3-- local version_name=${version}-rc${rc}-- if ! bintray \- GET \- /packages/${BINTRAY_REPOSITORY}/${target}-rc/versions/${version_name}; then- bintray \- POST /packages/${BINTRAY_REPOSITORY}/${target}-rc/versions \- --data-binary "-{- \"name\": \"${version_name}\",- \"desc\": \"Apache Arrow ${version} RC${rc}.\"-}-"- fi-}--download_files() {- local version=$1- local rc=$2- local target=$3-- local version_name=${version}-rc${rc}-- local files=$(- bintray \- GET /packages/${SOURCE_BINTRAY_REPOSITORY}/${target}-rc/versions/${version_name}/files | \- jq -r ".[].path")-- local file=- for file in ${files}; do- mkdir -p "$(dirname ${file})"- curl \- --fail \- --location \- --output ${file} \- ${BINTRAY_DOWNLOAD_URL_BASE}/${SOURCE_BINTRAY_REPOSITORY}/${file}- done-}--delete_file() {- local version=$1- local rc=$2- local target=$3- local upload_path=$4-- local version_name=${version}-rc${rc}-- bintray \- DELETE /content/${BINTRAY_REPOSITORY}/${target}-rc/${upload_path}-}--upload_file() {- local version=$1- local rc=$2- local target=$3- local local_path=$4- local upload_path=$5-- local version_name=${version}-rc${rc}-- local sha256=$(shasum -a 256 ${local_path} | awk '{print $1}')- local request_path=/content/${BINTRAY_REPOSITORY}/${target}-rc/${version_name}/${target}-rc/${upload_path}- if ! bintray \- PUT ${request_path} \- --header "X-Bintray-Publish: 1" \- --header "X-Bintray-Override: 1" \- --header "X-Checksum-Sha2: ${sha256}" \- --data-binary "@${local_path}"; then- delete_file ${version} ${rc} ${target} ${upload_path}- bintray \- PUT ${request_path} \- --header "X-Bintray-Publish: 1" \- --header "X-Bintray-Override: 1" \- --header "X-Checksum-Sha2: ${sha256}" \- --data-binary "@${local_path}"- fi-}--sign_and_upload_file() {- local version=$1- local rc=$2- local target=$3- local local_path=$4- local upload_path=$5-- local sha256=$(shasum -a 256 ${local_path} | awk '{print $1}')- local download_path=/${BINTRAY_REPOSITORY}/${target}-rc/${upload_path}- local source_upload=no- if ! curl \- --fail \- --head \- ${BINTRAY_DOWNLOAD_URL_BASE}${download_path} | \- grep -q "^X-Checksum-Sha2: ${sha256}"; then- upload_file ${version} ${rc} ${target} ${local_path} ${upload_path}- source_upload=yes- fi-- local suffix=- for suffix in asc sha512; do- pushd $(dirname ${local_path})- local local_path_base=$(basename ${local_path})- local output_dir=$(mktemp -d -t "arrow-binary-sign.XXXXX")- local output=${output_dir}/tmp.${suffix}- case $suffix in- asc)- gpg \- --local-user ${gpg_key_id} \- --detach-sig \- --output ${output} \- ${local_path_base}- ;;- sha*)- shasum \- --algorithm $(echo $suffix | sed -e 's/^sha//') \- ${local_path_base} > ${output}- ;;- esac- local need_upload=no- if [ "${source_upload}" = "yes" ]; then- need_upload=yes- elif ! curl \- --fail \- --head \- ${BINTRAY_DOWNLOAD_URL_BASE}${download_path}.${suffix}; then- need_upload=yes- fi- if [ "${need_upload}" = "yes" ]; then- upload_file ${version} ${rc} ${target} ${output} ${upload_path}.${suffix}- fi- rm -rf ${output_dir}- popd- done-}+. .env-upload_deb_file() {- local version=$1- local rc=$2- local distribution=$3- local code_name=$4- local base_path=$5-- case ${base_path} in- *.dsc|*.changes)- docker_run_gpg_ready debsign -k${gpg_key_id} --re-sign ${base_path}- ;;- *.asc|*.sha256|*.sha512)- return- ;;- esac- sign_and_upload_file \- ${version} \- ${rc} \- ${distribution} \- ${base_path} \- pool/${code_name}/main/a/apache-arrow/${base_path}-}--upload_deb() {- local version=$1- local rc=$2- local distribution=$3- local code_name=$4-- local base_path=- for base_path in *; do- upload_deb_file ${version} ${rc} ${distribution} ${code_name} ${base_path}- done-}--upload_apt() {- local version=$1- local rc=$2- local distribution=$3-- local tmp_dir=tmp/${distribution}- rm -rf ${tmp_dir}- mkdir -p ${tmp_dir}- pushd ${tmp_dir}-- download_files ${version} ${rc} ${distribution}-- pushd ${distribution}-rc-- local keyring_name=apache-arrow-keyring.gpg- rm -f ${keyring_name}- curl --fail https://dist.apache.org/repos/dist/dev/arrow/KEYS | \- gpg \- --no-default-keyring \- --keyring ./${keyring_name} \- --import - || : # XXX: Ignore gpg error- sign_and_upload_file \- ${version} \- ${rc} \- ${distribution} \- ${keyring_name} \- ${keyring_name}-- local pool_code_name=- for pool_code_name in pool/*; do- local code_name=$(basename ${pool_code_name})- local dist=dists/${code_name}/main- rm -rf dists- mkdir -p ${dist}/{source,binary-amd64}- docker_run apt-ftparchive \- sources pool/${code_name} > \- dists/${code_name}/main/source/Sources- gzip --keep dists/${code_name}/main/source/Sources- xz --keep dists/${code_name}/main/source/Sources- docker_run apt-ftparchive \- packages pool/${code_name} > \- dists/${code_name}/main/binary-amd64/Packages- gzip --keep dists/${code_name}/main/binary-amd64/Packages- xz --keep dists/${code_name}/main/binary-amd64/Packages- docker_run apt-ftparchive \- contents pool/${code_name} > \- dists/${code_name}/main/Contents-amd64- gzip --keep dists/${code_name}/main/Contents-amd64- docker_run apt-ftparchive \- release \- -o "APT::FTPArchive::Release::Origin=Apache\\ Arrow" \- -o "APT::FTPArchive::Release::Label=Apache\\ Arrow" \- -o APT::FTPArchive::Release::Codename=${code_name} \- -o APT::FTPArchive::Release::Architectures=amd64 \- -o APT::FTPArchive::Release::Components=main \- dists/${code_name} > \- dists/${code_name}/Release- gpg \- --local-user ${gpg_key_id} \- --sign \- --detach-sign \- --armor \- --output dists/${code_name}/Release.gpg \- dists/${code_name}/Release-- local path=- for path in $(find dists/${code_name}/ -type f); do- sign_and_upload_file \- ${version} \- ${rc} \- ${distribution} \- ${path} \- ${path}- done- done- popd-- popd- rm -rf ${tmp_dir}-}--upload_rpm_file() {- local version=$1- local rc=$2- local distribution=$3- local distribution_version=$4- local rpm_path=$5-- local upload_path=${distribution_version}-- case ${rpm_path} in- *.src.rpm)- upload_path=${upload_path}/Source/SPackages- ;;- *)- upload_path=${upload_path}/x86_64/Packages- ;;- esac- upload_path=${upload_path}/${rpm_path}- docker_run_gpg_ready rpm \- -D "_gpg_name\\ ${gpg_key_id}" \- --addsign \- ${rpm_path}- sign_and_upload_file \- ${version} \- ${rc} \- ${distribution} \- ${rpm_path} \- ${upload_path}-}--upload_rpm() {- local version=$1- local rc=$2- local distribution=$3- local distribution_version=$4-- local rpm_path=- for rpm_path in *.rpm; do- upload_rpm_file \- ${version} \- ${rc} \- ${distribution} \- ${distribution_version} \- ${rpm_path}- done-}--upload_yum() {- local version=$1- local rc=$2- local distribution=$3-- local version_name=${version}-rc${rc}-- local tmp_dir=tmp/${distribution}- rm -rf ${tmp_dir}- mkdir -p ${tmp_dir}- pushd ${tmp_dir}-- download_files ${version} ${rc} ${distribution}-- pushd ${distribution}-rc- local keyring_name=RPM-GPG-KEY-apache-arrow- curl -o ${keyring_name} https://dist.apache.org/repos/dist/dev/arrow/KEYS- sign_and_upload_file \- ${version} \- ${rc} \- ${distribution} \- ${keyring_name} \- ${keyring_name}- local version_dir=- local arch_dir=- local repo_path=- for version_dir in $(find . -mindepth 1 -maxdepth 1 -type d); do- for arch_dir in ${version_dir}/*; do- mkdir -p ${arch_dir}/repodata/- docker_run createrepo ${arch_dir}- for repo_path in ${arch_dir}/repodata/*; do- sign_and_upload_file \- ${version} \- ${rc} \- ${distribution} \- ${repo_path} \- ${repo_path}- done- done- done- popd-- popd- rm -rf ${tmp_dir}-}--upload_python() {- local version=$1- local rc=$2- local target=python-- local base_path=- for base_path in *; do- case ${base_path} in- *.asc|*.sha256|*.sha512)- continue- ;;- esac- sign_and_upload_file \- ${version} \- ${rc} \- ${target} \- ${base_path} \- ${version}-rc${rc}/${base_path}- done-}+if [ -n "${BINTRAY_REPOSITORY_CUSTOM}" ]; then+ BINTRAY_REPOSITORY=${BINTRAY_REPOSITORY_CUSTOM}+fi-docker build -t ${docker_image_name} ${SOURCE_DIR}/binary+if [ -n "${SOURCE_BINTRAY_REPOSITORY_CUSTOM}" ]; then+ SOURCE_BINTRAY_REPOSITORY=${SOURCE_BINTRAY_REPOSITORY_CUSTOM}+fi-chmod go-rwx "${docker_ssh_key}"+. binary-common.sh# By default upload all artifacts.# To deactivate one category, deactivate the category and all of its dependents.@@ -541,104 +83,52 @@ chmod go-rwx "${docker_ssh_key}": ${UPLOAD_UBUNTU_APT:=${UPLOAD_DEFAULT}}: ${UPLOAD_UBUNTU_DEB:=${UPLOAD_DEFAULT}}-have_debian=no-have_ubuntu=no-have_centos=no-have_python=no-pushd "${artifact_dir}"-for dir in *; do- is_deb=no- is_rpm=no- is_python=no- case ${dir} in- debian-*)- distribution=debian- code_name=$(echo ${dir} | sed -e 's/^debian-//')- is_deb=yes- have_debian=yes- ;;- ubuntu-*)- distribution=ubuntu- code_name=$(echo ${dir} | sed -e 's/^ubuntu-//')- is_deb=yes- have_ubuntu=yes- ;;- centos-*)- distribution=centos- distribution_version=$(echo ${dir} | sed -e 's/^centos-//')- is_rpm=yes- have_centos=yes- ;;- conda-*|wheel-*)- is_python=yes- have_python=yes- ;;- esac-- if [ ${is_deb} = "yes" ]; then- pushd ${dir}- case ${distribution} in- debian)- if [ ${UPLOAD_DEBIAN_DEB} -gt 0 ]; then- ensure_version ${version} ${rc} ${distribution}- upload_deb ${version} ${rc} ${distribution} ${code_name}- fi- ;;- ubuntu)- if [ ${UPLOAD_UBUNTU_DEB} -gt 0 ]; then- ensure_version ${version} ${rc} ${distribution}- upload_deb ${version} ${rc} ${distribution} ${code_name}- fi- ;;- esac- popd- elif [ ${is_rpm} = "yes" ]; then- pushd ${dir}- if [ ${UPLOAD_CENTOS_RPM} -gt 0 ]; then- ensure_version ${version} ${rc} ${distribution}- upload_rpm ${version} ${rc} ${distribution} ${distribution_version}- fi- popd- elif [ ${is_python} = "yes" ]; then- pushd ${dir}- if [ ${UPLOAD_PYTHON} -gt 0 ]; then- ensure_version ${version} ${rc} python- upload_python ${version} ${rc}- fi- popd- fi-done-popd--if [ ${have_debian} = "yes" ]; then- if [ ${UPLOAD_DEBIAN_APT} -gt 0 ]; then- ensure_version ${version} ${rc} debian- upload_apt ${version} ${rc} debian- fi+rake_tasks=()+apt_targets=()+yum_targets=()+if [ ${UPLOAD_DEBIAN_DEB} -gt 0 ]; then+ rake_tasks+=(deb)+ apt_targets+=(debian)fi-if [ ${have_ubuntu} = "yes" ]; then- if [ ${UPLOAD_UBUNTU_APT} -gt 0 ]; then- ensure_version ${version} ${rc} ubuntu- upload_apt ${version} ${rc} ubuntu- fi+if [ ${UPLOAD_DEBIAN_APT} -gt 0 ]; then+ rake_tasks+=(apt:rc)+ apt_targets+=(debian)fi-if [ ${have_centos} = "yes" ]; then- if [ ${UPLOAD_CENTOS_YUM} -gt 0 ]; then- ensure_version ${version} ${rc} centos- upload_yum ${version} ${rc} centos- fi+if [ ${UPLOAD_UBUNTU_DEB} -gt 0 ]; then+ rake_tasks+=(deb)+ apt_targets+=(ubuntu)fi--echo "Success! The release candidate binaries are available here:"-if [ ${have_debian} = "yes" ]; then- echo " https://bintray.com/${BINTRAY_REPOSITORY}/debian-rc/${version}-rc${rc}"+if [ ${UPLOAD_UBUNTU_APT} -gt 0 ]; then+ rake_tasks+=(apt:rc)+ apt_targets+=(ubuntu)fi-if [ ${have_ubuntu} = "yes" ]; then- echo " https://bintray.com/${BINTRAY_REPOSITORY}/ubuntu-rc/${version}-rc${rc}"+if [ ${UPLOAD_CENTOS_RPM} -gt 0 ]; then+ rake_tasks+=(rpm)+ yum_targets+=(centos)fi-if [ ${have_centos} = "yes" ]; then- echo " https://bintray.com/${BINTRAY_REPOSITORY}/centos-rc/${version}-rc${rc}"+if [ ${UPLOAD_CENTOS_YUM} -gt 0 ]; then+ rake_tasks+=(yum:rc)+ yum_targets+=(centos)fi-if [ ${have_python} = "yes" ]; then- echo " https://bintray.com/${BINTRAY_REPOSITORY}/python-rc/${version}-rc${rc}"+if [ ${UPLOAD_PYTHON} -gt 0 ]; then+ rake_tasks+=(python:rc)fi+rake_tasks+=(summary:rc)++tmp_dir=binary/tmp+mkdir -p "${tmp_dir}"+source_artifacts_dir="${tmp_dir}/artifacts"+rm -rf "${source_artifacts_dir}"+cp -a "${artifact_dir}" "${source_artifacts_dir}"++docker_run \+ ./runner.sh \+ rake \+ "${rake_tasks[@]}" \+ APT_TARGETS=$(IFS=,; echo "${apt_targets[*]}") \+ ARTIFACTS_DIR="${tmp_dir}/artifacts" \+ BINTRAY_REPOSITORY=${BINTRAY_REPOSITORY} \+ RC=${rc} \+ SOURCE_BINTRAY_REPOSITORY=${SOURCE_BINTRAY_REPOSITORY} \+ VERSION=${version} \+ YUM_TARGETS=$(IFS=,; echo "${yum_targets[*]}")diff --git a/dev/release/Rakefile b/dev/release/Rakefilenew file mode 100644index 0000000000..ff57bad5e8--- /dev/null+++ b/dev/release/Rakefile@@ -0,0 +1,37 @@+# -*- ruby -*-+#+# 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.++require_relative "binary-task"++if File.exist?(".env")+ File.open(".env") do |env|+ env.each_line do |line|+ case line.strip+ when /\A#/+ when /\A([^=]+)=(.*)\z/+ key = $1+ value = $2+ ENV[key] ||= value+ end+ end+ end+end++binary_task = BinaryTask.new+binary_task.definediff --git a/dev/release/binary-common.sh b/dev/release/binary-common.shnew file mode 100644index 0000000000..414638436c--- /dev/null+++ b/dev/release/binary-common.sh@@ -0,0 +1,82 @@+# 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.++docker_image_name=apache-arrow/release-binary+gpg_agent_extra_socket="$(gpgconf --list-dirs agent-extra-socket)"+if [ $(uname) = "Darwin" ]; then+ docker_uid=10000+ docker_gid=10000+else+ docker_uid=$(id -u)+ docker_gid=$(id -g)+fi+docker_ssh_key="${SOURCE_DIR}/binary/id_rsa"++docker_gpg_ssh() {+ local ssh_port=$1+ shift+ local known_hosts_file=$(mktemp -t "arrow-binary-gpg-ssh-known-hosts.XXXXX")+ local exit_code=+ if ssh \+ -o StrictHostKeyChecking=no \+ -o UserKnownHostsFile=${known_hosts_file} \+ -i "${docker_ssh_key}" \+ -p ${ssh_port} \+ -R "/home/arrow/.gnupg/S.gpg-agent:${gpg_agent_extra_socket}" \+ "$@"; then+ exit_code=$?;+ else+ exit_code=$?;+ fi+ rm -f ${known_hosts_file}+ return ${exit_code}+}++docker_run() {+ local container_id_dir=$(mktemp -d -t "arrow-binary-gpg-container.XXXXX")+ local container_id_file=${container_id_dir}/id+ docker \+ run \+ --cidfile ${container_id_file} \+ --detach \+ --publish-all \+ --rm \+ --volume "$PWD":/host \+ ${docker_image_name} \+ bash -c "+if [ \$(id -u) -ne ${docker_uid} ]; then+ usermod --uid ${docker_uid} arrow+ chown -R arrow: ~arrow+fi+/usr/sbin/sshd -D+"+ local container_id=$(cat ${container_id_file})+ local ssh_port=$(docker port ${container_id} | grep -E -o '[0-9]+$')+ # Wait for sshd available+ while ! docker_gpg_ssh ${ssh_port} : > /dev/null 2>&1; do+ sleep 0.1+ done+ gpg --export ${GPG_KEY_ID} | docker_gpg_ssh ${ssh_port} gpg --import+ docker_gpg_ssh ${ssh_port} "$@"+ docker kill ${container_id}+ rm -rf ${container_id_dir}+}++docker build -t ${docker_image_name} "${SOURCE_DIR}/binary"++chmod go-rwx "${docker_ssh_key}"diff --git a/dev/release/binary-task.rb b/dev/release/binary-task.rbnew file mode 100644index 0000000000..baaf9f869e--- /dev/null+++ b/dev/release/binary-task.rb@@ -0,0 +1,1815 @@+# 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.++require "digest/sha2"+require "io/console"+require "json"+require "net/http"+require "pathname"+require "tempfile"+require "thread"+require "time"++class BinaryTask+ include Rake::DSL++ class ThreadPool+ def initialize(n_workers=nil, &worker)+ @n_workers = n_workers || detect_n_processors+ @worker = worker+ @jobs = Thread::Queue.new+ @workers = @n_workers.times.collect do+ Thread.new do+ loop do+ job = @jobs.pop+ break if job.nil?+ @worker.call(job)+ end+ end+ end+ end++ def <<(job)+ @jobs << job+ end++ def join+ @n_workers.times do+ @jobs << nil+ end+ @workers.each(&:join)+ end++ private+ def detect_n_processors+ if File.exist?("/proc/cpuinfo")+ File.readlines("/proc/cpuinfo").grep(/^processor/).size+ else+ 8+ end+ end+ end++ class ProgressReporter+ def initialize(label, count_max=0)+ @label = label+ @count_max = count_max++ @mutex = Thread::Mutex.new++ @time_start = Time.now+ @time_previous = Time.now+ @count_current = 0+ @count_previous = 0+ end++ def advance+ @mutex.synchronize do+ @count_current += 1++ return if @count_max.zero?++ time_current = Time.now+ if time_current - @time_previous <= 1+ return+ end++ show_progress(time_current)+ end+ end++ def increment_max+ @mutex.synchronize do+ @count_max += 1+ end+ end++ def finish+ @mutex.synchronize do+ return if @count_max.zero?+ show_progress(Time.now)+ $stderr.puts+ end+ end++ private+ def show_progress(time_current)+ n_finishes = @count_current - @count_previous+ throughput = n_finishes.to_f / (time_current - @time_previous)+ @time_previous = time_current+ @count_previous = @count_current++ message = build_message(time_current, throughput)+ $stderr.print("\r#{message}") if message+ end++ def build_message(time_current, throughput)+ percent = (@count_current / @count_max.to_f) * 100+ formatted_count = "[%s/%s]" % [+ format_count(@count_current),+ format_count(@count_max),+ ]+ elapsed_second = time_current - @time_start+ if throughput.zero?+ rest_second = 0+ else+ rest_second = (@count_max - @count_current) / throughput+ end+ separator = " - "+ progress = "%5.1f%% %s %s %s %s" % [+ percent,+ formatted_count,+ format_time_interval(elapsed_second),+ format_time_interval(rest_second),+ format_throughput(throughput),+ ]+ label = @label++ width = guess_terminal_width+ return "#{label}#{separator}#{progress}" if width.nil?++ return nil if progress.size > width++ label_width = width - progress.size - separator.size+ if label.size > label_width+ ellipsis = "..."+ shorten_label_width = label_width - ellipsis.size+ if shorten_label_width < 1+ return progress+ else+ label = label[0, shorten_label_width] + ellipsis+ end+ end+ "#{label}#{separator}#{progress}"+ end++ def format_count(count)+ "%d" % count+ end++ def format_time_interval(interval)+ if interval < 60+ "00:00:%02d" % interval+ elsif interval < (60 * 60)+ minute, second = interval.divmod(60)+ "00:%02d:%02d" % [minute, second]+ elsif interval < (60 * 60 * 24)+ minute, second = interval.divmod(60)+ hour, minute = minute.divmod(60)+ "%02d:%02d:%02d" % [hour, minute, second]+ else+ minute, second = interval.divmod(60)+ hour, minute = minute.divmod(60)+ day, hour = hour.divmod(24)+ "%dd %02d:%02d:%02d" % [day, hour, minute, second]+ end+ end++ def format_throughput(throughput)+ "%2d/s" % throughput+ end++ def guess_terminal_width+ guess_terminal_width_from_io ||+ guess_terminal_width_from_command ||+ guess_terminal_width_from_env ||+ 80+ end++ def guess_terminal_width_from_io+ if IO.respond_to?(:console) and IO.console+ IO.console.winsize[1]+ elsif $stderr.respond_to?(:winsize)+ begin+ $stderr.winsize[1]+ rescue SystemCallError+ nil+ end+ else+ nil+ end+ end++ def guess_terminal_width_from_command+ IO.pipe do |input, output|+ begin+ pid = spawn("tput", "cols", {:out => output, :err => output})+ rescue SystemCallError+ return nil+ end++ output.close+ _, status = Process.waitpid2(pid)+ return nil unless status.success?++ result = input.read.chomp+ begin+ Integer(result, 10)+ rescue ArgumentError+ nil+ end+ end+ end++ def guess_terminal_width_from_env+ env = ENV["COLUMNS"] || ENV["TERM_WIDTH"]+ return nil if env.nil?++ begin+ Integer(env, 10)+ rescue ArgumentError+ nil+ end+ end+ end++ class BintrayClient+ class Error < StandardError+ attr_reader :request+ attr_reader :response+ def initialize(request, response, message)+ @request = request+ @response = response+ super(message)+ end+ end++ def initialize(options={})+ @options = options+ repository = @options[:repository]+ @subject, @repository = repository.split("/", 2) if repository+ @package = @options[:package]+ @version = @options[:version]+ @user = @options[:user]+ @api_key = @options[:api_key]+ end++ def request(method, headers, *components, &block)+ url = build_request_url(*components)+ http = Net::HTTP.new(url.host, url.port)+ http.set_debug_output($stderr) if ENV["DEBUG"]+ http.use_ssl = true+ http.start do |http|+ request = build_request(method, url, headers, &block)+ http.request(request) do |response|+ case response+ when Net::HTTPSuccess+ return JSON.parse(response.body)+ else+ message = "failed to request: "+ message << "#{url}: #{request.method}: "+ message << "#{response.message} #{response.code}:\n"+ message << response.body+ raise Error.new(request, response, message)+ end+ end+ end+ end++ def repository+ request(:get,+ {},+ "repos",+ @subject,+ @repository)+ end++ def create_repository+ request(:post,+ {},+ "repos",+ @subject,+ @repository) do+ request = {+ "name" => @repository,+ "desc" => "Apache Arrow",+ }+ JSON.generate(request)+ end+ end++ def ensure_repository+ begin+ repository+ rescue Error => error+ case error.response+ when Net::HTTPNotFound+ create_repository+ else+ raise+ end+ end+ end++ def package+ request(:get,+ {},+ "packages",+ @subject,+ @repository,+ @package)+ end++ def package_versions+ begin+ package["versions"]+ rescue Error => error+ case error.response+ when Net::HTTPNotFound+ []+ else+ raise+ end+ end+ end++ def create_package(description)+ request(:post,+ {},+ "packages",+ @subject,+ @repository) do+ request = {+ "name" => @package,+ "desc" => description,+ "licenses" => ["Apache-2.0"],+ "vcs_url" => "https://github.com/apache/arrow.git",+ "website_url" => "https://arrow.apache.org/",+ "issue_tracker_url" => "https://issues.apache.org/jira/browse/ARROW",+ "github_repo" => "apache/arrow",+ "public_download_numbers" => true,+ "public_stats" => true,+ }+ JSON.generate(request)+ end+ end++ def ensure_package(description)+ begin+ package+ rescue Error => error+ case error.response+ when Net::HTTPNotFound+ create_package(description)+ else+ raise+ end+ end+ end++ def create_version(description)+ request(:post,+ {},+ "packages",+ @subject,+ @repository,+ @package,+ "versions") do+ request = {+ "name" => @version,+ "desc" => description,+ }+ JSON.generate(request)+ end+ end++ def ensure_version(version, description)+ return if package["versions"].include?(version)+ create_version(description)+ end++ def files+ request(:get,+ {},+ "packages",+ @subject,+ @repository,+ @package,+ "versions",+ @version,+ "files")+ end++ def upload(path, destination_path)+ sha256 = Digest::SHA256.file(path).hexdigest+ headers = {+ "X-Bintray-Override" => "1",+ "X-Bintray-Package" => @package,+ "X-Bintray-Publish" => "1",+ "X-Bintray-Version" => @version,+ "X-Checksum-Sha2" => sha256,+ "Content-Length" => File.size(path).to_s,+ }+ File.open(path, "rb") do |input|+ request(:put,+ headers,+ "content",+ @subject,+ @repository,+ destination_path) do+ input+ end+ end+ end++ def delete(path)+ request(:delete,+ {},+ "content",+ @subject,+ @repository,+ path)+ end++ private+ def build_request_url(*components)+ if components.last.is_a?(Hash)+ parameters = components.pop+ else+ parameters = nil+ end+ path = components.join("/")+ url = "https://bintray.com/api/v1/#{path}"+ if parameters+ separator = "?"+ parameters.each do |key, value|+ url << "#{separator}#{CGI.escape(key)}=#{CGI.escape(value)}"+ separator = "&"+ end+ end+ URI(url)+ end++ def build_request(method, url, headers, &block)+ case method+ when :get+ request = Net::HTTP::Get.new(url, headers)+ when :post+ request = Net::HTTP::Post.new(url, headers)+ when :put+ request = Net::HTTP::Put.new(url, headers)+ when :delete+ request = Net::HTTP::Delete.new(url, headers)+ else+ raise "unsupported HTTP method: #{method.inspect}"+ end+ request.basic_auth(@user, @api_key) if @user and @api_key+ if block_given?+ request["Content-Type"] = "application/json"+ body = yield+ if body.is_a?(String)+ request.body = body+ else+ request.body_stream = body+ end+ end+ request+ end+ end++ module HashChekable+ def same_hash?(path, sha256)+ return false unless File.exist?(path)+ Digest::SHA256.file(path).hexdigest == sha256+ end+ end++ class BintrayDownloader+ include HashChekable++ def initialize(repository:,+ distribution:,+ version:,+ rc: nil,+ destination:,+ user:,+ api_key:)+ @repository = repository+ @distribution = distribution+ @version = version+ @rc = rc+ @destination = destination+ @user = user+ @api_key = api_key+ end++ def download+ client.ensure_repository++ progress_label = "Downloading: #{package} #{full_version}"+ progress_reporter = ProgressReporter.new(progress_label)+ pool = ThreadPool.new do |path, output_path|+ download_file(path, output_path)+ progress_reporter.advance+ end+ target_files.each do |file|+ path = file["path"]+ path_without_package = path.split("/", 2)[1..-1].join("/")+ output_path = "#{@destination}/#{path_without_package}"+ yield(output_path)+ sha256 = file["sha256"]+ next if same_hash?(output_path, sha256)+ output_dir = File.dirname(output_path)+ FileUtils.mkdir_p(output_dir)+ progress_reporter.increment_max+ pool << [path, output_path]+ end+ pool.join+ progress_reporter.finish+ end++ private+ def package+ if @rc+ "#{@distribution}-rc"+ else+ @distribution+ end+ end++ def full_version+ if @rc+ "#{@version}-rc#{@rc}"+ else+ @version+ end+ end++ def client(options={})+ default_options = {+ repository: @repository,+ package: package,+ version: full_version,+ user: @user,+ api_key: @api_key,+ }+ BintrayClient.new(default_options.merge(options))+ end++ def target_files+ begin+ client.files+ rescue BintrayClient::Error+ []+ end+ end++ def download_file(path, output_path)+ max_n_retries = 3+ n_retries = 0+ url = URI("https://dl.bintray.com/#{@repository}/#{path}")+ begin+ download_url(url, output_path)+ rescue SocketError, Timeout::Error => error+ n_retries += 1+ if n_retries <= max_n_retries+ $stderr.puts+ $stderr.puts("Retry #{n_retries}: #{url}: " ++ "#{error.class}: #{error.message}")+ retry+ else+ raise+ end+ end+ end++ def download_url(url, output_path)+ loop do+ http = Net::HTTP.new(url.host, url.port)+ http.set_debug_output($stderr) if ENV["DEBUG"]+ http.use_ssl = true+ http.start do |http|+ request = Net::HTTP::Get.new(url)+ http.request(request) do |response|+ case response+ when Net::HTTPSuccess+ save_response(response, output_path)+ return+ when Net::HTTPRedirection+ url = URI(response["Location"])+ when Net::HTTPNotFound+ $stderr.puts(build_download_error_message(url, response))+ return+ else+ raise message+ end+ end+ end+ end+ end++ def save_response(response, output_path)+ File.open(output_path, "wb") do |output|+ response.read_body do |chunk|+ output.print(chunk)+ end+ end+ last_modified = response["Last-Modified"]+ if last_modified+ FileUtils.touch(output_path, mtime: Time.rfc2822(last_modified))+ end+ end++ def build_download_error_message(url, response)+ message = "failed to download: "+ message << "#{url}: #{response.message} #{response.code}:\n"+ message << response.body+ message+ end+ end++ class BintrayUploader+ include HashChekable++ def initialize(repository:,+ distribution:,+ version:,+ rc: nil,+ source:,+ destination_prefix: "",+ user:,+ api_key:)+ @repository = repository+ @distribution = distribution+ @version = version+ @rc = rc+ @source = source+ @destination_prefix = destination_prefix+ @user = user+ @api_key = api_key+ end++ def upload+ client.ensure_repository+ client.ensure_package(package_description)+ client.ensure_version(full_version, version_description)++ progress_label = "Uploading: #{package} #{full_version}"+ progress_reporter = ProgressReporter.new(progress_label)+ pool = ThreadPool.new do |path, relative_path|+ upload_file(path, relative_path)+ progress_reporter.advance+ end++ files = existing_files+ source = Pathname(@source)+ source.glob("**/*") do |path|+ next if path.directory?+ destination_path =+ "#{package}/#{@destination_prefix}#{path.relative_path_from(source)}"+ file = files[destination_path]+ next if file and same_hash?(path.to_s, file["sha256"])+ progress_reporter.increment_max+ pool << [path, destination_path]+ end+ pool.join+ progress_reporter.finish+ end++ private+ def package+ if @rc+ "#{@distribution}-rc"+ else+ @distribution+ end+ end++ def full_version+ if @rc+ "#{@version}-rc#{@rc}"+ else+ @version+ end+ end++ def package_description+ if @rc+ release_type = "RC"+ else+ release_type = "Release"+ end+ case @distribution+ when "debian"+ "#{release_type} deb packages for Debian"+ when "ubuntu"+ "#{release_type} deb packages for Ubuntu"+ when "centos"+ "#{release_type} RPM packages for CentOS"+ when "Python"+ "#{release_type} binaries for Python"+ else+ "#{release_type} binaries for #{@distribution}"+ end+ end++ def version_description+ if @rc+ "Apache Arrow #{@version} RC#{@rc} for #{@distribution}"+ else+ "Apache Arrow #{@version} for #{@distribution}"+ end+ end++ def client+ BintrayClient.new(repository: @repository,+ package: package,+ version: full_version,+ user: @user,+ api_key: @api_key)+ end++ def existing_files+ files = {}+ client.files.each do |file|+ files[file["path"]] = file+ end+ files+ end++ def upload_file(path, destination_path)+ max_n_retries = 3+ n_retries = 0+ begin+ begin+ client.upload(path, destination_path)+ rescue BintrayClient::Error => error+ case error.response+ when Net::HTTPConflict+ n_retries += 1+ if n_retries <= max_n_retries+ client.delete(destination_path)+ retry+ else+ $stderr.puts(error)+ end+ else+ $stderr.puts(error)+ end+ end+ rescue SocketError, Timeout::Error => error+ n_retries += 1+ if n_retries <= max_n_retries+ $stderr.puts+ $stderr.puts("Retry #{n_retries}: #{path}: " ++ "#{error.class}: #{error.message}")+ retry+ else+ raise+ end+ end+ end+ end++ def define+ define_apt_tasks+ define_yum_tasks+ define_python_tasks+ define_summary_tasks+ end++ private+ def env_value(name)+ value = ENV[name]+ value = yield(name) if value.nil? and block_given?+ raise "Specify #{name} environment variable" if value.nil?+ value+ end++ def verbose?+ ENV["VERBOSE"] == "yes"+ end++ def default_output+ if verbose?+ nil+ else+ IO::NULL+ end+ end++ def gpg_key_id+ env_value("GPG_KEY_ID")+ end++ def shorten_gpg_key_id(id)+ id[-8..-1]+ end++ def rpm_gpg_key_package_name(id)+ "gpg-pubkey-#{shorten_gpg_key_id(id).downcase}"+ end++ def bintray_user+ env_value("BINTRAY_USER")+ end++ def bintray_api_key+ env_value("BINTRAY_API_KEY")+ end++ def bintray_repository+ env_value("BINTRAY_REPOSITORY")+ end++ def source_bintray_repository+ env_value("SOURCE_BINTRAY_REPOSITORY") do+ bintray_repository+ end+ end++ def artifacts_dir+ env_value("ARTIFACTS_DIR")+ end++ def version+ env_value("VERSION")+ end++ def rc+ env_value("RC")+ end++ def full_version+ "#{version}-rc#{rc}"+ end++ def valid_sign?(path, sign_path)+ IO.pipe do |input, output|+ begin+ sh({"LANG" => "C"},+ "gpg",+ "--verify",+ sign_path,+ path,+ out: default_output,+ err: output,+ verbose: false)+ rescue+ return false+ end+ output.close+ /Good signature/ === input.read+ end+ end++ def sign(source_path, destination_path)+ if File.exist?(destination_path)+ return if valid_sign?(source_path, destination_path)+ rm(destination_path, verbose: false)+ end+ sh("gpg",+ "--detach-sig",+ "--local-user", gpg_key_id,+ "--output", destination_path,+ source_path,+ out: default_output,+ verbose: verbose?)+ end++ def sha512(source_path, destination_path)+ if File.exist?(destination_path)+ sha512 = File.read(destination_path).split[0]+ return if Digest::SHA512.file(source_path).hexdigest == sha512+ end+ absolute_destination_path = File.expand_path(destination_path)+ Dir.chdir(File.dirname(source_path)) do+ sh("shasum",+ "--algorithm", "512",+ File.basename(source_path),+ out: absolute_destination_path,+ verbose: verbose?)+ end+ end++ def sign_dir(label, dir)+ progress_label = "Signing: #{label}"+ progress_reporter = ProgressReporter.new(progress_label)++ target_paths = []+ Pathname(dir).glob("**/*") do |path|+ next if path.directory?+ case path.extname+ when ".asc", ".sha512"+ next+ end+ progress_reporter.increment_max+ target_paths << path.to_s+ end+ target_paths.each do |path|+ sign(path, "#{path}.asc")+ sha512(path, "#{path}.sha512")+ progress_reporter.advance+ end+ progress_reporter.finish+ end++ def download_distribution(distribution,+ destination,+ with_source_repository: false)+ existing_paths = {}+ Pathname(destination).glob("**/*") do |path|+ next if path.directory?+ existing_paths[path.to_s] = true+ end+ if with_source_repository+ source_client = BintrayClient.new(repository: source_bintray_repository,+ package: distribution,+ user: bintray_user,+ api_key: bintray_api_key)+ source_client.package_versions[0, 10].each do |source_version|+ downloader = BintrayDownloader.new(repository: source_bintray_repository,+ distribution: distribution,+ version: source_version,+ destination: destination,+ user: bintray_user,+ api_key: bintray_api_key)+ downloader.download do |output_path|+ existing_paths.delete(output_path)+ end+ end+ end+ downloader = BintrayDownloader.new(repository: bintray_repository,+ distribution: distribution,+ version: version,+ rc: rc,+ destination: destination,+ user: bintray_user,+ api_key: bintray_api_key)+ downloader.download do |output_path|+ existing_paths.delete(output_path)+ end+ existing_paths.each_key do |path|+ rm_f(path, verbose: verbose?)+ end+ end++ def same_content?(path1, path2)+ File.exist?(path1) and+ File.exist?(path2) and+ Digest::SHA256.file(path1) == Digest::SHA256.file(path2)+ end++ def copy_artifact(source_path,+ destination_path,+ progress_reporter)+ return if same_content?(source_path, destination_path)+ progress_reporter.increment_max+ destination_dir = File.dirname(destination_path)+ unless File.exist?(destination_dir)+ mkdir_p(destination_dir, verbose: verbose?)+ end+ cp(source_path, destination_path, verbose: verbose?)+ progress_reporter.advance+ end++ def tmp_dir+ "binary/tmp"+ end++ def rc_dir+ "#{tmp_dir}/rc"+ end++ def release_dir+ "#{tmp_dir}/release"+ end++ def deb_dir+ "#{rc_dir}/deb/#{full_version}"+ end++ def apt_repository_label+ "Apache Arrow"+ end++ def apt_repository_description+ "Apache Arrow packages"+ end++ def apt_rc_repositories_dir+ "#{rc_dir}/apt/repositories"+ end++ def apt_release_repositories_dir+ "#{release_dir}/apt/repositories"+ end++ def available_apt_targets+ [+ ["debian", "stretch", "main"],+ ["debian", "buster", "main"],+ ["ubuntu", "xenial", "main"],+ ["ubuntu", "bionic", "main"],+ ["ubuntu", "disco", "main"],+ ["ubuntu", "eoan", "universe"],+ ]+ end++ def apt_targets+ env_apt_targets = (ENV["APT_TARGETS"] || "").split(",")+ if env_apt_targets.empty?+ available_apt_targets+ else+ available_apt_targets.select do |distribution, code_name, component|+ env_apt_targets.any? do |env_apt_target|+ "#{distribution}-#{code_name}".start_with?(env_apt_target)+ end+ end+ end+ end++ def apt_distributions+ apt_targets.collect(&:first).uniq+ end++ def apt_architectures+ [+ "amd64",+ "arm64",+ ]+ end++ def define_deb_tasks+ directory deb_dir++ namespace :deb do+ desc "Copy deb packages"+ task :copy => deb_dir do+ apt_targets.each do |distribution, code_name, component|+ progress_label = "Copying: #{distribution} #{code_name}"+ progress_reporter = ProgressReporter.new(progress_label)++ source_dir_prefix = "#{artifacts_dir}/#{distribution}-#{code_name}"+ Dir.glob("#{source_dir_prefix}*/**/*") do |path|+ next if File.directory?(path)+ base_name = File.basename(path)+ if base_name.start_with?("apache-arrow-archive-keyring")+ package_name = "apache-arrow-archive-keyring"+ else+ package_name = "apache-arrow"+ end+ distribution_dir = [+ deb_dir,+ distribution,+ ].join("/")+ destination_path = [+ distribution_dir,+ "pool",+ code_name,+ component,+ package_name[0],+ package_name,+ base_name,+ ].join("/")+ copy_artifact(path,+ destination_path,+ progress_reporter)+ case base_name+ when /\A[^_]+-archive-keyring_.*\.deb\z/+ latest_archive_keyring_package_path = [+ distribution_dir,+ "#{package_name}-latest-#{code_name}.deb"+ ].join("/")+ copy_artifact(path,+ latest_archive_keyring_package_path,+ progress_reporter)+ end+ end+ progress_reporter.finish+ end+ end++ desc "Sign deb packages"+ task :sign => deb_dir do+ apt_distributions.each do |distribution|+ distribution_dir = "#{deb_dir}/#{distribution}"+ Dir.glob("#{distribution_dir}/**/*.dsc") do |path|+ begin+ sh({"LANG" => "C"},+ "gpg",+ "--verify",+ path,+ out: IO::NULL,+ err: IO::NULL,+ verbose: false)+ rescue+ sh("debsign",+ "--no-re-sign",+ "-k#{gpg_key_id}",+ path,+ out: default_output,+ verbose: verbose?)+ end+ end+ sign_dir(distribution, distribution_dir)+ end+ end++ desc "Upload deb packages"+ task :upload do+ apt_distributions.each do |distribution|+ distribution_dir = "#{deb_dir}/#{distribution}"+ uploader = BintrayUploader.new(repository: bintray_repository,+ distribution: distribution,+ version: version,+ rc: rc,+ source: distribution_dir,+ user: bintray_user,+ api_key: bintray_api_key)+ uploader.upload+ end+ end+ end++ desc "Release deb packages"+ deb_tasks = [+ "deb:copy",+ "deb:sign",+ "deb:upload",+ ]+ task :deb => deb_tasks+ end++ def generate_apt_release(dists_dir, code_name, component, architecture)+ dir = "#{dists_dir}/#{component}/"+ if architecture == "source"+ dir << architecture+ else+ dir << "binary-#{architecture}"+ end++ mkdir_p(dir, verbose: verbose?)+ File.open("#{dir}/Release", "w") do |release|+ release.puts(<<-RELEASE)+Archive: #{code_name}+Component: #{component}+Origin: #{apt_repository_label}+Label: #{apt_repository_label}+Architecture: #{architecture}+ RELEASE+ end+ end++ def generate_apt_ftp_archive_generate_conf(code_name, component)+ conf = <<-CONF+Dir::ArchiveDir ".";+Dir::CacheDir ".";+TreeDefault::Directory "pool/#{code_name}/#{component}";+TreeDefault::SrcDirectory "pool/#{code_name}/#{component}";+Default::Packages::Extensions ".deb";+Default::Packages::Compress ". gzip xz";+Default::Sources::Compress ". gzip xz";+Default::Contents::Compress "gzip";+ CONF++ apt_architectures.each do |architecture|+ conf << <<-CONF++BinDirectory "dists/#{code_name}/#{component}/binary-#{architecture}" {+ Packages "dists/#{code_name}/#{component}/binary-#{architecture}/Packages";+ Contents "dists/#{code_name}/#{component}/Contents-#{architecture}";+ SrcPackages "dists/#{code_name}/#{component}/source/Sources";+};+ CONF+ end++ conf << <<-CONF++Tree "dists/#{code_name}" {+ Sections "#{component}";+ Architectures "#{apt_architectures.join(" ")} source";+};+ CONF++ conf+ end++ def generate_apt_ftp_archive_release_conf(code_name, component)+ <<-CONF+APT::FTPArchive::Release::Origin "#{apt_repository_label}";+APT::FTPArchive::Release::Label "#{apt_repository_label}";+APT::FTPArchive::Release::Architectures "#{apt_architectures.join(" ")}";+APT::FTPArchive::Release::Codename "#{code_name}";+APT::FTPArchive::Release::Suite "#{code_name}";+APT::FTPArchive::Release::Components "#{component}";+APT::FTPArchive::Release::Description "#{apt_repository_description}";+ CONF+ end++ def define_apt_rc_tasks+ directory apt_rc_repositories_dir++ namespace :apt do+ namespace :rc do+ desc "Download deb files for RC APT repositories"+ task :download => apt_rc_repositories_dir do+ apt_distributions.each do |distribution|+ download_distribution(distribution,+ "#{apt_rc_repositories_dir}/#{distribution}",+ with_source_repository: true)+ end+ end++ desc "Update RC APT repositories"+ task :update do+ apt_targets.each do |distribution, code_name, component|+ base_dir = "#{apt_rc_repositories_dir}/#{distribution}"+ pool_dir = "#{base_dir}/pool/#{code_name}"+ next unless File.exist?(pool_dir)+ dists_dir = "#{base_dir}/dists/#{code_name}"+ rm_rf(dists_dir, verbose: verbose?)+ generate_apt_release(dists_dir, code_name, component, "source")+ apt_architectures.each do |architecture|+ generate_apt_release(dists_dir, code_name, component, architecture)+ end++ generate_conf_file = Tempfile.new("apt-ftparchive-generate.conf")+ File.open(generate_conf_file.path, "w") do |conf|+ conf.puts(generate_apt_ftp_archive_generate_conf(code_name,+ component))+ end+ cd(base_dir, verbose: verbose?) do+ sh("apt-ftparchive",+ "generate",+ generate_conf_file.path,+ out: default_output,+ verbose: verbose?)+ end++ Dir.glob("#{dists_dir}/Release*") do |release|+ rm_f(release, verbose: verbose?)+ end+ Dir.glob("#{base_dir}/*.db") do |db|+ rm_f(db, verbose: verbose?)+ end+ release_conf_file = Tempfile.new("apt-ftparchive-release.conf")+ File.open(release_conf_file.path, "w") do |conf|+ conf.puts(generate_apt_ftp_archive_release_conf(code_name,+ component))+ end+ release_file = Tempfile.new("apt-ftparchive-release")+ sh("apt-ftparchive",+ "-c", release_conf_file.path,+ "release",+ dists_dir,+ out: release_file.path,+ verbose: verbose?)+ release_path = "#{dists_dir}/Release"+ signed_release_path = "#{release_path}.gpg"+ in_release_path = "#{dists_dir}/InRelease"+ mv(release_file.path, release_path, verbose: verbose?)+ chmod(0644, release_path, verbose: verbose?)+ sh("gpg",+ "--sign",+ "--detach-sign",+ "--armor",+ "--local-user", gpg_key_id,+ "--output", signed_release_path,+ release_path,+ out: default_output,+ verbose: verbose?)+ sh("gpg",+ "--clear-sign",+ "--local-user", gpg_key_id,+ "--output", in_release_path,+ release_path,+ out: default_output,+ verbose: verbose?)++ sign_dir("#{distribution} #{code_name}",+ dists_dir)+ end+ end++ desc "Upload RC APT repositories"+ task :upload => apt_rc_repositories_dir do+ apt_distributions.each do |distribution|+ dists_dir = "#{apt_rc_repositories_dir}/#{distribution}/dists"+ uploader = BintrayUploader.new(repository: bintray_repository,+ distribution: distribution,+ version: version,+ rc: rc,+ source: dists_dir,+ destination_prefix: "dists/",+ user: bintray_user,+ api_key: bintray_api_key)+ uploader.upload+ end+ end+ end++ desc "Release RC APT repositories"+ apt_rc_tasks = [+ "apt:rc:download",+ "apt:rc:update",+ "apt:rc:upload",+ ]+ task :rc => apt_rc_tasks+ end+ end++ def define_apt_release_tasks+ directory apt_release_repositories_dir++ namespace :apt do+ namespace :release do+ desc "Download RC APT repositories"+ task :download => apt_release_repositories_dir do+ apt_distributions.each do |distribution|+ distribution_dir = "#{apt_release_repositories_dir}/#{distribution}"+ download_distribution(distribution, distribution_dir)+ end+ end++ desc "Upload release APT repositories"+ task :upload => apt_release_repositories_dir do+ apt_distributions.each do |distribution|+ distribution_dir = "#{apt_release_repositories_dir}/#{distribution}"+ uploader = BintrayUploader.new(repository: bintray_repository,+ distribution: distribution,+ version: version,+ source: distribution_dir,+ user: bintray_user,+ api_key: bintray_api_key)+ uploader.upload+ end+ end+ end++ desc "Release APT repositories"+ apt_release_tasks = [+ "apt:release:download",+ "apt:release:upload",+ ]+ task :release => apt_release_tasks+ end+ end++ def define_apt_tasks+ define_deb_tasks+ define_apt_rc_tasks+ define_apt_release_tasks+ end++ def rpm_dir+ "#{rc_dir}/rpm/#{full_version}"+ end++ def yum_rc_repositories_dir+ "#{rc_dir}/yum/repositories"+ end++ def yum_release_repositories_dir+ "#{release_dir}/yum/repositories"+ end++ def available_yum_targets+ [+ ["centos", "6"],+ ["centos", "7"],+ ["centos", "8"],+ ]+ end++ def yum_targets+ env_yum_targets = (ENV["YUM_TARGETS"] || "").split(",")+ if env_yum_targets.empty?+ available_yum_targets+ else+ available_yum_targets.select do |distribution, distribution_version|+ env_yum_targets.any? do |env_yum_target|+ "#{distribution}-#{distribution_version}".start_with?(env_yum_target)+ end+ end+ end+ end++ def yum_distributions+ yum_targets.collect(&:first).uniq+ end++ def yum_architectures+ [+ "aarch64",+ "x86_64",+ ]+ end++ def signed_rpm?(rpm)+ IO.pipe do |input, output|+ system("rpm", "--checksig", rpm, out: output)+ output.close+ signature = input.gets.sub(/\A#{Regexp.escape(rpm)}: /, "")+ signature.split.include?("signatures")+ end+ end++ def sign_rpms(directory)+ thread_pool = ThreadPool.new(2) do |rpm|+ unless signed_rpm?(rpm)+ sh("rpm",+ "-D", "_gpg_name #{gpg_key_id}",+ "-D", "__gpg_check_password_cmd /bin/true true",+ "--resign",+ rpm,+ out: default_output,+ verbose: verbose?)+ end+ end+ Dir.glob("#{directory}/**/*.rpm") do |rpm|+ thread_pool << rpm+ end+ thread_pool.join+ end++ def define_rpm_tasks+ directory rpm_dir++ namespace :rpm do+ desc "Copy RPM packages"+ task :copy => rpm_dir do+ yum_targets.each do |distribution, distribution_version|+ progress_label = "Copying: #{distribution} #{distribution_version}"+ progress_reporter = ProgressReporter.new(progress_label)++ destination_prefix = [+ rpm_dir,+ distribution,+ distribution_version,+ ].join("/")+ source_dir_prefix =+ "#{artifacts_dir}/#{distribution}-#{distribution_version}"+ Dir.glob("#{source_dir_prefix}*/**/*") do |path|+ next if File.directory?(path)+ base_name = File.basename(path)+ type = base_name.split(".")[-2]+ destination_paths = []+ case type+ when "src"+ destination_paths << [+ destination_prefix,+ "Source",+ "SPackages",+ base_name,+ ].join("/")+ when "noarch"+ yum_architectures.each do |architecture|+ destination_paths << [+ destination_prefix,+ architecture,+ "Packages",+ base_name,+ ].join("/")+ end+ else+ destination_paths << [+ destination_prefix,+ type,+ "Packages",+ base_name,+ ].join("/")+ end+ destination_paths.each do |destination_path|+ copy_artifact(path,+ destination_path,+ progress_reporter)+ end+ case base_name+ when /\A(apache-arrow-release)-.*\.noarch\.rpm\z/+ package_name = $1+ latest_release_package_path = [+ destination_prefix,+ "#{package_name}-latest.rpm"+ ].join("/")+ copy_artifact(path,+ latest_release_package_path,+ progress_reporter)+ end+ end++ progress_reporter.finish+ end+ end++ desc "Sign RPM packages"+ task :sign do+ unless system("rpm", "-q",+ rpm_gpg_key_package_name(gpg_key_id),+ out: IO::NULL)+ gpg_key = Tempfile.new(["apache-arrow-binary", ".asc"])+ sh("gpg",+ "--armor",+ "--export", gpg_key_id,+ out: gpg_key.path,+ verbose: verbose?)+ sh("rpm",+ "--import", gpg_key.path,+ out: default_output,+ verbose: verbose?)+ gpg_key.close!+ end++ yum_targets.each do |distribution, distribution_version|+ source_dir = [+ rpm_dir,+ distribution,+ distribution_version,+ ].join("/")+ sign_rpms(source_dir)+ sign_dir("#{distribution}-#{distribution_version}",+ rpm_dir)+ end+ end++ desc "Upload RPM packages"+ task :upload do+ yum_distributions.each do |distribution|+ distribution_dir = "#{rpm_dir}/#{distribution}"+ uploader = BintrayUploader.new(repository: bintray_repository,+ distribution: distribution,+ version: version,+ rc: rc,+ source: distribution_dir,+ user: bintray_user,+ api_key: bintray_api_key)+ uploader.upload+ end+ end+ end++ desc "Release RPM packages"+ rpm_tasks = [+ "rpm:copy",+ "rpm:sign",+ "rpm:upload",+ ]+ task :rpm => rpm_tasks+ end++ def define_yum_rc_tasks+ directory yum_rc_repositories_dir++ namespace :yum do+ namespace :rc do+ desc "Download RPM files for RC Yum repositories"+ task :download => yum_rc_repositories_dir do+ yum_distributions.each do |distribution|+ distribution_dir = "#{yum_rc_repositories_dir}/#{distribution}"+ download_distribution(distribution,+ distribution_dir,+ with_source_repository: true)+ end+ end++ desc "Update RC Yum repositories"+ task :update => yum_rc_repositories_dir do+ yum_distributions.each do |distribution|+ distribution_dir = "#{yum_rc_repositories_dir}/#{distribution}"+ Dir.glob("#{distribution_dir}/**/repodata") do |repodata|+ rm_rf(repodata, verbose: verbose?)+ end+ end++ yum_targets.each do |distribution, distribution_version|+ base_dir = [+ yum_rc_repositories_dir,+ distribution,+ distribution_version,+ ].join("/")+ base_dir = Pathname(base_dir)+ next unless base_dir.directory?+ base_dir.glob("*") do |arch_dir|+ next unless arch_dir.directory?+ sh("createrepo",+ "--update",+ arch_dir.to_s,+ out: default_output,+ verbose: verbose?)+ sign_label =+ "#{distribution}-#{distribution_version} #{arch_dir.basename}"+ sign_dir(sign_label,+ arch_dir.to_s)+ end+ end+ end++ desc "Upload RC Yum repositories"+ task :upload => yum_rc_repositories_dir do+ yum_targets.each do |distribution, distribution_version|+ base_dir = [+ yum_rc_repositories_dir,+ distribution,+ distribution_version,+ ].join("/")+ base_dir = Pathname(base_dir)+ base_dir.glob("**/repodata") do |repodata_dir|+ relative_dir = [+ distribution_version,+ repodata_dir.relative_path_from(base_dir).to_s+ ].join("/")+ uploader =+ BintrayUploader.new(repository: bintray_repository,+ distribution: distribution,+ version: version,+ rc: rc,+ source: repodata_dir.to_s,+ destination_prefix: "#{relative_dir}/",+ user: bintray_user,+ api_key: bintray_api_key)+ uploader.upload+ end+ end+ end+ end++ desc "Release RC Yum packages"+ yum_rc_tasks = [+ "yum:rc:download",+ "yum:rc:update",+ "yum:rc:upload",+ ]+ task :rc => yum_rc_tasks+ end+ end++ def define_yum_release_tasks+ directory yum_release_repositories_dir++ namespace :yum do+ namespace :release do+ desc "Download RC Yum repositories"+ task :download => yum_release_repositories_dir do+ yum_distributions.each do |distribution|+ distribution_dir = "#{yum_release_repositories_dir}/#{distribution}"+ download_distribution(distribution, distribution_dir)+ end+ end++ desc "Upload release Yum repositories"+ task :upload => yum_release_repositories_dir do+ yum_distributions.each do |distribution|+ distribution_dir = "#{yum_release_repositories_dir}/#{distribution}"+ uploader = BintrayUploader.new(repository: bintray_repository,+ distribution: distribution,+ version: version,+ source: distribution_dir,+ user: bintray_user,+ api_key: bintray_api_key)+ uploader.upload+ end+ end+ end++ desc "Release Yum packages"+ yum_release_tasks = [+ "yum:release:download",+ "yum:release:upload",+ ]+ task :release => yum_release_tasks+ end+ end++ def define_yum_tasks+ define_rpm_tasks+ define_yum_rc_tasks+ define_yum_release_tasks+ end++ def python_rc_dir+ "#{rc_dir}/python/#{full_version}"+ end++ def python_release_dir+ "#{release_dir}/python/#{full_version}"+ end++ def define_python_rc_tasks+ directory python_rc_dir++ namespace :python do+ namespace :rc do+ desc "Copy Python packages"+ task :copy => python_rc_dir do+ progress_label = "Copying: Python"+ progress_reporter = ProgressReporter.new(progress_label)++ Pathname(artifacts_dir).glob("{conda,wheel}-*/**/*") do |path|+ next if path.directory?+ destination_path = [+ python_rc_dir,+ path.basename.to_s,+ ].join("/")+ copy_artifact(path, destination_path, progress_reporter)+ end++ progress_reporter.finish+ end++ desc "Sign Python packages"+ task :sign => python_rc_dir do+ sign_dir("Python", python_rc_dir)+ end++ desc "Upload Python packages"+ task :upload do+ uploader = BintrayUploader.new(repository: bintray_repository,+ distribution: "python",+ version: version,+ rc: rc,+ source: python_rc_dir,+ destination_prefix: "#{full_version}/",+ user: bintray_user,+ api_key: bintray_api_key)+ uploader.upload+ end+ end++ desc "Release RC Python packages"+ python_rc_tasks = [+ "python:rc:copy",+ "python:rc:sign",+ "python:rc:upload",+ ]+ task :rc => python_rc_tasks+ end+ end++ def define_python_release_tasks+ directory python_release_dir++ namespace :python do+ namespace :release do+ desc "Download RC Python packages"+ task :download => python_release_dir do+ download_distribution("python", python_release_dir)+ end++ desc "Upload release Python packages"+ task :upload => python_release_dir do+ packages_dir = "#{python_release_dir}/#{full_version}"+ uploader = BintrayUploader.new(repository: bintray_repository,+ distribution: "python",+ version: version,+ source: packages_dir,+ destination_prefix: "#{version}/",+ user: bintray_user,+ api_key: bintray_api_key)+ uploader.upload+ end+ end++ desc "Release Python packages"+ python_release_tasks = [+ "python:release:download",+ "python:release:upload",+ ]+ task :release => python_release_tasks+ end+ end++ def define_python_tasks+ define_python_rc_tasks+ define_python_release_tasks+ end++ def define_summary_tasks+ namespace :summary do+ desc "Show RC summary"+ task :rc do+ puts(<<-SUMMARY)+Success! The release candidate binaries are available here:+ https://bintray.com/#{bintray_repository}/debian-rc/#{full_version}+ https://bintray.com/#{bintray_repository}/ubuntu-rc/#{full_version}+ https://bintray.com/#{bintray_repository}/centos-rc/#{full_version}+ https://bintray.com/#{bintray_repository}/python-rc/#{full_version}+ SUMMARY+ end++ desc "Show release summary"+ task :release do+ puts(<<-SUMMARY)+Success! The release binaries are available here:+ https://bintray.com/#{bintray_repository}/debian/#{version}+ https://bintray.com/#{bintray_repository}/ubuntu/#{version}+ https://bintray.com/#{bintray_repository}/centos/#{version}+ https://bintray.com/#{bintray_repository}/python/#{version}+ SUMMARY+ end+ end+ end+enddiff --git a/dev/release/binary/.dockerignore b/dev/release/binary/.dockerignorenew file mode 100644index 0000000000..f2c46d8ce2--- /dev/null+++ b/dev/release/binary/.dockerignore@@ -0,0 +1,18 @@+# 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.++/tmp/diff --git a/dev/release/binary/Dockerfile b/dev/release/binary/Dockerfileindex c9f2e57959..622072c1f2 100644--- a/dev/release/binary/Dockerfile+++ b/dev/release/binary/Dockerfile@@ -31,6 +31,8 @@ RUN \gpg \openssh-server \rpm \+ ruby \+ rake \sudo && \apt clean && \rm -rf /var/lib/apt/lists/*@@ -46,11 +48,18 @@ RUN \useradd --uid ${ARROW_UID} --gid ${ARROW_UID} --create-home ${ARROW_USER} && \mkdir -p /home/arrow/.gnupg /home/arrow/.ssh && \chown -R arrow: /home/arrow/.gnupg /home/arrow/.ssh && \- chmod -R og-rwx /home/arrow/.gnupg /home/arrow/.ssh+ chmod -R og-rwx /home/arrow/.gnupg /home/arrow/.ssh && \+ echo "${ARROW_USER} ALL=(ALL:ALL) NOPASSWD:ALL" | \+ EDITOR=tee visudo -f /etc/sudoers.d/arrowCOPY id_rsa.pub /home/arrow/.ssh/authorized_keysRUN \chown -R arrow: /home/arrow/.ssh && \chmod -R og-rwx /home/arrow/.ssh+COPY runner.sh /home/arrow/runner.sh+RUN \+ chown -R arrow: /home/arrow/runner.sh && \+ chmod +x /home/arrow/runner.sh+EXPOSE 22diff --git a/dev/release/binary/runner.sh b/dev/release/binary/runner.shnew file mode 100755index 0000000000..5cf5033d68--- /dev/null+++ b/dev/release/binary/runner.sh@@ -0,0 +1,36 @@+#!/bin/bash+#+# 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.++set -u++export LANG=C++target_dir=/host/binary/tmp+original_owner=$(stat --format=%u ${target_dir})+original_group=$(stat --format=%g ${target_dir})++sudo -H chown -R ${USER}: ${target_dir}+restore_owner() {+ sudo -H chown -R ${original_owner}:${original_group} ${target_dir}+}+trap restore_owner EXIT++cd /host++"$@"diff --git a/dev/release/post-02-binary.sh b/dev/release/post-02-binary.shindex d2788409a7..b07abb78a9 100755--- a/dev/release/post-02-binary.sh+++ b/dev/release/post-02-binary.sh@@ -1,5 +1,4 @@#!/bin/bash-# -*- indent-tabs-mode: nil; sh-indentation: 2; sh-basic-offset: 2 -*-## Licensed to the Apache Software Foundation (ASF) under one# or more contributor license agreements. See the NOTICE file@@ -17,11 +16,11 @@# KIND, either express or implied. See the License for the# specific language governing permissions and limitations# under the License.-#+set -eset -o pipefail-SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"+SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"if [ "$#" -ne 2 ]; thenecho "Usage: $0 <version> <rc-num>"@@ -31,146 +30,62 @@ fiversion=$1rc=$2-if [ -z "${BINTRAY_PASSWORD}" ]; then- echo "BINTRAY_PASSWORD is empty"- exit 1-fi+cd "${SOURCE_DIR}"-if ! jq --help > /dev/null 2>&1; then- echo "jq is required"+: ${BINTRAY_REPOSITORY_CUSTOM:=${BINTRAY_REPOSITORY:-}}++if [ ! -f .env ]; then+ echo "You must create $(pwd)/.env"+ echo "You can use $(pwd)/.env.example as template"exit 1fi+. .env-: ${BINTRAY_REPOSITORY:=apache/arrow}--BINTRAY_DOWNLOAD_URL_BASE=https://dl.bintray.com--docker_image_name=apache-arrow/release-binary--bintray() {- local command=$1- shift- local path=$1- shift- local url=https://bintray.com/api/v1${path}- echo "${command} ${url}" 1>&2- curl \- --fail \- --basic \- --user "${BINTRAY_USER:-$USER}:${BINTRAY_PASSWORD}" \- --header "Content-Type: application/json" \- --request ${command} \- ${url} \- "$@" | \- jq .-}--ensure_version() {- local version=$1- local target=$2-- if ! bintray \- GET \- /packages/${BINTRAY_REPOSITORY}/${target}/versions/${version}; then- bintray \- POST /packages/${BINTRAY_REPOSITORY}/${target}/versions \- --data-binary "-{- \"name\": \"${version}\",- \"desc\": \"Apache Arrow ${version}.\"-}-"- fi-}--download_files() {- local version=$1- local rc=$2- local target=$3-- local version_name=${version}-rc${rc}-- local files=$(- bintray \- GET /packages/${BINTRAY_REPOSITORY}/${target}-rc/versions/${version_name}/files | \- jq -r ".[].path")-- local file- for file in ${files}; do- mkdir -p "$(dirname ${file})"- curl \- --fail \- --location \- --output ${file} \- ${BINTRAY_DOWNLOAD_URL_BASE}/${BINTRAY_REPOSITORY}/${file}- done-}--delete_file() {- local version=$1- local target=$2- local path=$3-- bintray \- DELETE /content/${BINTRAY_REPOSITORY}/${target}/${path}-}--upload_file() {- local version=$1- local target=$2- local path=$3-- local sha256=$(shasum -a 256 ${path} | awk '{print $1}')- local download_path=/${BINTRAY_REPOSITORY}/${target}/${path}- if curl \- --fail \- --head \- ${BINTRAY_DOWNLOAD_URL_BASE}${download_path} | \- grep -q "^X-Checksum-Sha2: ${sha256}"; then- return 0- fi-- local request_path=/content/${BINTRAY_REPOSITORY}/${target}/${version}/${target}/${path}- if ! bintray \- PUT ${request_path} \- --header "X-Bintray-Publish: 1" \- --header "X-Bintray-Override: 1" \- --header "X-Checksum-Sha2: ${sha256}" \- --data-binary "@${path}"; then- delete_file ${version} ${target} ${path}- bintray \- PUT ${request_path} \- --header "X-Bintray-Publish: 1" \- --header "X-Bintray-Override: 1" \- --header "X-Checksum-Sha2: ${sha256}" \- --data-binary "@${path}"- fi-}--docker build -t ${docker_image_name} ${SOURCE_DIR}/binary--for target in debian ubuntu centos python; do- tmp_dir=tmp/${target}- rm -rf ${tmp_dir}- mkdir -p ${tmp_dir}- pushd ${tmp_dir}- ensure_version ${version} ${target}- download_files ${version} ${rc} ${target}- mv ${target}-rc ${target}- pushd ${target}- if [ ${target} = "python" ]; then- mv ${version}-rc${rc} ${version}- fi- for file in $(find . -type f); do- upload_file ${version} ${target} ${file}- done- popd- popd- rm -rf ${tmp_dir}-done+if [ -n "${BINTRAY_REPOSITORY_CUSTOM}" ]; then+ BINTRAY_REPOSITORY=${BINTRAY_REPOSITORY_CUSTOM}+fi-echo "Success! The release binaries are available here:"-echo " https://bintray.com/${BINTRAY_REPOSITORY}/debian/${version}"-echo " https://bintray.com/${BINTRAY_REPOSITORY}/ubuntu/${version}"-echo " https://bintray.com/${BINTRAY_REPOSITORY}/centos/${version}"-echo " https://bintray.com/${BINTRAY_REPOSITORY}/python/${version}"+. binary-common.sh++# By default deploy all artifacts.+# To deactivate one category, deactivate the category and all of its dependents.+# To explicitly select one category, set DEPLOY_DEFAULT=0 DEPLOY_X=1.+: ${DEPLOY_DEFAULT:=1}+: ${DEPLOY_CENTOS:=${DEPLOY_DEFAULT}}+: ${DEPLOY_DEBIAN:=${DEPLOY_DEFAULT}}+: ${DEPLOY_PYTHON:=${DEPLOY_DEFAULT}}+: ${DEPLOY_UBUNTU:=${DEPLOY_DEFAULT}}++rake_tasks=()+apt_targets=()+yum_targets=()+if [ ${DEPLOY_DEBIAN} -gt 0 ]; then+ rake_tasks+=(apt:release)+ apt_targets+=(debian)+fi+if [ ${DEPLOY_UBUNTU} -gt 0 ]; then+ rake_tasks+=(apt:release)+ apt_targets+=(ubuntu)+fi+if [ ${DEPLOY_CENTOS} -gt 0 ]; then+ rake_tasks+=(yum:release)+ yum_targets+=(centos)+fi+if [ ${DEPLOY_PYTHON} -gt 0 ]; then+ rake_tasks+=(python:release)+fi+rake_tasks+=(summary:release)++tmp_dir=binary/tmp+mkdir -p "${tmp_dir}"++docker_run \+ ./runner.sh \+ rake \+ "${rake_tasks[@]}" \+ APT_TARGETS=$(IFS=,; echo "${apt_targets[*]}") \+ ARTIFACTS_DIR="${tmp_dir}/artifacts" \+ BINTRAY_REPOSITORY=${BINTRAY_REPOSITORY} \+ RC=${rc} \+ VERSION=${version} \+ YUM_TARGETS=$(IFS=,; echo "${yum_targets[*]}")diff --git a/dev/release/verify-apt.sh b/dev/release/verify-apt.shindex 79b4c19056..88fa22f234 100755--- a/dev/release/verify-apt.sh+++ b/dev/release/verify-apt.sh@@ -16,7 +16,6 @@# KIND, either express or implied. See the License for the# specific language governing permissions and limitations# under the License.-#set -exu@@ -39,9 +38,7 @@ export DEBIAN_FRONTEND=noninteractiveapt updateapt install -y -V \- apt-transport-https \curl \- gnupg \lsb-releasecode_name="$(lsb_release --codename --short)"@@ -51,13 +48,12 @@ if [ "${IS_RC}" = "yes" ]; thenbintray_base_url="${bintray_base_url}-rc"fi-have_signed_by=yeshave_flight=yeshave_python=yeshave_gandiva=yesneed_llvm_apt=no-case "${distribution}-${code_name}" in- debian-stretch)+case "${distribution}-${code_name}-$(arch)" in+ debian-stretch-*)sed \-i"" \-e "s/ main$/ main contrib non-free/g" \@@ -67,47 +63,45 @@ deb http://deb.debian.org/debian ${code_name}-backports mainAPT_LINEneed_llvm_apt=yes;;- debian-buster)+ debian-buster-*)sed \-i"" \-e "s/ main$/ main contrib non-free/g" \/etc/apt/sources.list;;- ubuntu-xenial)- have_signed_by=no+ ubuntu-xenial-x86_64)need_llvm_apt=yeshave_flight=no;;- ubuntu-trusty)- have_signed_by=no+ ubuntu-xenial-aarch64)have_flight=no- have_python=nohave_gandiva=no;;esac-if [ "${have_signed_by}" = "yes" ]; then- keyring_path="/usr/share/keyrings/apache-arrow-keyring.gpg"- curl \- --output "${keyring_path}" \- "${bintray_base_url}/apache-arrow-keyring.gpg"- cat <<APT_LINE > /etc/apt/sources.list.d/apache-arrow.list-deb [arch=amd64 signed-by=${keyring_path}] ${bintray_base_url}/ ${code_name} main-deb-src [signed-by=${keyring_path}] ${bintray_base_url}/ ${code_name} main-APT_LINE+keyring_archive_base_name="apache-arrow-archive-keyring-latest-${code_name}.deb"+curl \+ --output "${keyring_archive_base_name}" \+ "${bintray_base_url}/${keyring_archive_base_name}"+apt install -y -V "./${keyring_archive_base_name}"+if [ "${BINTRAY_REPOSITORY}" = "apache/arrow" ]; then+ if [ "${IS_RC}" = "yes" ]; then+ sed \+ -i"" \+ -e "s,^URIs: \\(.*\\)/,URIs: \\1-rc/,g" \+ /etc/apt/sources.list.d/apache-arrow.sources+ fielse- curl https://dist.apache.org/repos/dist/dev/arrow/KEYS | apt-key add -- cat <<APT_LINE > /etc/apt/sources.list.d/apache-arrow.list-deb [arch=amd64] ${bintray_base_url}/ ${code_name} main-deb-src ${bintray_base_url}/ ${code_name} main-APT_LINE+ sed \+ -i"" \+ -e "s,^URIs: .*,URIs: ${bintray_base_url}/,g" \+ /etc/apt/sources.list.d/apache-arrow.sourcesfiif [ "${need_llvm_apt}" = "yes" ]; thencurl https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -cat <<APT_LINE > /etc/apt/sources.list.d/llvm.listdeb http://apt.llvm.org/${code_name}/ llvm-toolchain-${code_name}-7 main-deb-src http://apt.llvm.org/${code_name}/ llvm-toolchain-${code_name}-7 mainAPT_LINEfidiff --git a/dev/release/verify-release-candidate.sh b/dev/release/verify-release-candidate.shindex ba75dbff70..7a357c0218 100755--- a/dev/release/verify-release-candidate.sh+++ b/dev/release/verify-release-candidate.sh@@ -129,10 +129,26 @@ test_binary() {test_apt() {for target in "debian:stretch" \+ "arm64v8/debian:stretch" \"debian:buster" \+ "arm64v8/debian:buster" \"ubuntu:xenial" \+ "arm64v8/ubuntu:xenial" \"ubuntu:bionic" \- "ubuntu:disco"; do+ "arm64v8/ubuntu:bionic" \+ "ubuntu:disco" \+ "arm64v8/ubuntu:disco" \+ "ubuntu:eoan" \+ "arm64v8/ubuntu:eoan"; do \+ case "${target}" in+ arm64v8/*)+ if [ "$(arch)" = "aarch64" -o -e /usr/bin/qemu-aarch64-static ]; then+ : # OK+ else+ continue+ fi+ ;;+ esacif ! docker run -v "${SOURCE_DIR}"/../..:/arrow:delegated \"${target}" \/arrow/dev/release/verify-apt.sh \@@ -147,7 +163,19 @@ test_apt() {test_yum() {for target in "centos:6" \- "centos:7"; do+ "centos:7" \+ "arm64v8/centos:7" \+ "centos:8" \+ "arm64v8/centos:8"; do+ case "${target}" in+ arm64v8/*)+ if [ "$(arch)" = "aarch64" -o -e /usr/bin/qemu-aarch64-static ]; then+ : # OK+ else+ continue+ fi+ ;;+ esacif ! docker run -v "${SOURCE_DIR}"/../..:/arrow:delegated \"${target}" \/arrow/dev/release/verify-yum.sh \diff --git a/dev/release/verify-yum.sh b/dev/release/verify-yum.shindex 8ef38c0983..f8f95f4042 100755--- a/dev/release/verify-yum.sh+++ b/dev/release/verify-yum.sh@@ -16,7 +16,6 @@# KIND, either express or implied. See the License for the# specific language governing permissions and limitations# under the License.-#set -exu@@ -38,52 +37,81 @@ if [ "${IS_RC}" = "yes" ]; thenbintray_base_url="${bintray_base_url}-rc"fi-distribution=$(cut -d " " -f 1 /etc/redhat-release | tr "A-Z" "a-z")-if grep -q Linux /etc/redhat-release; then- distribution_version=$(cut -d " " -f 4 /etc/redhat-release)+if [ -f /etc/os-release ]; then+ distribution=$(. /etc/os-release && echo "${ID}")+ distribution_version=$(. /etc/os-release && echo "${VERSION_ID}")else- distribution_version=$(cut -d " " -f 3 /etc/redhat-release)+ distribution=centos+ distribution_version=6fi-distribution_version=$(echo ${distribution_version} | sed -e 's/\..*$//g')+have_flight=yes+have_gandiva=yeshave_glib=yeshave_parquet=yes-case "${distribution}-${distribution_version}" in- centos-6)+install_command="dnf install -y --enablerepo=PowerTools"+case "${distribution}-${distribution_version}-$(arch)" in+ centos-6-*)+ have_flight=no+ have_gandiva=nohave_glib=nohave_parquet=no+ install_command="yum install -y"+ ;;+ centos-7-*)+ have_flight=no+ have_gandiva=no+ install_command="yum install -y";;esac-cat <<REPO > /etc/yum.repos.d/Apache-Arrow.repo-[apache-arrow]-name=Apache Arrow-baseurl=${bintray_base_url}/\$releasever/\$basearch/-gpgcheck=1-enabled=1-gpgkey=${bintray_base_url}/RPM-GPG-KEY-apache-arrow-REPO--yum install -y epel-release+${install_command} \+ ${bintray_base_url}/${distribution_version}/apache-arrow-release-latest.rpm+if [ "${BINTRAY_REPOSITORY}" = "apache/arrow" ]; then+ if [ "${IS_RC}" = "yes" ]; then+ sed \+ -i"" \+ -e "s,/centos/,/centos-rc/,g" \+ /etc/yum.repos.d/Apache-Arrow.repo+ fi+else+ sed \+ -i"" \+ -e "s,baseurl=https://apache.bintray.com/arrow/centos,baseurl=${bintray_base_url},g" \+ /etc/yum.repos.d/Apache-Arrow.repo+fiif [ "${have_glib}" = "yes" ]; then- yum install -y --enablerepo=epel arrow-glib-devel-${VERSION}- yum install -y --enablerepo=epel arrow-glib-doc-${VERSION}+ ${install_command} --enablerepo=epel arrow-glib-devel-${VERSION}+ ${install_command} --enablerepo=epel arrow-glib-doc-${VERSION}fi-yum install -y --enablerepo=epel arrow-python-devel-${VERSION}+${install_command} --enablerepo=epel arrow-python-devel-${VERSION}if [ "${have_glib}" = "yes" ]; then- yum install -y --enablerepo=epel plasma-glib-devel-${VERSION}- yum install -y --enablerepo=epel plasma-glib-doc-${VERSION}+ ${install_command} --enablerepo=epel plasma-glib-devel-${VERSION}+ ${install_command} --enablerepo=epel plasma-glib-doc-${VERSION}else- yum install -y --enablerepo=epel plasma-devel-${VERSION}+ ${install_command} --enablerepo=epel plasma-devel-${VERSION}+fi++if [ "${have_flight}" = "yes" ]; then+ ${install_command} --enablerepo=epel arrow-flight-devel-${VERSION}+fi++if [ "${have_gandiva}" = "yes" ]; then+ if [ "${have_glib}" = "yes" ]; then+ ${install_command} --enablerepo=epel gandiva-glib-devel-${VERSION}+ ${install_command} --enablerepo=epel gandiva-glib-doc-${VERSION}+ else+ ${install_command} --enablerepo=epel gandiva-devel-${VERSION}+ fifiif [ "${have_parquet}" = "yes" ]; thenif [ "${have_glib}" = "yes" ]; then- yum install -y --enablerepo=epel parquet-glib-devel-${VERSION}- yum install -y --enablerepo=epel parquet-glib-doc-${VERSION}+ ${install_command} --enablerepo=epel parquet-glib-devel-${VERSION}+ ${install_command} --enablerepo=epel parquet-glib-doc-${VERSION}else- yum install -y --enablerepo=epel parquet-devel-${VERSION}+ ${install_command} --enablerepo=epel parquet-devel-${VERSION}fifidiff --git a/dev/tasks/crossbow.py b/dev/tasks/crossbow.pyindex 820da70651..e46d5026fb 100755--- a/dev/tasks/crossbow.py+++ b/dev/tasks/crossbow.py@@ -1259,7 +1259,7 @@ def report(obj, job_name, sender_name, sender_email, recipient_email,help='Directory to download the build artifacts')@click.pass_objdef download_artifacts(obj, job_name, target_dir):- """Download and sign build artifacts from github releases"""+ """Download build artifacts from GitHub releases"""output = obj['output']# fetch the queue repositorydiff --git a/dev/tasks/tasks.yml b/dev/tasks/tasks.ymlindex 9feb245316..bbdfe53783 100644--- a/dev/tasks/tasks.yml+++ b/dev/tasks/tasks.yml@@ -856,6 +856,7 @@ tasks:- apache-arrow_{no_rc_version}-1.dsc- apache-arrow_{no_rc_version}.orig.tar.gz- gir1.2-arrow-1.0_{no_rc_version}-1_[a-z0-9]+.deb+ - gir1.2-gandiva-1.0_{no_rc_version}-1_[a-z0-9]+.deb- gir1.2-parquet-1.0_{no_rc_version}-1_[a-z0-9]+.deb- libarrow-dev_{no_rc_version}-1_[a-z0-9]+.deb- libarrow-dataset-dev_{no_rc_version}-1_[a-z0-9]+.deb@@ -873,6 +874,13 @@ tasks:- libarrow-python16_{no_rc_version}-1_[a-z0-9]+.deb- libarrow16-dbgsym_{no_rc_version}-1_[a-z0-9]+.deb- libarrow16_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva-dev_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva-glib-dev_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva-glib-doc_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva-glib16-dbgsym_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva-glib16_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva16-dbgsym_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva16_{no_rc_version}-1_[a-z0-9]+.deb- libparquet-dev_{no_rc_version}-1_[a-z0-9]+.deb- libparquet-glib-dev_{no_rc_version}-1_[a-z0-9]+.deb- libparquet-glib-doc_{no_rc_version}-1_[a-z0-9]+.deb@@ -971,6 +979,7 @@ tasks:- apache-arrow_{no_rc_version}-1.dsc- apache-arrow_{no_rc_version}.orig.tar.gz- gir1.2-arrow-1.0_{no_rc_version}-1_[a-z0-9]+.deb+ - gir1.2-gandiva-1.0_{no_rc_version}-1_[a-z0-9]+.deb- gir1.2-parquet-1.0_{no_rc_version}-1_[a-z0-9]+.deb- libarrow-dev_{no_rc_version}-1_[a-z0-9]+.deb- libarrow-dataset-dev_{no_rc_version}-1_[a-z0-9]+.deb@@ -988,6 +997,13 @@ tasks:- libarrow-python16_{no_rc_version}-1_[a-z0-9]+.deb- libarrow16-dbgsym_{no_rc_version}-1_[a-z0-9]+.deb- libarrow16_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva-dev_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva-glib-dev_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva-glib-doc_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva-glib16-dbgsym_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva-glib16_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva16-dbgsym_{no_rc_version}-1_[a-z0-9]+.deb+ - libgandiva16_{no_rc_version}-1_[a-z0-9]+.deb- libparquet-dev_{no_rc_version}-1_[a-z0-9]+.deb- libparquet-glib-dev_{no_rc_version}-1_[a-z0-9]+.deb- libparquet-glib-doc_{no_rc_version}-1_[a-z0-9]+.deb@@ -1073,7 +1089,6 @@ tasks:- apache-arrow_{no_rc_version}.orig.tar.gz- gir1.2-arrow-1.0_{no_rc_version}-1_[a-z0-9]+.deb- gir1.2-arrow-cuda-1.0_{no_rc_version}-1_[a-z0-9]+.deb- - gir1.2-gandiva-1.0_{no_rc_version}-1_[a-z0-9]+.deb- gir1.2-parquet-1.0_{no_rc_version}-1_[a-z0-9]+.deb- gir1.2-plasma-1.0_{no_rc_version}-1_[a-z0-9]+.deb- libarrow-dev_{no_rc_version}-1_[a-z0-9]+.deb@@ -1090,11 +1105,6 @@ tasks:- libarrow-python-dev_{no_rc_version}-1_[a-z0-9]+.deb- libarrow-python16_{no_rc_version}-1_[a-z0-9]+.deb- libarrow16_{no_rc_version}-1_[a-z0-9]+.deb- - libgandiva-dev_{no_rc_version}-1_[a-z0-9]+.deb- - libgandiva-glib-dev_{no_rc_version}-1_[a-z0-9]+.deb- - libgandiva-glib-doc_{no_rc_version}-1_[a-z0-9]+.deb- - libgandiva-glib16_{no_rc_version}-1_[a-z0-9]+.deb- - libgandiva16_{no_rc_version}-1_[a-z0-9]+.deb- libparquet-dev_{no_rc_version}-1_[a-z0-9]+.deb- libparquet-glib-dev_{no_rc_version}-1_[a-z0-9]+.deb- libparquet-glib-doc_{no_rc_version}-1_[a-z0-9]+.deb