From 1e3c577c03bfd13264f95a74e87462df3ebf7a85 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Fri, 14 Aug 2020 09:45:23 -0700 Subject: [PATCH] static-build: build the real static binary for clh This patch reuses the 'dev_cli.sh' from cloud-hypervisor repo to build a static binary of clh without creating our own docker image nor installing extra dependencies. Fixes: #1033 Signed-off-by: Bo Chen --- .../cloud-hypervisor/build-static-clh.sh | 4 +-- .../cloud-hypervisor/docker-build/Dockerfile | 12 ------- .../cloud-hypervisor/docker-build/build.sh | 36 ------------------- 3 files changed, 2 insertions(+), 50 deletions(-) delete mode 100644 static-build/cloud-hypervisor/docker-build/Dockerfile delete mode 100755 static-build/cloud-hypervisor/docker-build/build.sh diff --git a/static-build/cloud-hypervisor/build-static-clh.sh b/static-build/cloud-hypervisor/build-static-clh.sh index b53cff40..30987f40 100755 --- a/static-build/cloud-hypervisor/build-static-clh.sh +++ b/static-build/cloud-hypervisor/build-static-clh.sh @@ -36,6 +36,6 @@ repo_dir="${repo_dir//.git}" cd "${repo_dir}" git fetch || true git checkout "${cloud_hypervisor_version}" -"${script_dir}/docker-build/build.sh" +./scripts/dev_cli.sh build --release --libc musl rm -f cloud-hypervisor -cp ./target/release/cloud-hypervisor . +cp build/cargo_target/$(uname -m)-unknown-linux-musl/release/cloud-hypervisor . diff --git a/static-build/cloud-hypervisor/docker-build/Dockerfile b/static-build/cloud-hypervisor/docker-build/Dockerfile deleted file mode 100644 index 78aaa2b3..00000000 --- a/static-build/cloud-hypervisor/docker-build/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -# -# Copyright (c) 2019 Intel Corporation -# -# SPDX-License-Identifier: Apache-2.0 - -FROM ubuntu:18.04 - -RUN apt-get update -RUN apt-get --no-install-recommends install -yq apt-utils ca-certificates build-essential mtools libssl-dev pkg-config curl git -RUN nohup curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc -ENV PATH="/root/.cargo/bin:${PATH}" diff --git a/static-build/cloud-hypervisor/docker-build/build.sh b/static-build/cloud-hypervisor/docker-build/build.sh deleted file mode 100755 index f7e3e988..00000000 --- a/static-build/cloud-hypervisor/docker-build/build.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2019 Intel Corporation -# -# SPDX-License-Identifier: Apache-2.0 - -set -o errexit -set -o nounset -set -o pipefail - -script_dir=$(dirname $(readlink -f "$0")) -docker_image="cloud-hypervisor-builder" - -DOCKER_CLI="docker" - -if ! command -v docker && command -v podman; then - DOCKER_CLI="podman" -fi - -sudo "${DOCKER_CLI}" build -t "${docker_image}" "${script_dir}" - -if test -t 1; then - USE_TTY="-ti" -else - USE_TTY="" - echo "INFO: not tty build" -fi - -sudo "${DOCKER_CLI}" run \ - --rm \ - -v "$(pwd):/$(pwd)" \ - -w "$(pwd)" \ - --env "CARGO_HOME=$(pwd)" \ - ${USE_TTY} \ - "${docker_image}" \ - cargo build --release