Packager: fixes (#5103)

This commit is contained in:
proller 2019-04-25 15:29:28 +03:00 committed by GitHub
parent 445f51c01e
commit 33922685d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 17 deletions

2
docker/builder/build.sh Normal file → Executable file
View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#ccache -s
mkdir -p /server/build_docker

View File

@ -8,6 +8,7 @@ RUN apt-get update -y \
apt-get install --yes --no-install-recommends \
bash \
cmake \
ccache \
curl \
gcc-7 \
g++-7 \
@ -34,4 +35,5 @@ RUN apt-get update -y \
git \
tzdata
CMD mkdir -p build/build_result && cd build/build_result && cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSANITIZE=$SANITIZER $CMAKE_FLAGS && ninja && mv ./dbms/programs/clickhouse* /output && mv ./dbms/unit_tests_dbms /output
COPY build.sh /
CMD ["/bin/bash", "/build.sh"]

13
docker/packager/binary/build.sh Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -x -e
mkdir -p build/build_docker
cd build/build_docker
ccache -s ||:
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSANITIZE=$SANITIZER $CMAKE_FLAGS
ninja
ccache -s ||:
mv ./dbms/programs/clickhouse* /output
mv ./dbms/unit_tests_dbms /output
mv ./dbms/programs/odbc-bridge/clickhouse-odbc-bridge /output

View File

@ -9,6 +9,7 @@ RUN apt-get --allow-unauthenticated update -y \
bash \
fakeroot \
cmake \
ccache \
curl \
gcc-7 \
g++-7 \
@ -60,6 +61,5 @@ RUN apt-get --allow-unauthenticated update -y \
odbcinst \
tzdata
CMD /bin/bash build/release --no-pbuilder && mv /*.deb /output && mv *.changes /output && mv *.buildinfo /output
COPY build.sh /
CMD ["/bin/bash", "/build.sh"]

10
docker/packager/deb/build.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -x -e
ccache -s ||:
build/release --no-pbuilder
mv /*.deb /output
mv *.changes /output
mv *.buildinfo /output
ccache -s ||:

View File

@ -2,4 +2,3 @@ Vagrant.configure("2") do |config|
config.vm.box = "robot-clickhouse/clickhouse-freebsd"
config.vm.synced_folder ".", "/vagrant", disabled: true
end

View File

@ -71,7 +71,7 @@ def pull_image(image_name):
def build_image(image_name, filepath):
subprocess.check_call("docker build --network=host -t {} -f {} .".format(image_name, filepath), shell=True)
def run_docker_image_with_env(image_name, output, env_variables, ch_root):
def run_docker_image_with_env(image_name, output, env_variables, ch_root, ccache_dir):
env_part = " -e ".join(env_variables)
if env_part:
env_part = " -e " + env_part
@ -81,9 +81,10 @@ def run_docker_image_with_env(image_name, output, env_variables, ch_root):
else:
interactive = ""
cmd = "docker run --network=host --rm --volume={output_path}:/output --volume={ch_root}:/build {env} {interactive} {img_name}".format(
cmd = "docker run --network=host --rm --volume={output_path}:/output --volume={ch_root}:/build --volume={ccache_dir}:/ccache {env} {interactive} {img_name}".format(
output_path=output,
ch_root=ch_root,
ccache_dir=ccache_dir,
env=env_part,
img_name=image_name,
interactive=interactive
@ -104,21 +105,34 @@ def run_vagrant_box_with_env(image_path, output_dir, ch_root):
def parse_env_variables(build_type, compiler, sanitizer, package_type, cache, distcc_hosts, unbundled, split_binary, version, author, official):
result = []
cmake_flags = ['$CMAKE_FLAGS']
cc = compiler
cxx = cc.replace('gcc', 'g++').replace('clang', 'clang++')
if package_type == "deb":
result.append("DEB_CC={}".format(compiler))
result.append("DEB_CXX={}".format(compiler.replace('gcc', 'g++').replace('clang', 'clang++')))
result.append("DEB_CC={}".format(cc))
result.append("DEB_CXX={}".format(cxx))
elif package_type == "binary":
result.append("CC={}".format(compiler))
result.append("CXX={}".format(compiler.replace('gcc', 'g++').replace('clang', 'clang++')))
result.append("CC={}".format(cc))
result.append("CXX={}".format(cxx))
cmake_flags.append('-DCMAKE_C_COMPILER=`which {}`'.format(cc))
cmake_flags.append('-DCMAKE_CXX_COMPILER=`which {}`'.format(cxx))
if sanitizer:
result.append("SANITIZER={}".format(sanitizer))
if build_type:
result.append("BUILD_TYPE={}".format(build_type))
if cache:
if cache == 'distcc':
result.append("CCACHE_PREFIX={}".format(cache))
if cache:
result.append("CCACHE_DIR=/ccache")
result.append("CCACHE_BASEDIR=/build")
result.append("CCACHE_NOHASHDIR=true")
result.append("CCACHE_COMPILERCHECK=content")
# result.append("CCACHE_UMASK=777")
if distcc_hosts:
hosts_with_params = ["{}/24,lzo".format(host) for host in distcc_hosts] + ["localhost/`nproc`"]
result.append('DISTCC_HOSTS="{}"'.format(" ".join(hosts_with_params)))
@ -126,10 +140,10 @@ def parse_env_variables(build_type, compiler, sanitizer, package_type, cache, di
result.append('DISTCC_HOSTS="{}"'.format("localhost/`nproc`"))
if unbundled:
result.append('CMAKE_FLAGS="-DUNBUNDLED=1 -DENABLE_MYSQL=0 -DENABLE_POCO_ODBC=0 -DENABLE_ODBC=0 $CMAKE_FLAGS"')
cmake_flags.append('-DUNBUNDLED=1 -DENABLE_MYSQL=0 -DENABLE_POCO_ODBC=0 -DENABLE_ODBC=0')
if split_binary:
result.append('CMAKE_FLAGS="-DUSE_STATIC_LIBRARIES=0 -DSPLIT_SHARED_LIBRARIES=1 -DCLICKHOUSE_SPLIT_BINARY=1 $CMAKE_FLAGS"')
cmake_flags.append('-DUSE_STATIC_LIBRARIES=0 -DSPLIT_SHARED_LIBRARIES=1 -DCLICKHOUSE_SPLIT_BINARY=1')
if version:
result.append("VERSION_STRING='{}'".format(version))
@ -138,7 +152,9 @@ def parse_env_variables(build_type, compiler, sanitizer, package_type, cache, di
result.append("AUTHOR='{}'".format(author))
if official:
result.append('CMAKE_FLAGS="-DYANDEX_OFFICIAL_BUILD=1 $CMAKE_FLAGS"')
cmake_flags.append('-DYANDEX_OFFICIAL_BUILD=1')
result.append('CMAKE_FLAGS="' + ' '.join(cmake_flags) + '"')
return result
@ -154,6 +170,7 @@ if __name__ == "__main__":
parser.add_argument("--unbundled", action="store_true")
parser.add_argument("--split-binary", action="store_true")
parser.add_argument("--cache", choices=("", "ccache", "distcc"), default="")
parser.add_argument("--ccache_dir", default= os.getenv("HOME", "") + '/.ccache')
parser.add_argument("--distcc-hosts", nargs="+")
parser.add_argument("--force-build-image", action="store_true")
parser.add_argument("--version")
@ -180,7 +197,7 @@ if __name__ == "__main__":
args.cache, args.distcc_hosts, args.unbundled, args.split_binary,
args.version, args.author, args.official)
if args.package_type != "freebsd":
run_docker_image_with_env(image_name, args.output_dir, env_prepared, ch_root)
run_docker_image_with_env(image_name, args.output_dir, env_prepared, ch_root, args.ccache_dir)
else:
logging.info("Running freebsd build, arguments will be ignored")
run_vagrant_box_with_env(image_name, args.output_dir, ch_root)