mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-17 06:48:51 +00:00
Merge pull request #1025 from wainersm/static_build_qemu_patches
Use apply_patches.sh in qemu and kernel scripts
This commit is contained in:
@@ -62,7 +62,8 @@ DESTDIR="${DESTDIR:-/}"
|
|||||||
#PREFIX=
|
#PREFIX=
|
||||||
PREFIX="${PREFIX:-/usr}"
|
PREFIX="${PREFIX:-/usr}"
|
||||||
|
|
||||||
source "${script_dir}/../scripts/lib.sh"
|
packaging_scripts_dir="${script_dir}/../scripts"
|
||||||
|
source "${packaging_scripts_dir}/lib.sh"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
exit_code="$1"
|
exit_code="$1"
|
||||||
@@ -332,34 +333,14 @@ setup_kernel() {
|
|||||||
local major_kernel
|
local major_kernel
|
||||||
major_kernel=$(get_major_kernel_version "${kernel_version}")
|
major_kernel=$(get_major_kernel_version "${kernel_version}")
|
||||||
local patches_dir_for_version="${patches_path}/${major_kernel}.x"
|
local patches_dir_for_version="${patches_path}/${major_kernel}.x"
|
||||||
local kernel_patches=""
|
|
||||||
if [ -d "${patches_dir_for_version}" ]; then
|
|
||||||
# Patches are expected to be named in the standard
|
|
||||||
# git-format-patch(1) format where the first part of the
|
|
||||||
# filename represents the patch ordering
|
|
||||||
# (lowest numbers apply first):
|
|
||||||
#
|
|
||||||
# "${number}-${dashed_description}"
|
|
||||||
#
|
|
||||||
# For example,
|
|
||||||
#
|
|
||||||
# 0001-fix-the-bad-thing.patch
|
|
||||||
# 0002-improve-the-fix-the-bad-thing-fix.patch
|
|
||||||
# 0003-correct-compiler-warnings.patch
|
|
||||||
kernel_patches=$(find "${patches_dir_for_version}" -name '*.patch' -type f |\
|
|
||||||
sort -t- -k1,1n)
|
|
||||||
else
|
|
||||||
info "kernel patches directory does not exit"
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ -n "${arch_target}" ] || arch_target="$(uname -m)"
|
[ -n "${arch_target}" ] || arch_target="$(uname -m)"
|
||||||
arch_target=$(arch_to_kernel "${arch_target}")
|
arch_target=$(arch_to_kernel "${arch_target}")
|
||||||
(
|
(
|
||||||
cd "${kernel_path}" || exit 1
|
cd "${kernel_path}" || exit 1
|
||||||
for p in ${kernel_patches}; do
|
|
||||||
info "Applying patch $p"
|
# Apply version specific patches
|
||||||
patch -p1 --fuzz 0 <"$p"
|
${packaging_scripts_dir}/apply_patches.sh "${patches_dir_for_version}"
|
||||||
done
|
|
||||||
|
|
||||||
[ -n "${hypervisor_target}" ] || hypervisor_target="kvm"
|
[ -n "${hypervisor_target}" ] || hypervisor_target="kvm"
|
||||||
[ -n "${kernel_config_path}" ] || kernel_config_path=$(get_default_kernel_config "${kernel_version}" "${hypervisor_target}" "${arch_target}" "${kernel_path}")
|
[ -n "${kernel_config_path}" ] || kernel_config_path=$(get_default_kernel_config "${kernel_version}" "${hypervisor_target}" "${arch_target}" "${kernel_path}")
|
||||||
|
@@ -1,27 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Copyright (c) 2020 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
# This script apply the needed for Kata Containers patches on QEMU.
|
|
||||||
# Note: It should be executed from inside the QEMU source directory.
|
|
||||||
#
|
|
||||||
set -e
|
|
||||||
|
|
||||||
script_dir="$(realpath $(dirname $0))"
|
|
||||||
|
|
||||||
qemu_version="$(cat VERSION)"
|
|
||||||
stable_branch=$(echo $qemu_version | \
|
|
||||||
awk 'BEGIN{FS=OFS="."}{print $1 "." $2 ".x"}')
|
|
||||||
patches_dir="${script_dir}/patches/${stable_branch}"
|
|
||||||
|
|
||||||
echo "Handle patches for QEMU $qemu_version (stable ${stable_branch})"
|
|
||||||
if [ -d $patches_dir ]; then
|
|
||||||
for patch in $(find $patches_dir -name '*.patch'); do
|
|
||||||
echo "Apply $patch"
|
|
||||||
git apply "$patch"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "No patches to apply"
|
|
||||||
fi
|
|
48
tools/packaging/scripts/apply_patches.sh
Executable file
48
tools/packaging/scripts/apply_patches.sh
Executable file
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 Red Hat, Inc.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
# This script apply patches.
|
||||||
|
#
|
||||||
|
set -e
|
||||||
|
|
||||||
|
script_dir="$(realpath $(dirname $0))"
|
||||||
|
patches_dir="$1"
|
||||||
|
|
||||||
|
if [ -z "$patches_dir" ]; then
|
||||||
|
cat <<-EOT
|
||||||
|
Apply patches to the sources at the current directory.
|
||||||
|
|
||||||
|
Patches are expected to be named in the standard git-format-patch(1) format where
|
||||||
|
the first part of the filename represents the patch ordering (lowest numbers
|
||||||
|
apply first):
|
||||||
|
'NUMBER-DASHED_DESCRIPTION.patch'
|
||||||
|
|
||||||
|
For example,
|
||||||
|
|
||||||
|
0001-fix-the-bad-thing.patch
|
||||||
|
0002-improve-the-fix-the-bad-thing-fix.patch
|
||||||
|
0003-correct-compiler-warnings.patch
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
$0 PATCHES_DIR
|
||||||
|
Where:
|
||||||
|
PATCHES_DIR is the directory containing the patches
|
||||||
|
EOT
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "INFO: Apply patches from $patches_dir"
|
||||||
|
if [ -d "$patches_dir" ]; then
|
||||||
|
patches=($(find "$patches_dir" -name '*.patch'|sort -t- -k1,1n))
|
||||||
|
echo "INFO: Found ${#patches[@]} patches"
|
||||||
|
for patch in ${patches[@]}; do
|
||||||
|
echo "INFO: Apply $patch"
|
||||||
|
git apply "$patch" || \
|
||||||
|
{ echo >&2 "ERROR: Not applied. Exiting..."; exit 1; }
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "INFO: Patches directory does not exist"
|
||||||
|
fi
|
@@ -54,16 +54,15 @@ RUN git checkout "${QEMU_VIRTIOFS_TAG}"
|
|||||||
|
|
||||||
ADD scripts/configure-hypervisor.sh /root/configure-hypervisor.sh
|
ADD scripts/configure-hypervisor.sh /root/configure-hypervisor.sh
|
||||||
ADD qemu /root/kata_qemu
|
ADD qemu /root/kata_qemu
|
||||||
|
ADD scripts/apply_patches.sh /root/apply_patches.sh
|
||||||
|
|
||||||
# Apply experimental specific patches
|
# Apply experimental specific patches
|
||||||
# Patches to quick fix virtiofs fork
|
# Patches to quick fix virtiofs fork
|
||||||
ENV VIRTIOFS_PATCHES_DIR=/root/kata_qemu/patches/${QEMU_VIRTIOFS_TAG}/
|
ENV VIRTIOFS_PATCHES_DIR=/root/kata_qemu/patches/${QEMU_VIRTIOFS_TAG}/
|
||||||
RUN if [ -d ${VIRTIOFS_PATCHES_DIR} ]; then \
|
RUN /root/apply_patches.sh ${VIRTIOFS_PATCHES_DIR}
|
||||||
echo "Patches to apply for virtiofs fixes:"; \
|
# Apply the stable branch patches
|
||||||
for patch in $(find "${VIRTIOFS_PATCHES_DIR}" -name '*.patch' -type f |sort -t- -k1,1n); do \
|
RUN stable_branch=$(cat VERSION | awk 'BEGIN{FS=OFS="."}{print $1 "." $2 ".x"}') && \
|
||||||
git apply $patch; \
|
/root/apply_patches.sh "/root/kata_qemu/patches/${stable_branch}"
|
||||||
done;fi
|
|
||||||
RUN /root/kata_qemu/apply_patches.sh
|
|
||||||
|
|
||||||
RUN PREFIX="${PREFIX}" /root/configure-hypervisor.sh -s kata-qemu | sed -e 's|--disable-seccomp||g' | xargs ./configure \
|
RUN PREFIX="${PREFIX}" /root/configure-hypervisor.sh -s kata-qemu | sed -e 's|--disable-seccomp||g' | xargs ./configure \
|
||||||
--with-pkgversion=kata-static
|
--with-pkgversion=kata-static
|
||||||
|
@@ -54,8 +54,10 @@ RUN git clone https://github.com/qemu/keycodemapdb.git ui/keycodemapdb
|
|||||||
|
|
||||||
ADD scripts/configure-hypervisor.sh /root/configure-hypervisor.sh
|
ADD scripts/configure-hypervisor.sh /root/configure-hypervisor.sh
|
||||||
ADD qemu /root/kata_qemu
|
ADD qemu /root/kata_qemu
|
||||||
|
ADD scripts/apply_patches.sh /root/apply_patches.sh
|
||||||
|
|
||||||
RUN /root/kata_qemu/apply_patches.sh
|
RUN stable_branch=$(cat VERSION | awk 'BEGIN{FS=OFS="."}{print $1 "." $2 ".x"}') && \
|
||||||
|
/root/apply_patches.sh "/root/kata_qemu/patches/${stable_branch}"
|
||||||
|
|
||||||
RUN PREFIX="${PREFIX}" /root/configure-hypervisor.sh -s kata-qemu | xargs ./configure \
|
RUN PREFIX="${PREFIX}" /root/configure-hypervisor.sh -s kata-qemu | xargs ./configure \
|
||||||
--with-pkgversion=kata-static
|
--with-pkgversion=kata-static
|
||||||
|
Reference in New Issue
Block a user