mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 20:24:31 +00:00
packaging/qemu: Build and package completely in the container
Currently QEMU is built inside the container, its tarball pulled to the host, files removed then packaged again. Instead, let's run all those steps inside the container and the resulting tarball will be the final version. For that end, it is introduced the qemu-build-post.sh script which will remove the uneeded files and create the tarball. The patterns for directories on qemu.blacklist had to be changed to work properly with `find -path`. Fixes #1168 Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
This commit is contained in:
parent
4c3377de3b
commit
e5c710e833
@ -56,6 +56,7 @@ RUN git checkout "${QEMU_VIRTIOFS_TAG}"
|
||||
ADD scripts/configure-hypervisor.sh /root/configure-hypervisor.sh
|
||||
ADD qemu /root/kata_qemu
|
||||
ADD scripts/apply_patches.sh /root/apply_patches.sh
|
||||
ADD static-build /root/static-build
|
||||
|
||||
# Apply experimental specific patches
|
||||
# Patches to quick fix virtiofs fork
|
||||
@ -74,4 +75,4 @@ RUN make install DESTDIR="${QEMU_DESTDIR}"
|
||||
RUN cd "${QEMU_DESTDIR}/${PREFIX}" && \
|
||||
mv bin/qemu-system-x86_64 bin/qemu-virtiofs-system-x86_64 && \
|
||||
mv libexec/kata-qemu/virtiofsd bin/virtiofsd-dax
|
||||
RUN cd "${QEMU_DESTDIR}" && tar -czvf "${QEMU_TARBALL}" *
|
||||
RUN /root/static-build/scripts/qemu-build-post.sh
|
||||
|
@ -53,7 +53,3 @@ sudo "${DOCKER_CLI}" run \
|
||||
mv "${qemu_destdir}/${qemu_virtiofs_tar}" /share/
|
||||
|
||||
sudo chown ${USER}:${USER} "${PWD}/${qemu_virtiofs_tar}"
|
||||
|
||||
# Remove blacklisted binaries
|
||||
gzip -d < "${qemu_virtiofs_tar}" | tar --delete --wildcards -f - ${qemu_black_list[*]} | gzip > "${qemu_tmp_tar}"
|
||||
mv -f "${qemu_tmp_tar}" "${qemu_virtiofs_tar}"
|
||||
|
@ -6,7 +6,7 @@ qemu_black_list=(
|
||||
*/bin/qemu-pr-helper
|
||||
*/bin/virtfs-proxy-helper
|
||||
*/libexec/kata-qemu/qemu*
|
||||
*/share/*/applications/
|
||||
*/share/*/applications
|
||||
*/share/*/*.dtb
|
||||
*/share/*/efi-e1000e.rom
|
||||
*/share/*/efi-e1000.rom
|
||||
@ -15,9 +15,9 @@ qemu_black_list=(
|
||||
*/share/*/efi-pcnet.rom
|
||||
*/share/*/efi-rtl8139.rom
|
||||
*/share/*/efi-vmxnet3.rom
|
||||
*/share/*/icons/
|
||||
*/share/*/icons
|
||||
*/share/*/*.img
|
||||
*/share/*/keymaps/
|
||||
*/share/*/keymaps
|
||||
*/share/*/multiboot.bin
|
||||
*/share/*/openbios-ppc
|
||||
*/share/*/openbios-sparc32
|
||||
|
@ -56,6 +56,7 @@ RUN git clone https://github.com/qemu/keycodemapdb.git ui/keycodemapdb
|
||||
ADD scripts/configure-hypervisor.sh /root/configure-hypervisor.sh
|
||||
ADD qemu /root/kata_qemu
|
||||
ADD scripts/apply_patches.sh /root/apply_patches.sh
|
||||
ADD static-build /root/static-build
|
||||
|
||||
RUN stable_branch=$(cat VERSION | awk 'BEGIN{FS=OFS="."}{print $1 "." $2 ".x"}') && \
|
||||
/root/apply_patches.sh "/root/kata_qemu/patches/${stable_branch}"
|
||||
@ -66,4 +67,4 @@ RUN PREFIX="${PREFIX}" /root/configure-hypervisor.sh -s kata-qemu | xargs ./conf
|
||||
RUN make -j$(nproc)
|
||||
RUN make -j$(nproc) virtiofsd
|
||||
RUN make install DESTDIR="${QEMU_DESTDIR}"
|
||||
RUN cd "${QEMU_DESTDIR}" && tar -czvf "${QEMU_TARBALL}" *
|
||||
RUN /root/static-build/scripts/qemu-build-post.sh
|
||||
|
@ -61,7 +61,3 @@ sudo docker run \
|
||||
mv "${qemu_destdir}/${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}"
|
||||
|
28
tools/packaging/static-build/scripts/qemu-build-post.sh
Executable file
28
tools/packaging/static-build/scripts/qemu-build-post.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2020 Red Hat, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# This script process QEMU post-build.
|
||||
#
|
||||
set -e
|
||||
|
||||
script_dir="$(realpath $(dirname $0))"
|
||||
source "${script_dir}/../qemu.blacklist"
|
||||
|
||||
if [[ -z "${QEMU_TARBALL}" || -z "${QEMU_DESTDIR}" ]]; then
|
||||
echo "$0: needs QEMU_TARBALL and QEMU_DESTDIR exported"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd "${QEMU_DESTDIR}"
|
||||
# Remove files to reduce the surface.
|
||||
echo "INFO: remove uneeded files"
|
||||
for pattern in ${qemu_black_list[@]}; do
|
||||
find . -path "$pattern" | xargs rm -rfv
|
||||
done
|
||||
|
||||
echo "INFO: create the tarball"
|
||||
tar -czvf "${QEMU_TARBALL}" *
|
||||
popd
|
Loading…
Reference in New Issue
Block a user