packaging: merge packaging repository

git-subtree-dir: tools/packaging
git-subtree-mainline: f818b46a41
git-subtree-split: 1f22d72d5d

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao
2020-06-23 22:49:04 -07:00
645 changed files with 292694 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
from ubuntu:20.04
ARG QEMU_REPO
# commit/tag/branch
ARG QEMU_VERSION
ARG QEMU_TARBALL
ARG PREFIX
WORKDIR /root/qemu
RUN apt-get update && apt-get upgrade -y
RUN apt-get --no-install-recommends install -y \
apt-utils \
autoconf \
automake \
bc \
bison \
ca-certificates \
cpio \
flex \
gawk \
libaudit-dev \
libblkid-dev \
libcap-dev \
libcap-ng-dev \
libdw-dev \
libelf-dev \
libffi-dev \
libglib2.0-0 \
libglib2.0-dev \
libglib2.0-dev git \
libltdl-dev \
libmount-dev \
libpixman-1-dev \
libpmem-dev \
libselinux1-dev \
libtool \
make \
pkg-config \
pkg-config \
python \
python-dev \
rsync \
zlib1g-dev
RUN cd .. && git clone "${QEMU_REPO}" qemu
RUN git checkout "${QEMU_VERSION}"
RUN git clone https://github.com/qemu/capstone.git capstone
RUN git clone https://github.com/qemu/keycodemapdb.git ui/keycodemapdb
ADD scripts/configure-hypervisor.sh /root/configure-hypervisor.sh
ADD qemu/patches/ /root/kata_qemu_patches
RUN \
cat VERSION; \
stable_branch=$(cat VERSION | awk 'BEGIN{FS=OFS="."}{print $1 "." $2 ".x"}');\
for patch in $(find /root/kata_qemu_patches/${stable_branch}/ -name '*.patch'); do\
echo "apply $patch";\
git apply "$patch"; \
done
RUN PREFIX="${PREFIX}" /root/configure-hypervisor.sh -s kata-qemu | xargs ./configure \
--with-pkgversion=kata-static
RUN make -j$(nproc)
RUN make install DESTDIR=/tmp/qemu-static
RUN cd /tmp/qemu-static && tar -czvf "${QEMU_TARBALL}" *

View File

@@ -0,0 +1,8 @@
MK_DIR :=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
CONFIG_DIR := $(MK_DIR)/../../scripts/
build:
"$(MK_DIR)/build-static-qemu.sh"
clean:
rm -f kata-qemu-static.tar.gz

View File

@@ -0,0 +1,65 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
set -o errexit
set -o nounset
set -o pipefail
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${script_dir}/../../scripts/lib.sh"
source "${script_dir}/../qemu.blacklist"
packaging_dir="${script_dir}/../.."
qemu_tar="kata-static-qemu.tar.gz"
qemu_tmp_tar="kata-static-qemu-tmp.tar.gz"
qemu_repo="${qemu_repo:-}"
qemu_version="${qemu_version:-}"
kata_version="${kata_version:-}"
if [ -z "$qemu_repo" ]; then
info "Get qemu information from runtime versions.yaml"
qemu_url=$(get_from_kata_deps "assets.hypervisor.qemu.url" "${kata_version}")
[ -n "$qemu_url" ] || die "failed to get qemu url"
qemu_repo="${qemu_url}.git"
fi
[ -n "$qemu_repo" ] || die "failed to get qemu repo"
[ -n "$qemu_version" ] || qemu_version=$(get_from_kata_deps "assets.hypervisor.qemu.version" "${kata_version}")
if ! (git ls-remote --heads "${qemu_url}" | grep -q "refs/heads/${qemu_version}"); then
qemu_version=$(get_from_kata_deps "assets.hypervisor.qemu.tag" "${kata_version}")
fi
[ -n "$qemu_version" ] || die "failed to get qemu version"
info "Build ${qemu_repo} version: ${qemu_version}"
http_proxy="${http_proxy:-}"
https_proxy="${https_proxy:-}"
prefix="${prefix:-"/opt/kata"}"
sudo docker build \
--no-cache \
--build-arg http_proxy="${http_proxy}" \
--build-arg https_proxy="${https_proxy}" \
--build-arg QEMU_REPO="${qemu_repo}" \
--build-arg QEMU_VERSION="${qemu_version}" \
--build-arg QEMU_TARBALL="${qemu_tar}" \
--build-arg PREFIX="${prefix}" \
"${packaging_dir}" \
-f "${script_dir}/Dockerfile" \
-t qemu-static
sudo docker run \
-i \
-v "${PWD}":/share qemu-static \
mv "/tmp/qemu-static/${qemu_tar}" /share/
sudo chown ${USER}:${USER} "${PWD}/${qemu_tar}"
# Remove blacklisted binaries
gzip -d < "${qemu_tar}" | tar --delete --wildcards -f - ${qemu_black_list[*]} | gzip > "${qemu_tmp_tar}"
mv -f "${qemu_tmp_tar}" "${qemu_tar}"