]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/dev/release/utils-binary.sh
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / dev / release / utils-binary.sh
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17
18 docker_image_name=apache-arrow/release-binary
19 gpg_agent_extra_socket="$(gpgconf --list-dirs agent-extra-socket)"
20 if [ $(uname) = "Darwin" ]; then
21 docker_uid=10000
22 docker_gid=10000
23 else
24 docker_uid=$(id -u)
25 docker_gid=$(id -g)
26 fi
27 docker_ssh_key="${SOURCE_DIR}/binary/id_rsa"
28
29 if [ ! -f "${docker_ssh_key}" ]; then
30 ssh-keygen -N "" -f "${docker_ssh_key}"
31 fi
32
33 docker_gpg_ssh() {
34 local ssh_port=$1
35 shift
36 local known_hosts_file=$(mktemp -t "arrow-binary-gpg-ssh-known-hosts.XXXXX")
37 local exit_code=
38 if ssh \
39 -o StrictHostKeyChecking=no \
40 -o UserKnownHostsFile=${known_hosts_file} \
41 -i "${docker_ssh_key}" \
42 -p ${ssh_port} \
43 -R "/home/arrow/.gnupg/S.gpg-agent:${gpg_agent_extra_socket}" \
44 arrow@127.0.0.1 \
45 "$@"; then
46 exit_code=$?;
47 else
48 exit_code=$?;
49 fi
50 rm -f ${known_hosts_file}
51 return ${exit_code}
52 }
53
54 docker_run() {
55 local container_id_dir=$(mktemp -d -t "arrow-binary-gpg-container.XXXXX")
56 local container_id_file=${container_id_dir}/id
57 docker \
58 run \
59 --cidfile ${container_id_file} \
60 --detach \
61 --publish-all \
62 --rm \
63 --volume "$PWD":/host \
64 ${docker_image_name} \
65 bash -c "
66 if [ \$(id -u) -ne ${docker_uid} ]; then
67 usermod --uid ${docker_uid} arrow
68 chown -R arrow: ~arrow
69 fi
70 /usr/sbin/sshd -D
71 "
72 local container_id=$(cat ${container_id_file})
73 local ssh_port=$(docker port ${container_id} | grep -E -o '[0-9]+$' | head -n 1)
74 # Wait for sshd available
75 while ! docker_gpg_ssh ${ssh_port} : > /dev/null 2>&1; do
76 sleep 0.1
77 done
78 gpg --export ${GPG_KEY_ID} | docker_gpg_ssh ${ssh_port} gpg --import
79 docker_gpg_ssh ${ssh_port} "$@"
80 docker kill ${container_id}
81 rm -rf ${container_id_dir}
82 }
83
84 docker build -t ${docker_image_name} "${SOURCE_DIR}/binary"
85
86 chmod go-rwx "${docker_ssh_key}"