mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-02 02:02:24 +00:00
Merge pull request #451 from jcvenegas/kernel-patches-per-version
kernel: use patches per kernel version.
This commit is contained in:
commit
8ae6755bc8
@ -123,11 +123,19 @@ get_kernel() {
|
|||||||
|
|
||||||
sha256sum -c "${kernel_tarball}.sha256"
|
sha256sum -c "${kernel_tarball}.sha256"
|
||||||
|
|
||||||
tar xf ${kernel_tarball}
|
tar xf "${kernel_tarball}"
|
||||||
|
|
||||||
mv "linux-${version}" "${kernel_path}"
|
mv "linux-${version}" "${kernel_path}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_major_kernel_version() {
|
||||||
|
local version="${1}"
|
||||||
|
[ -n "${version}" ] || die "kernel version not provided"
|
||||||
|
major_version=$(echo "${version}" | cut -d. -f1)
|
||||||
|
minor_version=$(echo "${version}" | cut -d. -f2)
|
||||||
|
echo "${major_version}.${minor_version}"
|
||||||
|
}
|
||||||
|
|
||||||
get_default_kernel_config() {
|
get_default_kernel_config() {
|
||||||
local version="${1}"
|
local version="${1}"
|
||||||
|
|
||||||
@ -138,9 +146,9 @@ get_default_kernel_config() {
|
|||||||
[ -n "${hypervisor}" ] || die "hypervisor not provided"
|
[ -n "${hypervisor}" ] || die "hypervisor not provided"
|
||||||
[ -n "${kernel_arch}" ] || die "kernel arch not provided"
|
[ -n "${kernel_arch}" ] || die "kernel arch not provided"
|
||||||
|
|
||||||
major_version=$(echo "${version}" | cut -d. -f1)
|
local kernel_ver
|
||||||
minor_version=$(echo "${version}" | cut -d. -f2)
|
kernel_ver=$(get_major_kernel_version "${version}")
|
||||||
config="${default_kernel_config_dir}/${kernel_arch}_kata_${hypervisor}_${major_version}.${minor_version}.x"
|
config="${default_kernel_config_dir}/${kernel_arch}_kata_${hypervisor}_${major_kernel}.x"
|
||||||
[ -f "${config}" ] || die "failed to find default config ${config}"
|
[ -f "${config}" ] || die "failed to find default config ${config}"
|
||||||
echo "${config}"
|
echo "${config}"
|
||||||
}
|
}
|
||||||
@ -185,21 +193,32 @@ setup_kernel() {
|
|||||||
|
|
||||||
[ -d "${patches_path}" ] || die " patches path '${patches_path}' does not exist"
|
[ -d "${patches_path}" ] || die " patches path '${patches_path}' does not exist"
|
||||||
|
|
||||||
kernel_patches=$(find "${patches_path}" -name '*.patch' -type f)
|
local major_kernel
|
||||||
|
major_kernel=$(get_major_kernel_version "${kernel_version}")
|
||||||
|
local patches_dir_for_version="${patches_path}/${major_kernel}.x"
|
||||||
|
local kernel_patches=""
|
||||||
|
if [ -d "${patches_dir_for_version}" ]; then
|
||||||
|
kernel_patches=$(find "${patches_dir_for_version}" -name '*.patch' -type f)
|
||||||
|
else
|
||||||
|
info "kernel patches directory does not exit"
|
||||||
|
|
||||||
pushd "${kernel_path}" >>/dev/null
|
fi
|
||||||
for p in ${kernel_patches}; do
|
|
||||||
info "Applying patch $p"
|
|
||||||
patch -p1 <"$p"
|
|
||||||
done
|
|
||||||
|
|
||||||
[ -n "${hypervisor_target}" ] || hypervisor_target="kvm"
|
|
||||||
[ -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}")
|
||||||
[ -n "${kernel_config_path}" ] || kernel_config_path=$(get_default_kernel_config "${kernel_version}" "${hypervisor_target}" "${arch_target}")
|
(
|
||||||
|
cd "${kernel_path}" || exit 1
|
||||||
|
for p in ${kernel_patches}; do
|
||||||
|
info "Applying patch $p"
|
||||||
|
patch -p1 <"$p"
|
||||||
|
done
|
||||||
|
|
||||||
cp "${kernel_config_path}" ./.config
|
[ -n "${hypervisor_target}" ] || hypervisor_target="kvm"
|
||||||
make oldconfig
|
[ -n "${kernel_config_path}" ] || kernel_config_path=$(get_default_kernel_config "${kernel_version}" "${hypervisor_target}" "${arch_target}")
|
||||||
|
|
||||||
|
cp "${kernel_config_path}" ./.config
|
||||||
|
make oldconfig
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
build_kernel() {
|
build_kernel() {
|
||||||
|
@ -1 +1 @@
|
|||||||
34
|
35
|
||||||
|
@ -27,7 +27,9 @@ KATA_CONFIG_VERSION=$(cat "${SCRIPT_DIR}/../../kernel/kata_config_version")
|
|||||||
|
|
||||||
KR_SERIES="$(echo $VERSION | cut -d "." -f 1).x"
|
KR_SERIES="$(echo $VERSION | cut -d "." -f 1).x"
|
||||||
KR_LTS=$(echo $VERSION | cut -d "." -f 1,2)
|
KR_LTS=$(echo $VERSION | cut -d "." -f 1,2)
|
||||||
KR_PATCHES=$(eval find "${SCRIPT_DIR}/../../kernel/patches" -type f -name "*.patch")
|
ln -sfT "${SCRIPT_DIR}/../../kernel/patches-${KR_LTS}" "${SCRIPT_DIR}/patches"
|
||||||
|
|
||||||
|
KR_PATCHES=$(eval find "${SCRIPT_DIR}/patches" -type f -name "*.patch")
|
||||||
|
|
||||||
KR_REL=https://www.kernel.org/releases.json
|
KR_REL=https://www.kernel.org/releases.json
|
||||||
KR_SHA=https://cdn.kernel.org/pub/linux/kernel/v"${KR_SERIES}"/sha256sums.asc
|
KR_SHA=https://cdn.kernel.org/pub/linux/kernel/v"${KR_SERIES}"/sha256sums.asc
|
||||||
@ -66,6 +68,5 @@ get_git_info
|
|||||||
#TODO delete me: used by changelog_update
|
#TODO delete me: used by changelog_update
|
||||||
hash_tag="nocommit"
|
hash_tag="nocommit"
|
||||||
changelog_update "${VERSION}-${KATA_CONFIG_VERSION}"
|
changelog_update "${VERSION}-${KATA_CONFIG_VERSION}"
|
||||||
ln -sfT "${SCRIPT_DIR}/../../kernel/patches" "${SCRIPT_DIR}/patches"
|
|
||||||
generate_files "$SCRIPT_DIR" "${replace_list[@]}"
|
generate_files "$SCRIPT_DIR" "${replace_list[@]}"
|
||||||
build_pkg "${PROJECT_REPO}"
|
build_pkg "${PROJECT_REPO}"
|
||||||
|
@ -218,8 +218,9 @@ parts:
|
|||||||
|
|
||||||
make mrproper
|
make mrproper
|
||||||
|
|
||||||
|
|
||||||
# Apply patches
|
# Apply patches
|
||||||
for patch in ${SNAPCRAFT_STAGE}/kernel/patches/*.patch; do
|
for patch in ${SNAPCRAFT_STAGE}/kernel/patches/${x_version}/*.patch; do
|
||||||
echo "Applying $(basename "$patch") ..."
|
echo "Applying $(basename "$patch") ..."
|
||||||
patch \
|
patch \
|
||||||
--batch \
|
--batch \
|
||||||
|
Loading…
Reference in New Issue
Block a user